HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simpleLight.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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_GLF_SIMPLE_LIGHT_H
8 #define PXR_IMAGING_GLF_SIMPLE_LIGHT_H
9 
10 /// \file glf/simpleLight.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/imaging/glf/api.h"
14 #include "pxr/base/gf/matrix4d.h"
15 #include "pxr/base/gf/vec3f.h"
16 #include "pxr/base/gf/vec4f.h"
17 #include "pxr/usd/sdf/path.h"
18 #include "pxr/usd/sdf/assetPath.h"
19 
20 #include "pxr/base/tf/token.h"
21 #include "pxr/base/vt/array.h"
22 #include "pxr/base/vt/dictionary.h"
23 
24 #include <string>
25 
27 
28 
29 class GlfSimpleLight final {
30 public:
31  GLF_API
32  GlfSimpleLight(GfVec4f const & position = GfVec4f(0.0, 0.0, 0.0, 1.0));
33  GLF_API
35 
36  GLF_API
37  GfMatrix4d const & GetTransform() const;
38  GLF_API
39  void SetTransform(GfMatrix4d const & mat);
40 
41  /// The ambient light value is in the renderer's working color space
42  GLF_API
43  GfVec4f const & GetAmbient() const;
44  GLF_API
45  void SetAmbient(GfVec4f const & ambient);
46 
47  /// The diffuse light value is in the renderer's working color space
48  GLF_API
49  GfVec4f const & GetDiffuse() const;
50  GLF_API
51  void SetDiffuse(GfVec4f const & diffuse);
52 
53  /// The specular light value is in the renderer's working color space
54  GLF_API
55  GfVec4f const & GetSpecular() const;
56  GLF_API
57  void SetSpecular(GfVec4f const & specular);
58 
59  GLF_API
60  GfVec4f const & GetPosition() const;
61  GLF_API
62  void SetPosition(GfVec4f const & position);
63 
64  GLF_API
65  GfVec3f const & GetSpotDirection() const;
66  GLF_API
67  void SetSpotDirection(GfVec3f const & spotDirection);
68 
69  GLF_API
70  float const & GetSpotCutoff() const;
71  GLF_API
72  void SetSpotCutoff(float const & spotCutoff);
73 
74  GLF_API
75  float const & GetSpotFalloff() const;
76  GLF_API
77  void SetSpotFalloff(float const & spotFalloff);
78 
79  GLF_API
80  GfVec3f const & GetAttenuation() const;
81  GLF_API
82  void SetAttenuation(GfVec3f const & attenuation);
83 
84  GLF_API
85  std::vector<GfMatrix4d> const & GetShadowMatrices() const;
86  GLF_API
87  void SetShadowMatrices(std::vector<GfMatrix4d> const &matrix);
88 
89  GLF_API
90  int GetShadowResolution() const;
91  GLF_API
93 
94  GLF_API
95  float GetShadowBias() const;
96  GLF_API
97  void SetShadowBias(float bias);
98 
99  GLF_API
100  float GetShadowBlur() const;
101  GLF_API
102  void SetShadowBlur(float blur);
103 
104  GLF_API
105  int GetShadowIndexStart() const;
106  GLF_API
107  void SetShadowIndexStart(int shadowStart);
108 
109  GLF_API
110  int GetShadowIndexEnd() const;
111  GLF_API
112  void SetShadowIndexEnd(int shadowEnd);
113 
114  GLF_API
115  bool HasShadow() const;
116  GLF_API
117  void SetHasShadow(bool hasShadow);
118 
119  GLF_API
120  bool HasIntensity() const;
121  GLF_API
122  void SetHasIntensity(bool hasIntensity);
123 
124  GLF_API
125  bool IsCameraSpaceLight() const;
126  GLF_API
127 
128  void SetIsCameraSpaceLight(bool isCameraSpaceLight);
129  GLF_API
130  SdfPath const & GetID() const;
131  GLF_API
132  void SetID(SdfPath const & id);
133 
134  GLF_API
135  bool IsDomeLight() const;
136  GLF_API
137  void SetIsDomeLight(bool isDomeLight);
138 
139  /// The path to the (unprocessed) environment map texture.
140  ///
141  /// All textures actually used by the dome light (irradiance, prefilter,
142  /// brdf) are derived from this texture in a pre-calculation step.
143  GLF_API
144  const SdfAssetPath &GetDomeLightTextureFile() const;
145  GLF_API
147 
148 
149  /// \name Post Surface Lighting
150  ///
151  /// Post surface lighting is evaluated after other surface illumination
152  /// and can be used to implement lighting effects beyond those that
153  /// correspond to basic positional lighting, e.g. range base fog, etc.
154  ///
155  /// @{
156 
157  GLF_API
158  TfToken const & GetPostSurfaceIdentifier() const;
159  GLF_API
160  std::string const & GetPostSurfaceShaderSource() const;
161  GLF_API
162  VtUCharArray const & GetPostSurfaceShaderParams() const;
163 
164  GLF_API
165  void SetPostSurfaceParams(TfToken const & identifier,
166  std::string const & shaderSource,
167  VtUCharArray const & shaderParams);
168 
169  /// @}
170 
171  /// \name Extending this class for Houdini's viewport
172  ///
173  /// Provide some additional Houdini viewport-specific controls. These
174  /// do nothing unless they are enabled (in other words these additional
175  /// parameters have no effect on apps like usdview that know nothing
176  /// about them).
177  ///
178  /// @{
179 
180  GLF_API
181  bool HasExtendedAttributes() const;
182  GLF_API
183  void SetHasExtendedAttributes(bool hasExtendedAttributes);
184 
185  GLF_API
186  float GetExtendedIntensity() const;
187  GLF_API
188  void SetExtendedIntensity(float intensity);
189 
190  GLF_API
191  float GetExtendedAngle() const;
192  GLF_API
193  void SetExtendedAngle(float angle);
194 
195  GLF_API
196  GfVec3f const & GetExtendedColor() const;
197  GLF_API
198  void SetExtendedColor(GfVec3f const & color);
199 
200  /// @}
201 
202  GLF_API
203  bool operator ==(GlfSimpleLight const &other) const;
204  GLF_API
205  bool operator !=(GlfSimpleLight const &other) const;
206 
207 private:
208  GLF_API
209  friend std::ostream & operator <<(std::ostream &out,
210  const GlfSimpleLight& v);
211  GfVec4f _ambient;
212  GfVec4f _diffuse;
213  GfVec4f _specular;
214  GfVec4f _position;
215  GfVec3f _spotDirection;
216  float _spotCutoff;
217  float _spotFalloff;
218  GfVec3f _attenuation;
219  bool _isCameraSpaceLight;
220  bool _hasIntensity;
221 
222  bool _hasShadow;
223  int _shadowResolution;
224  float _shadowBias;
225  float _shadowBlur;
226  int _shadowIndexStart;
227  int _shadowIndexEnd;
228 
229  GfMatrix4d _transform;
230  std::vector<GfMatrix4d> _shadowMatrices;
231 
232  // domeLight specific parameters
233  bool _isDomeLight;
234  // path to texture for dome light.
235  SdfAssetPath _domeLightTextureFile;
236 
237  TfToken _postSurfaceIdentifier;
238  std::string _postSurfaceShaderSource;
239  VtUCharArray _postSurfaceShaderParams;
240 
241  SdfPath _id;
242 
243  // Houdini viewport-specific attributes
244  bool _hasExtendedAttributes;
245  float _extendedIntensity;
246  float _extendedAngle;
247  GfVec3f _extendedColor;
248 };
249 
250 // VtValue requirements
251 GLF_API
252 std::ostream& operator<<(std::ostream& out, const GlfSimpleLight& v);
253 
254 typedef std::vector<class GlfSimpleLight> GlfSimpleLightVector;
255 
256 // VtValue requirements
257 GLF_API
258 std::ostream& operator<<(std::ostream& out, const GlfSimpleLightVector& pv);
259 
260 
262 
263 #endif
GLF_API void SetAmbient(GfVec4f const &ambient)
GLF_API void SetShadowBlur(float blur)
GLF_API int GetShadowIndexStart() const
GLF_API bool IsDomeLight() const
GLF_API GfVec3f const & GetAttenuation() const
GLF_API void SetExtendedAngle(float angle)
GLF_API void SetSpotCutoff(float const &spotCutoff)
GLF_API void SetPosition(GfVec4f const &position)
GLF_API void SetShadowBias(float bias)
#define GLF_API
Definition: api.h:23
GLF_API int GetShadowIndexEnd() const
SIM_API const UT_StringHolder angle
GLF_API void SetShadowIndexStart(int shadowStart)
const GLdouble * v
Definition: glcorearb.h:837
GLF_API void SetShadowMatrices(std::vector< GfMatrix4d > const &matrix)
GLF_API bool HasIntensity() const
GLF_API bool HasShadow() const
Definition: vec3f.h:45
GLF_API bool HasExtendedAttributes() const
GLF_API void SetSpecular(GfVec4f const &specular)
GLF_API float GetExtendedAngle() const
GLF_API VtUCharArray const & GetPostSurfaceShaderParams() const
GLF_API void SetExtendedColor(GfVec3f const &color)
GLF_API void SetTransform(GfMatrix4d const &mat)
GLF_API GfMatrix4d const & GetTransform() const
GLF_API void SetAttenuation(GfVec3f const &attenuation)
GLF_API float GetShadowBlur() const
GLF_API void SetHasIntensity(bool hasIntensity)
Definition: token.h:70
GLF_API bool operator==(GlfSimpleLight const &other) const
GLF_API std::vector< GfMatrix4d > const & GetShadowMatrices() const
GLF_API void SetHasShadow(bool hasShadow)
GLF_API float GetShadowBias() const
GLF_API void SetDiffuse(GfVec4f const &diffuse)
GLF_API void SetHasExtendedAttributes(bool hasExtendedAttributes)
GLF_API ~GlfSimpleLight()
GLF_API std::ostream & operator<<(std::ostream &out, const GlfSimpleLight &v)
GLF_API friend std::ostream & operator<<(std::ostream &out, const GlfSimpleLight &v)
GLF_API float GetExtendedIntensity() const
GLF_API GfVec3f const & GetSpotDirection() const
GLF_API GfVec4f const & GetDiffuse() const
The diffuse light value is in the renderer's working color space.
GLF_API GfVec4f const & GetSpecular() const
The specular light value is in the renderer's working color space.
HUSD_API const char * resolution()
GLF_API void SetShadowResolution(int resolution)
Definition: path.h:273
GLF_API GfVec4f const & GetAmbient() const
The ambient light value is in the renderer's working color space.
GLF_API bool operator!=(GlfSimpleLight const &other) const
GLF_API GfVec4f const & GetPosition() const
GLF_API void SetPostSurfaceParams(TfToken const &identifier, std::string const &shaderSource, VtUCharArray const &shaderParams)
GLF_API void SetID(SdfPath const &id)
GLF_API void SetSpotFalloff(float const &spotFalloff)
Definition: vec4f.h:45
GLF_API SdfPath const & GetID() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
GLuint color
Definition: glcorearb.h:1261
GLF_API void SetShadowIndexEnd(int shadowEnd)
GLF_API const SdfAssetPath & GetDomeLightTextureFile() const
GLF_API GlfSimpleLight(GfVec4f const &position=GfVec4f(0.0, 0.0, 0.0, 1.0))
GLF_API bool IsCameraSpaceLight() const
SIM_API const UT_StringHolder position
GLF_API void SetDomeLightTextureFile(const SdfAssetPath &)
GLF_API int GetShadowResolution() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
GLF_API float const & GetSpotFalloff() const
GLF_API float const & GetSpotCutoff() const
GLF_API void SetIsCameraSpaceLight(bool isCameraSpaceLight)
GLF_API std::string const & GetPostSurfaceShaderSource() const
GLF_API void SetSpotDirection(GfVec3f const &spotDirection)
GLF_API void SetExtendedIntensity(float intensity)
GLF_API TfToken const & GetPostSurfaceIdentifier() const
GLF_API void SetIsDomeLight(bool isDomeLight)
GLF_API GfVec3f const & GetExtendedColor() const
std::vector< class GlfSimpleLight > GlfSimpleLightVector
Definition: simpleLight.h:254