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 GLF_SIMPLE_LIGHT_H
25 #define 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  GfMatrix4d const & GetShadowMatrix() const;
93  GLF_API
94  void SetShadowMatrix(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 GetShadowIndex() const;
113  GLF_API
114  void SetShadowIndex(int shadowIndex);
115 
116  GLF_API
117  bool HasShadow() const;
118  GLF_API
119  void SetHasShadow(bool hasShadow);
120 
121  GLF_API
122  bool IsCameraSpaceLight() const;
123  GLF_API
124  void SetIsCameraSpaceLight(bool isCameraSpaceLight);
125 
126  GLF_API
127  SdfPath const & GetID() const;
128  GLF_API
129  void SetID(SdfPath const & id);
130 
131  GLF_API
132  bool IsDomeLight() const;
133  GLF_API
134  void SetIsDomeLight(bool isDomeLight);
135 
136  // the following Id's are GL resource handles for the precomputed textures
137  // created by HdStLight
138  GLF_API
139  uint32_t const & GetIrradianceId() const;
140  GLF_API
141  void SetIrradianceId(uint32_t const & irradianceId);
142 
143  GLF_API
144  uint32_t const & GetPrefilterId() const;
145  GLF_API
146  void SetPrefilterId(uint32_t const & prefilterId);
147 
148  GLF_API
149  uint32_t const & GetBrdfId() const;
150  GLF_API
151  void SetBrdfId(uint32_t const & brdfId);
152 
153  GLF_API
154  bool operator ==(GlfSimpleLight const & other) const;
155  GLF_API
156  bool operator !=(GlfSimpleLight const & other) const;
157 
158 private:
159  GLF_API
160  friend std::ostream & operator <<(std::ostream &out,
161  const GlfSimpleLight& v);
162  GfVec4f _ambient;
163  GfVec4f _diffuse;
164  GfVec4f _specular;
165  GfVec4f _position;
166  GfVec3f _spotDirection;
167  float _spotCutoff;
168  float _spotFalloff;
169  GfVec3f _attenuation;
170  bool _isCameraSpaceLight;
171 
172  bool _hasShadow;
173  int _shadowResolution;
174  float _shadowBias;
175  float _shadowBlur;
176  int _shadowIndex;
177 
178  GfMatrix4d _transform;
179  GfMatrix4d _shadowMatrix;
180 
181  // domeLight specific parameters
182  bool _isDomeLight;
183  // handles for the resource bindings from HdXSimpleLightingShader
184  uint32_t _irradianceId; // pre-computed irradiance map
185  uint32_t _prefilterId; // pre-computed preFiltered map
186  uint32_t _brdfId; // pre-computed BRDF look up texture
187 
188  SdfPath _id;
189 };
190 
191 // VtValue requirements
192 GLF_API
193 std::ostream& operator<<(std::ostream& out, const GlfSimpleLight& v);
194 
195 typedef std::vector<class GlfSimpleLight> GlfSimpleLightVector;
196 
197 // VtValue requirements
198 GLF_API
199 std::ostream& operator<<(std::ostream& out, const GlfSimpleLightVector& pv);
200 
201 
202 PXR_NAMESPACE_CLOSE_SCOPE
203 
204 #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:287
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.