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 
38 
39 
40 class GlfSimpleLight final {
41 public:
42  GLF_API
43  GlfSimpleLight(GfVec4f const & position = GfVec4f(0.0, 0.0, 0.0, 1.0));
44  GLF_API
46 
47  GLF_API
48  GfMatrix4d const & GetTransform() const;
49  GLF_API
50  void SetTransform(GfMatrix4d const & mat);
51 
52  GLF_API
53  GfVec4f const & GetAmbient() const;
54  GLF_API
55  void SetAmbient(GfVec4f const & ambient);
56 
57  GLF_API
58  GfVec4f const & GetDiffuse() const;
59  GLF_API
60  void SetDiffuse(GfVec4f const & diffuse);
61 
62  GLF_API
63  GfVec4f const & GetSpecular() const;
64  GLF_API
65  void SetSpecular(GfVec4f const & specular);
66 
67  GLF_API
68  GfVec4f const & GetPosition() const;
69  GLF_API
70  void SetPosition(GfVec4f const & position);
71 
72  GLF_API
73  GfVec3f const & GetSpotDirection() const;
74  GLF_API
75  void SetSpotDirection(GfVec3f const & spotDirection);
76 
77  GLF_API
78  float const & GetSpotCutoff() const;
79  GLF_API
80  void SetSpotCutoff(float const & spotCutoff);
81 
82  GLF_API
83  float const & GetSpotFalloff() const;
84  GLF_API
85  void SetSpotFalloff(float const & spotFalloff);
86 
87  GLF_API
88  GfVec3f const & GetAttenuation() const;
89  GLF_API
90  void SetAttenuation(GfVec3f const & attenuation);
91 
92  GLF_API
93  std::vector<GfMatrix4d> const & GetShadowMatrices() const;
94  GLF_API
95  void SetShadowMatrices(std::vector<GfMatrix4d> const &matrix);
96 
97  GLF_API
98  int GetShadowResolution() const;
99  GLF_API
100  void SetShadowResolution(int resolution);
101 
102  GLF_API
103  float GetShadowBias() const;
104  GLF_API
105  void SetShadowBias(float bias);
106 
107  GLF_API
108  float GetShadowBlur() const;
109  GLF_API
110  void SetShadowBlur(float blur);
111 
112  GLF_API
113  int GetShadowIndexStart() const;
114  GLF_API
115  void SetShadowIndexStart(int shadowStart);
116 
117  GLF_API
118  int GetShadowIndexEnd() const;
119  GLF_API
120  void SetShadowIndexEnd(int shadowEnd);
121 
122  GLF_API
123  bool HasShadow() const;
124  GLF_API
125  void SetHasShadow(bool hasShadow);
126 
127  GLF_API
128  bool IsCameraSpaceLight() const;
129  GLF_API
130  void SetIsCameraSpaceLight(bool isCameraSpaceLight);
131 
132  GLF_API
133  SdfPath const & GetID() const;
134  GLF_API
135  void SetID(SdfPath const & id);
136 
137  GLF_API
138  bool IsDomeLight() const;
139  GLF_API
140  void SetIsDomeLight(bool isDomeLight);
141 
142  /// The path to the (unprocessed) environment map texture.
143  ///
144  /// All textures actually used by the dome light (irradiance, prefilter,
145  /// brdf) are derived from this texture in a pre-calculation step.
146  GLF_API
147  const SdfAssetPath &GetDomeLightTextureFile() const;
148  GLF_API
150 
151  GLF_API
152  bool operator ==(GlfSimpleLight const & other) const;
153  GLF_API
154  bool operator !=(GlfSimpleLight const & other) const;
155 
156 private:
157  GLF_API
158  friend std::ostream & operator <<(std::ostream &out,
159  const GlfSimpleLight& v);
160  GfVec4f _ambient;
161  GfVec4f _diffuse;
162  GfVec4f _specular;
163  GfVec4f _position;
164  GfVec3f _spotDirection;
165  float _spotCutoff;
166  float _spotFalloff;
167  GfVec3f _attenuation;
168  bool _isCameraSpaceLight;
169 
170  bool _hasShadow;
171  int _shadowResolution;
172  float _shadowBias;
173  float _shadowBlur;
174  int _shadowIndexStart;
175  int _shadowIndexEnd;
176 
177  GfMatrix4d _transform;
178  std::vector<GfMatrix4d> _shadowMatrices;
179 
180  // domeLight specific parameters
181  bool _isDomeLight;
182  // path to texture for dome light.
183  SdfAssetPath _domeLightTextureFile;
184 
185  SdfPath _id;
186 };
187 
188 // VtValue requirements
189 GLF_API
190 std::ostream& operator<<(std::ostream& out, const GlfSimpleLight& v);
191 
192 typedef std::vector<class GlfSimpleLight> GlfSimpleLightVector;
193 
194 // VtValue requirements
195 GLF_API
196 std::ostream& operator<<(std::ostream& out, const GlfSimpleLightVector& pv);
197 
198 
200 
201 #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 HasShadow() const
Definition: vec3f.h:63
GLF_API void SetSpecular(GfVec4f const &specular)
const GLdouble * v
Definition: glew.h:1391
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 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 ~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
GLF_API void SetShadowResolution(int resolution)
GLfloat bias
Definition: glew.h:10274
Definition: path.h:288
GLF_API GfVec4f const & GetAmbient() const
GLF_API bool operator!=(GlfSimpleLight const &other) const
GLF_API GfVec4f const & GetPosition() const
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:1346
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 void SetSpotDirection(GfVec3f const &spotDirection)
GLF_API void SetIsDomeLight(bool isDomeLight)
GLuint GLenum matrix
Definition: glew.h:14742
std::vector< class GlfSimpleLight > GlfSimpleLightVector
Definition: simpleLight.h:192