Loading...
Searching...
No Matches
light.h
1//
2// Copyright 2024 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_PLUGIN_HD_EMBREE_LIGHT_H
8#define PXR_IMAGING_PLUGIN_HD_EMBREE_LIGHT_H
9
10#include "pxr/base/gf/vec3f.h"
13#include "pxr/imaging/hd/light.h"
14
15#include <embree4/rtcore_common.h>
16#include <embree4/rtcore_geometry.h>
17
18#include <limits>
19#include <variant>
20
21PXR_NAMESPACE_OPEN_SCOPE
22
97
99
100struct HdEmbree_UnknownLight
101{};
102struct HdEmbree_Cylinder
103{
104 float radius;
105 float length;
106};
107
108struct HdEmbree_Disk
109{
110 float radius;
111};
112
113// Needed for HdEmbree_LightVariant
114struct HdEmbree_Dome
115{};
116
117struct HdEmbree_Rect
118{
119 float width;
120 float height;
121};
122
123struct HdEmbree_Sphere
124{
125 float radius;
126};
127
128using HdEmbree_LightVariant = std::variant<
129 HdEmbree_UnknownLight,
130 HdEmbree_Cylinder,
131 HdEmbree_Disk,
132 HdEmbree_Dome,
133 HdEmbree_Rect,
134 HdEmbree_Sphere>;
135
136struct HdEmbree_LightTexture
137{
138 std::vector<GfVec3f> pixels;
139 int width = 0;
140 int height = 0;
141};
142
143struct HdEmbree_Shaping
144{
145 GfVec3f focusTint;
146 float focus = 0.0f;
147 float coneAngle = 180.0f;
148 float coneSoftness = 0.0f;
149};
150
151struct HdEmbree_LightData
152{
153 GfMatrix4f xformLightToWorld;
154 GfMatrix3f normalXformLightToWorld;
155 GfMatrix4f xformWorldToLight;
156 GfVec3f color;
157 HdEmbree_LightTexture texture;
158 float intensity = 1.0f;
159 float diffuse = 1.0f;
160 float exposure = 0.0f;
161 float colorTemperature = 6500.0f;
162 bool enableColorTemperature = false;
163 HdEmbree_LightVariant lightVariant;
164 bool normalize = false;
165 bool visible = true;
166 HdEmbree_Shaping shaping;
167};
168
169class HdEmbree_Light final : public HdLight
170{
171public:
172 HdEmbree_Light(SdfPath const& id, TfToken const& lightType);
173 ~HdEmbree_Light();
174
176 void Sync(HdSceneDelegate* sceneDelegate,
177 HdRenderParam* renderParam,
178 HdDirtyBits* dirtyBits) override;
179
183 HdDirtyBits GetInitialDirtyBitsMask() const override;
184
185 void Finalize(HdRenderParam *renderParam) override;
186
187 HdEmbree_LightData const& LightData() const {
188 return _lightData;
189 }
190
191 bool IsDome() const {
192 return std::holds_alternative<HdEmbree_Dome>(_lightData.lightVariant);
193 }
194
195private:
196 HdEmbree_LightData _lightData;
197};
198
199
200PXR_NAMESPACE_CLOSE_SCOPE
201
202#endif
Stores a 3x3 matrix of float elements.
Definition: matrix3f.h:65
Stores a 4x4 matrix of float elements.
Definition: matrix4f.h:71
Basic type for a vector of 3 float components.
Definition: vec3f.h:46
HdEmbreeRenderer implements a renderer on top of Embree's raycasting abilities.
Definition: renderer.h:53
A light model, used in conjunction with HdRenderPass.
Definition: light.h:67
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Adapter class providing data exchange with the client scene graph.
virtual HD_API void Finalize(HdRenderParam *renderParam)
Finalizes object resources.
virtual HdDirtyBits GetInitialDirtyBitsMask() const =0
Returns the minimal set of dirty bits to place in the change tracker for use in the first sync of thi...
virtual void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits)=0
Synchronizes state from the delegate to this object.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71