7#ifndef PXR_IMAGING_PLUGIN_HD_EMBREE_RENDERER_H
8#define PXR_IMAGING_PLUGIN_HD_EMBREE_RENDERER_H
12#include "pxr/imaging/plugin/hdEmbree/context.h"
13#include "pxr/imaging/plugin/hdEmbree/light.h"
15#include "pxr/imaging/hd/aov.h"
16#include "pxr/imaging/hd/renderThread.h"
21#include <embree4/rtcore.h>
22#include <embree4/rtcore_device.h>
23#include <embree4/rtcore_ray.h>
30PXR_NAMESPACE_OPEN_SCOPE
32enum HdEmbree_RayMask: uint32_t {
55 using WriteMutex = std::mutex;
56 using ScopedLock = std::scoped_lock<WriteMutex>;
142 void _PreRenderSetup();
152 bool _ValidateAovBindings();
162 size_t tileStart,
size_t tileEnd);
166 void _TraceRay(
unsigned int x,
unsigned int y,
168 std::default_random_engine &random);
171 GfVec4f _ComputeColor(RTCRayHit
const& rayHit,
172 std::default_random_engine &random,
175 bool _ComputeDepth(RTCRayHit
const& rayHit,
float *depth,
bool clip);
177 bool _ComputeId(RTCRayHit
const& rayHit,
TfToken const& idType, int32_t *
id);
179 bool _ComputeNormal(RTCRayHit
const& rayHit,
GfVec3f *normal,
bool eye);
181 bool _ComputePrimvar(RTCRayHit
const& rayHit,
TfToken const& primvar,
190 float _ComputeAmbientOcclusion(
GfVec3f const& position,
192 std::default_random_engine &random);
199 std::default_random_engine &random,
203 float _Visibility(
GfVec3f const& position,
205 float offset = 1.0e-3f)
const;
208 bool _RayShouldContinue(RTCRayHit
const& rayHit)
const;
211 HdRenderPassAovBindingVector _aovBindings;
213 HdParsedAovTokenVector _aovNames;
216 bool _aovBindingsNeedValidation;
218 bool _aovBindingsValid;
226 unsigned int _height;
241 int _samplesToConvergence;
243 int _ambientOcclusionSamples;
245 bool _enableSceneColors;
247 bool _domeLightCameraVisibility;
249 int _randomNumberSeed;
251 bool _enableLighting;
254 std::atomic<int> _completedSamples;
257 mutable WriteMutex _lightsWriteMutex;
258 std::map<SdfPath, HdEmbree_Light*> _lightMap;
259 std::vector<HdEmbree_Light*> _domes;
262PXR_NAMESPACE_CLOSE_SCOPE
Stores a 4x4 matrix of double elements.
A 2D rectangle with integer coordinates.
Basic type for a vector of 3 float components.
Basic type for a vector of 4 float components.
HdEmbreeRenderer implements a renderer on top of Embree's raycasting abilities.
void SetSamplesToConvergence(int samplesToConvergence)
Set how many samples to render before considering an image converged.
void SetRandomNumberSeed(int randomNumberSeed)
Sets a number to seed the random number generator with.
void RemoveLight(SdfPath const &lightPath, HdEmbree_Light *light)
Remove a light.
void SetAmbientOcclusionSamples(int ambientOcclusionSamples)
Set how many samples to use for ambient occlusion.
void SetEnableSceneColors(bool enableSceneColors)
Sets whether to use scene colors while rendering.
void Render(HdRenderThread *renderThread)
Rendering entrypoint: add one sample per pixel to the whole sample buffer, and then loop until the im...
void SetEnableLighting(bool enableLighting)
Sets whether to enable direct lighting (disables ambient occlusion).
void AddLight(SdfPath const &lightPath, HdEmbree_Light *light)
Add a light.
HdEmbreeRenderer()
Renderer constructor.
~HdEmbreeRenderer()
Renderer destructor.
void MarkAovBuffersUnconverged()
Mark the aov buffers as unconverged.
void SetAovBindings(HdRenderPassAovBindingVector const &aovBindings)
Set the aov bindings to use for rendering.
void SetDomeLightCameraVisibility(bool domeLightCameraVisibility)
Sets whether dome light direct camera visibility should be enabled.
int GetCompletedSamples() const
Get the number of samples completed so far.
void SetScene(RTCScene scene)
Set the embree scene that this renderer should raycast into.
void SetCamera(const GfMatrix4d &viewMatrix, const GfMatrix4d &projMatrix)
Set the camera to use for rendering.
void Clear()
Clear the bound aov buffers (typically before rendering).
void SetDataWindow(const GfRect2i &dataWindow)
Set the data window to fill (same meaning as in CameraUtilFraming with coordinate system also being y...
HdRenderPassAovBindingVector const & GetAovBindings() const
Get the aov bindings being used for rendering.
HdRenderThread is a utility that specific render delegates can choose to use depending on their needs...
A path value used to locate objects in layers or scenegraphs.
Token for efficient comparison, assignment, and hashing of known strings.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
A small bit of state attached to each bit of prototype geometry in embree, for the benefit of HdEmbre...