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#include "pxr/imaging/plugin/hdEmbree/pxrIES/pxrIES.h"
15
16#include <embree4/rtcore_common.h>
17#include <embree4/rtcore_geometry.h>
18
19#include <limits>
20#include <variant>
21
22PXR_NAMESPACE_OPEN_SCOPE
23
98
103
104class HdEmbreeRenderer;
105
106struct HdEmbree_UnknownLight
107{};
108struct HdEmbree_Cylinder
109{
110 float radius;
111 float length;
112};
113
114struct HdEmbree_Disk
115{
116 float radius;
117};
118
119struct HdEmbree_Distant
120{
121 float halfAngleRadians;
122};
123
124// Needed for HdEmbree_LightVariant
125struct HdEmbree_Dome
126{};
127
128struct HdEmbree_Rect
129{
130 float width;
131 float height;
132};
133
134struct HdEmbree_Sphere
135{
136 float radius;
137};
138
139using HdEmbree_LightVariant = std::variant<
140 HdEmbree_UnknownLight,
141 HdEmbree_Cylinder,
142 HdEmbree_Disk,
143 HdEmbree_Distant,
144 HdEmbree_Dome,
145 HdEmbree_Rect,
146 HdEmbree_Sphere>;
147
148struct HdEmbree_LightTexture
149{
150 std::vector<GfVec3f> pixels;
151 int width = 0;
152 int height = 0;
153};
154
155struct HdEmbree_IES
156{
157 PxrIESFile iesFile;
158 bool normalize = false;
159 float angleScale = 0.0f;
160};
161
162struct HdEmbree_Shaping
163{
164 GfVec3f focusTint;
165 float focus = 0.0f;
166 float coneAngle = 180.0f;
167 float coneSoftness = 0.0f;
168 HdEmbree_IES ies;
169};
170
171struct HdEmbree_LightData
172{
173 GfMatrix4f xformLightToWorld;
174 GfMatrix3f normalXformLightToWorld;
175 GfMatrix4f xformWorldToLight;
176 GfVec3f color;
177 HdEmbree_LightTexture texture;
178 float intensity = 1.0f;
179 float diffuse = 1.0f;
180 float exposure = 0.0f;
181 float colorTemperature = 6500.0f;
182 bool enableColorTemperature = false;
183 HdEmbree_LightVariant lightVariant;
184 bool normalize = false;
185 bool visible = true;
186 HdEmbree_Shaping shaping;
187};
188
189class HdEmbree_Light final : public HdLight
190{
191public:
192 HdEmbree_Light(SdfPath const& id, TfToken const& lightType);
193 ~HdEmbree_Light();
194
196 void Sync(HdSceneDelegate* sceneDelegate,
197 HdRenderParam* renderParam,
198 HdDirtyBits* dirtyBits) override;
199
203 HdDirtyBits GetInitialDirtyBitsMask() const override;
204
205 void Finalize(HdRenderParam *renderParam) override;
206
207 HdEmbree_LightData const& LightData() const {
208 return _lightData;
209 }
210
211 bool IsDome() const {
212 return std::holds_alternative<HdEmbree_Dome>(_lightData.lightVariant);
213 }
214
215private:
216 HdEmbree_LightData _lightData;
217};
218
219
220PXR_NAMESPACE_CLOSE_SCOPE
221
222#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.
Extends / overrides some functionality of standard IESFile.
Definition: pxrIES.h:21
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:281
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71