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  GLF_API
186  bool operator ==(GlfSimpleLight const &other) const;
187  GLF_API
188  bool operator !=(GlfSimpleLight const &other) const;
189 
190 private:
191  GLF_API
192  friend std::ostream & operator <<(std::ostream &out,
193  const GlfSimpleLight& v);
194  GfVec4f _ambient;
195  GfVec4f _diffuse;
196  GfVec4f _specular;
197  GfVec4f _position;
198  GfVec3f _spotDirection;
199  float _spotCutoff;
200  float _spotFalloff;
201  GfVec3f _attenuation;
202  bool _isCameraSpaceLight;
203  bool _hasIntensity;
204 
205  bool _hasShadow;
206  int _shadowResolution;
207  float _shadowBias;
208  float _shadowBlur;
209  int _shadowIndexStart;
210  int _shadowIndexEnd;
211 
212  GfMatrix4d _transform;
213  std::vector<GfMatrix4d> _shadowMatrices;
214 
215  // domeLight specific parameters
216  bool _isDomeLight;
217  // path to texture for dome light.
218  SdfAssetPath _domeLightTextureFile;
219 
220  TfToken _postSurfaceIdentifier;
221  std::string _postSurfaceShaderSource;
222  VtUCharArray _postSurfaceShaderParams;
223 
224  SdfPath _id;
225 };
226 
227 // VtValue requirements
228 GLF_API
229 std::ostream& operator<<(std::ostream& out, const GlfSimpleLight& v);
230 
231 typedef std::vector<class GlfSimpleLight> GlfSimpleLightVector;
232 
233 // VtValue requirements
234 GLF_API
235 std::ostream& operator<<(std::ostream& out, const GlfSimpleLightVector& pv);
236 
237 
239 
240 #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 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
GLF_API void SetShadowIndexStart(int shadowStart)
GLF_API void SetShadowMatrices(std::vector< GfMatrix4d > const &matrix)
GLF_API bool HasIntensity() const
GLF_API bool HasShadow() const
Definition: vec3f.h:63
GLF_API void SetSpecular(GfVec4f const &specular)
GLF_API VtUCharArray const & GetPostSurfaceShaderParams() const
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
GLfloat bias
Definition: glew.h:10316
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)
const GLdouble * v
Definition: glcorearb.h:836
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
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 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:288
GLF_API GfVec4f const & GetAmbient() const
GLF_API bool operator!=(GlfSimpleLight const &other) const
GLF_API GfVec4f const & GetPosition() const
GLuint GLenum matrix
Definition: glew.h:15055
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:63
GLF_API SdfPath const & GetID() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
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
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 TfToken const & GetPostSurfaceIdentifier() const
GLF_API void SetIsDomeLight(bool isDomeLight)
std::vector< class GlfSimpleLight > GlfSimpleLightVector
Definition: simpleLight.h:231