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 
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 
43 PXR_NAMESPACE_OPEN_SCOPE
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
51  ~GlfSimpleLight();
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
106  void SetShadowResolution(int resolution);
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 
157  GLF_API
158  const SdfAssetPath &GetDomeLightTextureFile() const;
159  GLF_API
160  void SetDomeLightTextureFile(const SdfAssetPath &);
161 
162 
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 
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 
238 PXR_NAMESPACE_CLOSE_SCOPE
239 
240 #endif
Basic type for a vector of 3 float components.
Definition: vec3f.h:63
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...