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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_GLF_SIMPLE_LIGHT_H
25 #define PXR_IMAGING_GLF_SIMPLE_LIGHT_H
26 
27 /// \file glf/simpleLight.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/glf/api.h"
31 #include "pxr/base/gf/matrix4d.h"
32 #include "pxr/base/gf/vec3f.h"
33 #include "pxr/base/gf/vec4f.h"
34 #include "pxr/usd/sdf/path.h"
35 #include "pxr/usd/sdf/assetPath.h"
36 
37 #include "pxr/base/tf/token.h"
38 #include "pxr/base/vt/array.h"
39 #include "pxr/base/vt/dictionary.h"
40 
41 #include <string>
42 
44 
45 
46 class GlfSimpleLight final {
47 public:
48  GLF_API
49  GlfSimpleLight(GfVec4f const & position = GfVec4f(0.0, 0.0, 0.0, 1.0));
50  GLF_API
52 
53  GLF_API
54  GfMatrix4d const & GetTransform() const;
55  GLF_API
56  void SetTransform(GfMatrix4d const & mat);
57 
58  GLF_API
59  GfVec4f const & GetAmbient() const;
60  GLF_API
61  void SetAmbient(GfVec4f const & ambient);
62 
63  GLF_API
64  GfVec4f const & GetDiffuse() const;
65  GLF_API
66  void SetDiffuse(GfVec4f const & diffuse);
67 
68  GLF_API
69  GfVec4f const & GetSpecular() const;
70  GLF_API
71  void SetSpecular(GfVec4f const & specular);
72 
73  GLF_API
74  GfVec4f const & GetPosition() const;
75  GLF_API
76  void SetPosition(GfVec4f const & position);
77 
78  GLF_API
79  GfVec3f const & GetSpotDirection() const;
80  GLF_API
81  void SetSpotDirection(GfVec3f const & spotDirection);
82 
83  GLF_API
84  float const & GetSpotCutoff() const;
85  GLF_API
86  void SetSpotCutoff(float const & spotCutoff);
87 
88  GLF_API
89  float const & GetSpotFalloff() const;
90  GLF_API
91  void SetSpotFalloff(float const & spotFalloff);
92 
93  GLF_API
94  GfVec3f const & GetAttenuation() const;
95  GLF_API
96  void SetAttenuation(GfVec3f const & attenuation);
97 
98  GLF_API
99  std::vector<GfMatrix4d> const & GetShadowMatrices() const;
100  GLF_API
101  void SetShadowMatrices(std::vector<GfMatrix4d> const &matrix);
102 
103  GLF_API
104  int GetShadowResolution() const;
105  GLF_API
107 
108  GLF_API
109  float GetShadowBias() const;
110  GLF_API
111  void SetShadowBias(float bias);
112 
113  GLF_API
114  float GetShadowBlur() const;
115  GLF_API
116  void SetShadowBlur(float blur);
117 
118  GLF_API
119  int GetShadowIndexStart() const;
120  GLF_API
121  void SetShadowIndexStart(int shadowStart);
122 
123  GLF_API
124  int GetShadowIndexEnd() const;
125  GLF_API
126  void SetShadowIndexEnd(int shadowEnd);
127 
128  GLF_API
129  bool HasShadow() const;
130  GLF_API
131  void SetHasShadow(bool hasShadow);
132 
133  GLF_API
134  bool HasIntensity() const;
135  GLF_API
136  void SetHasIntensity(bool hasIntensity);
137 
138  GLF_API
139  bool IsCameraSpaceLight() const;
140  GLF_API
141 
142  void SetIsCameraSpaceLight(bool isCameraSpaceLight);
143  GLF_API
144  SdfPath const & GetID() const;
145  GLF_API
146  void SetID(SdfPath const & id);
147 
148  GLF_API
149  bool IsDomeLight() const;
150  GLF_API
151  void SetIsDomeLight(bool isDomeLight);
152 
153  /// The path to the (unprocessed) environment map texture.
154  ///
155  /// All textures actually used by the dome light (irradiance, prefilter,
156  /// brdf) are derived from this texture in a pre-calculation step.
157  GLF_API
158  const SdfAssetPath &GetDomeLightTextureFile() const;
159  GLF_API
161 
162 
163  /// \name Post Surface Lighting
164  ///
165  /// Post surface lighting is evaluated after other surface illumination
166  /// and can be used to implement lighting effects beyond those that
167  /// correspond to basic positional lighting, e.g. range base fog, etc.
168  ///
169  /// @{
170 
171  GLF_API
172  TfToken const & GetPostSurfaceIdentifier() const;
173  GLF_API
174  std::string const & GetPostSurfaceShaderSource() const;
175  GLF_API
176  VtUCharArray const & GetPostSurfaceShaderParams() const;
177 
178  GLF_API
179  void SetPostSurfaceParams(TfToken const & identifier,
180  std::string const & shaderSource,
181  VtUCharArray const & shaderParams);
182 
183  /// @}
184 
185  /// \name Extending this class for Houdini's viewport
186  ///
187  /// Provide some additional Houdini viewport-specific controls. These
188  /// do nothing unless they are enabled (in other words these additional
189  /// parameters have no effect on apps like usdview that know nothing
190  /// about them).
191  ///
192  /// @{
193 
194  GLF_API
195  bool HasExtendedAttributes() const;
196  GLF_API
197  void SetHasExtendedAttributes(bool hasExtendedAttributes);
198 
199  GLF_API
200  float GetExtendedIntensity() const;
201  GLF_API
202  void SetExtendedIntensity(float intensity);
203 
204  GLF_API
205  float GetExtendedAngle() const;
206  GLF_API
207  void SetExtendedAngle(float angle);
208 
209  GLF_API
210  GfVec3f const & GetExtendedColor() const;
211  GLF_API
212  void SetExtendedColor(GfVec3f const & color);
213 
214  /// @}
215 
216  GLF_API
217  bool operator ==(GlfSimpleLight const &other) const;
218  GLF_API
219  bool operator !=(GlfSimpleLight const &other) const;
220 
221 private:
222  GLF_API
223  friend std::ostream & operator <<(std::ostream &out,
224  const GlfSimpleLight& v);
225  GfVec4f _ambient;
226  GfVec4f _diffuse;
227  GfVec4f _specular;
228  GfVec4f _position;
229  GfVec3f _spotDirection;
230  float _spotCutoff;
231  float _spotFalloff;
232  GfVec3f _attenuation;
233  bool _isCameraSpaceLight;
234  bool _hasIntensity;
235 
236  bool _hasShadow;
237  int _shadowResolution;
238  float _shadowBias;
239  float _shadowBlur;
240  int _shadowIndexStart;
241  int _shadowIndexEnd;
242 
243  GfMatrix4d _transform;
244  std::vector<GfMatrix4d> _shadowMatrices;
245 
246  // domeLight specific parameters
247  bool _isDomeLight;
248  // path to texture for dome light.
249  SdfAssetPath _domeLightTextureFile;
250 
251  TfToken _postSurfaceIdentifier;
252  std::string _postSurfaceShaderSource;
253  VtUCharArray _postSurfaceShaderParams;
254 
255  SdfPath _id;
256 
257  // Houdini viewport-specific attributes
258  bool _hasExtendedAttributes;
259  float _extendedIntensity;
260  float _extendedAngle;
261  GfVec3f _extendedColor;
262 };
263 
264 // VtValue requirements
265 GLF_API
266 std::ostream& operator<<(std::ostream& out, const GlfSimpleLight& v);
267 
268 typedef std::vector<class GlfSimpleLight> GlfSimpleLightVector;
269 
270 // VtValue requirements
271 GLF_API
272 std::ostream& operator<<(std::ostream& out, const GlfSimpleLightVector& pv);
273 
274 
276 
277 #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:40
GLF_API int GetShadowIndexEnd() const
SIM_API const UT_StringHolder angle
GLF_API void SetShadowIndexStart(int shadowStart)
const GLdouble * v
Definition: glcorearb.h:837
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLF_API void SetShadowMatrices(std::vector< GfMatrix4d > const &matrix)
GLF_API bool HasIntensity() const
GLF_API bool HasShadow() const
Definition: vec3f.h:62
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:87
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
GLF_API GfVec4f const & GetSpecular() const
HUSD_API const char * resolution()
GLF_API void SetShadowResolution(int resolution)
Definition: path.h:290
GLF_API GfVec4f const & GetAmbient() const
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:62
GLF_API SdfPath const & GetID() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
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:91
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:268