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 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 
39 class GlfSimpleLight final {
40 public:
41  GLF_API
42  GlfSimpleLight(GfVec4f const & position = GfVec4f(0.0, 0.0, 0.0, 1.0));
43  GLF_API
44  ~GlfSimpleLight();
45 
46  GLF_API
47  GfMatrix4d const & GetTransform() const;
48  GLF_API
49  void SetTransform(GfMatrix4d const & mat);
50 
51  GLF_API
52  GfVec4f const & GetAmbient() const;
53  GLF_API
54  void SetAmbient(GfVec4f const & ambient);
55 
56  GLF_API
57  GfVec4f const & GetDiffuse() const;
58  GLF_API
59  void SetDiffuse(GfVec4f const & diffuse);
60 
61  GLF_API
62  GfVec4f const & GetSpecular() const;
63  GLF_API
64  void SetSpecular(GfVec4f const & specular);
65 
66  GLF_API
67  GfVec4f const & GetPosition() const;
68  GLF_API
69  void SetPosition(GfVec4f const & position);
70 
71  GLF_API
72  GfVec3f const & GetSpotDirection() const;
73  GLF_API
74  void SetSpotDirection(GfVec3f const & spotDirection);
75 
76  GLF_API
77  float const & GetSpotCutoff() const;
78  GLF_API
79  void SetSpotCutoff(float const & spotCutoff);
80 
81  GLF_API
82  float const & GetSpotFalloff() const;
83  GLF_API
84  void SetSpotFalloff(float const & spotFalloff);
85 
86  GLF_API
87  GfVec3f const & GetAttenuation() const;
88  GLF_API
89  void SetAttenuation(GfVec3f const & attenuation);
90 
91  GLF_API
92  std::vector<GfMatrix4d> const & GetShadowMatrices() const;
93  GLF_API
94  void SetShadowMatrices(std::vector<GfMatrix4d> const &matrix);
95 
96  GLF_API
97  int GetShadowResolution() const;
98  GLF_API
99  void SetShadowResolution(int resolution);
100 
101  GLF_API
102  float GetShadowBias() const;
103  GLF_API
104  void SetShadowBias(float bias);
105 
106  GLF_API
107  float GetShadowBlur() const;
108  GLF_API
109  void SetShadowBlur(float blur);
110 
111  GLF_API
112  int GetShadowIndexStart() const;
113  GLF_API
114  void SetShadowIndexStart(int shadowStart);
115 
116  GLF_API
117  int GetShadowIndexEnd() const;
118  GLF_API
119  void SetShadowIndexEnd(int shadowEnd);
120 
121  GLF_API
122  bool HasShadow() const;
123  GLF_API
124  void SetHasShadow(bool hasShadow);
125 
126  GLF_API
127  bool IsCameraSpaceLight() const;
128  GLF_API
129  void SetIsCameraSpaceLight(bool isCameraSpaceLight);
130 
131  GLF_API
132  SdfPath const & GetID() const;
133  GLF_API
134  void SetID(SdfPath const & id);
135 
136  GLF_API
137  bool IsDomeLight() const;
138  GLF_API
139  void SetIsDomeLight(bool isDomeLight);
140 
141  // the following Id's are GL resource handles for the precomputed textures
142  // created by HdStLight
143  GLF_API
144  uint32_t const & GetIrradianceId() const;
145  GLF_API
146  void SetIrradianceId(uint32_t const & irradianceId);
147 
148  GLF_API
149  uint32_t const & GetPrefilterId() const;
150  GLF_API
151  void SetPrefilterId(uint32_t const & prefilterId);
152 
153  GLF_API
154  uint32_t const & GetBrdfId() const;
155  GLF_API
156  void SetBrdfId(uint32_t const & brdfId);
157 
158  GLF_API
159  bool operator ==(GlfSimpleLight const & other) const;
160  GLF_API
161  bool operator !=(GlfSimpleLight const & other) const;
162 
163 private:
164  GLF_API
165  friend std::ostream & operator <<(std::ostream &out,
166  const GlfSimpleLight& v);
167  GfVec4f _ambient;
168  GfVec4f _diffuse;
169  GfVec4f _specular;
170  GfVec4f _position;
171  GfVec3f _spotDirection;
172  float _spotCutoff;
173  float _spotFalloff;
174  GfVec3f _attenuation;
175  bool _isCameraSpaceLight;
176 
177  bool _hasShadow;
178  int _shadowResolution;
179  float _shadowBias;
180  float _shadowBlur;
181  int _shadowIndexStart;
182  int _shadowIndexEnd;
183 
184  GfMatrix4d _transform;
185  std::vector<GfMatrix4d> _shadowMatrices;
186 
187  // domeLight specific parameters
188  bool _isDomeLight;
189  // handles for the resource bindings from HdStSimpleLightingShader
190  uint32_t _irradianceId; // pre-computed irradiance map
191  uint32_t _prefilterId; // pre-computed preFiltered map
192  uint32_t _brdfId; // pre-computed BRDF look up texture
193 
194  SdfPath _id;
195 };
196 
197 // VtValue requirements
198 GLF_API
199 std::ostream& operator<<(std::ostream& out, const GlfSimpleLight& v);
200 
201 typedef std::vector<class GlfSimpleLight> GlfSimpleLightVector;
202 
203 // VtValue requirements
204 GLF_API
205 std::ostream& operator<<(std::ostream& out, const GlfSimpleLightVector& pv);
206 
207 
208 PXR_NAMESPACE_CLOSE_SCOPE
209 
210 #endif
Basic type for a vector of 3 float components.
Definition: vec3f.h:63
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].
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.