Skip to content

Commit

Permalink
Merge pull request #3185 from pmolodo/pr/hdEmbree-usd-lux-prep
Browse files Browse the repository at this point in the history
[hdEmbree] minor fixes / tweaks  (hdEmbree-UsdLux-PR03)

(Internal change: 2341720)
  • Loading branch information
pixar-oss committed Sep 24, 2024
2 parents 5003858 + dabdeb5 commit 84da670
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pxr/imaging/plugin/hdEmbree/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

PXR_NAMESPACE_OPEN_SCOPE

class HdEmbreePrototypeContext;
class HdEmbreeInstanceContext;
struct HdEmbreePrototypeContext;
struct HdEmbreeInstanceContext;

/// \class HdEmbreeMesh
///
Expand Down Expand Up @@ -171,7 +171,7 @@ class HdEmbreeMesh final : public HdMesh {

private:
// Every HdEmbreeMesh is treated as instanced; if there's no instancer,
// the prototype has a single identity istance. The prototype is stored
// the prototype has a single identity instance. The prototype is stored
// as _rtcMeshId, in _rtcMeshScene.
unsigned _rtcMeshId;
RTCScene _rtcMeshScene;
Expand Down
26 changes: 20 additions & 6 deletions pxr/imaging/plugin/hdEmbree/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@
#include <chrono>
#include <thread>

namespace {

PXR_NAMESPACE_USING_DIRECTIVE

// -------------------------------------------------------------------------
// General Ray Utilities
// -------------------------------------------------------------------------

inline GfVec3f
_CalculateHitPosition(RTCRayHit const& rayHit)
{
return GfVec3f(rayHit.ray.org_x + rayHit.ray.tfar * rayHit.ray.dir_x,
rayHit.ray.org_y + rayHit.ray.tfar * rayHit.ray.dir_y,
rayHit.ray.org_z + rayHit.ray.tfar * rayHit.ray.dir_z);
}

} // anonymous namespace

PXR_NAMESPACE_OPEN_SCOPE

HdEmbreeRenderer::HdEmbreeRenderer()
Expand Down Expand Up @@ -762,9 +780,7 @@ HdEmbreeRenderer::_ComputeDepth(RTCRayHit const& rayHit,
}

if (clip) {
GfVec3f hitPos = GfVec3f(rayHit.ray.org_x + rayHit.ray.tfar * rayHit.ray.dir_x,
rayHit.ray.org_y + rayHit.ray.tfar * rayHit.ray.dir_y,
rayHit.ray.org_z + rayHit.ray.tfar * rayHit.ray.dir_z);
GfVec3f hitPos = _CalculateHitPosition(rayHit);

hitPos = GfVec3f(_viewMatrix.Transform(hitPos));
hitPos = GfVec3f(_projMatrix.Transform(hitPos));
Expand Down Expand Up @@ -874,9 +890,7 @@ HdEmbreeRenderer::_ComputeColor(RTCRayHit const& rayHit,
rtcGetGeometryUserData(rtcGetGeometry(instanceContext->rootScene,rayHit.hit.geomID)));

// Compute the worldspace location of the rayHit hit.
GfVec3f hitPos = GfVec3f(rayHit.ray.org_x + rayHit.ray.tfar * rayHit.ray.dir_x,
rayHit.ray.org_y + rayHit.ray.tfar * rayHit.ray.dir_y,
rayHit.ray.org_z + rayHit.ray.tfar * rayHit.ray.dir_z);
GfVec3f hitPos = _CalculateHitPosition(rayHit);

// If a normal primvar is present (e.g. from smooth shading), use that
// for shading; otherwise use the flat face normal.
Expand Down

0 comments on commit 84da670

Please sign in to comment.