Skip to content

Commit 65f44f3

Browse files
committed
[hdEmbree] add support for lighting double-sided meshes
1 parent 05ff0ad commit 65f44f3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

pxr/imaging/plugin/hdEmbree/mesh.h

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ class HdEmbreeMesh final : public HdMesh {
9999
/// embree state.
100100
virtual void Finalize(HdRenderParam *renderParam) override;
101101

102+
bool EmbreeMeshIsDoubleSided() const
103+
{
104+
return _doubleSided;
105+
}
106+
102107
protected:
103108
// Initialize the given representation of this Rprim.
104109
// This is called prior to syncing the prim, the first time the repr

pxr/imaging/plugin/hdEmbree/renderer.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -1660,8 +1660,23 @@ HdEmbreeRenderer::_ComputeLighting(
16601660
float vis = _Visibility(position, ls.wI, ls.dist * 0.99f);
16611661

16621662
// Add exitant luminance
1663+
float cosOffNormal = GfDot(ls.wI, normal);
1664+
if (cosOffNormal < 0.0f) {
1665+
bool doubleSided = false;
1666+
HdEmbreeMesh *mesh =
1667+
dynamic_cast<HdEmbreeMesh*>(prototypeContext->rprim);
1668+
if (mesh) {
1669+
doubleSided = mesh->EmbreeMeshIsDoubleSided();
1670+
}
1671+
1672+
if (doubleSided) {
1673+
cosOffNormal *= -1.0f;
1674+
} else {
1675+
cosOffNormal = 0.0f;
1676+
}
1677+
}
16631678
finalColor += ls.Li
1664-
* _DotZeroClip(ls.wI, normal)
1679+
* cosOffNormal
16651680
* brdf
16661681
* vis
16671682
* ls.invPdfW;

0 commit comments

Comments
 (0)