Loading...
Searching...
No Matches
simpleLight.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_GLF_SIMPLE_LIGHT_H
8#define PXR_IMAGING_GLF_SIMPLE_LIGHT_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/imaging/glf/api.h"
15#include "pxr/base/gf/vec3f.h"
16#include "pxr/base/gf/vec4f.h"
17#include "pxr/usd/sdf/path.h"
19
20#include "pxr/base/tf/token.h"
21#include "pxr/base/vt/array.h"
23
24#include <string>
25
26PXR_NAMESPACE_OPEN_SCOPE
27
28
29class GlfSimpleLight final {
30public:
31 GLF_API
32 GlfSimpleLight(GfVec4f const & position = GfVec4f(0.0, 0.0, 0.0, 1.0));
33 GLF_API
34 ~GlfSimpleLight();
35
36 GLF_API
37 GfMatrix4d const & GetTransform() const;
38 GLF_API
39 void SetTransform(GfMatrix4d const & mat);
40
42 GLF_API
43 GfVec4f const & GetAmbient() const;
44 GLF_API
45 void SetAmbient(GfVec4f const & ambient);
46
48 GLF_API
49 GfVec4f const & GetDiffuse() const;
50 GLF_API
51 void SetDiffuse(GfVec4f const & diffuse);
52
54 GLF_API
55 GfVec4f const & GetSpecular() const;
56 GLF_API
57 void SetSpecular(GfVec4f const & specular);
58
59 GLF_API
60 GfVec4f const & GetPosition() const;
61 GLF_API
62 void SetPosition(GfVec4f const & position);
63
64 GLF_API
65 GfVec3f const & GetSpotDirection() const;
66 GLF_API
67 void SetSpotDirection(GfVec3f const & spotDirection);
68
69 GLF_API
70 float const & GetSpotCutoff() const;
71 GLF_API
72 void SetSpotCutoff(float const & spotCutoff);
73
74 GLF_API
75 float const & GetSpotFalloff() const;
76 GLF_API
77 void SetSpotFalloff(float const & spotFalloff);
78
79 GLF_API
80 GfVec3f const & GetAttenuation() const;
81 GLF_API
82 void SetAttenuation(GfVec3f const & attenuation);
83
84 GLF_API
85 std::vector<GfMatrix4d> const & GetShadowMatrices() const;
86 GLF_API
87 void SetShadowMatrices(std::vector<GfMatrix4d> const &matrix);
88
89 GLF_API
90 int GetShadowResolution() const;
91 GLF_API
92 void SetShadowResolution(int resolution);
93
94 GLF_API
95 float GetShadowBias() const;
96 GLF_API
97 void SetShadowBias(float bias);
98
99 GLF_API
100 float GetShadowBlur() const;
101 GLF_API
102 void SetShadowBlur(float blur);
103
104 GLF_API
105 int GetShadowIndexStart() const;
106 GLF_API
107 void SetShadowIndexStart(int shadowStart);
108
109 GLF_API
110 int GetShadowIndexEnd() const;
111 GLF_API
112 void SetShadowIndexEnd(int shadowEnd);
113
114 GLF_API
115 bool HasShadow() const;
116 GLF_API
117 void SetHasShadow(bool hasShadow);
118
119 GLF_API
120 bool HasIntensity() const;
121 GLF_API
122 void SetHasIntensity(bool hasIntensity);
123
124 GLF_API
125 bool IsCameraSpaceLight() const;
126 GLF_API
127
128 void SetIsCameraSpaceLight(bool isCameraSpaceLight);
129 GLF_API
130 SdfPath const & GetID() const;
131 GLF_API
132 void SetID(SdfPath const & id);
133
134 GLF_API
135 bool IsDomeLight() const;
136 GLF_API
137 void SetIsDomeLight(bool isDomeLight);
138
143 GLF_API
144 const SdfAssetPath &GetDomeLightTextureFile() const;
145 GLF_API
146 void SetDomeLightTextureFile(const SdfAssetPath &);
147
148
156
157 GLF_API
158 TfToken const & GetPostSurfaceIdentifier() const;
159 GLF_API
160 std::string const & GetPostSurfaceShaderSource() const;
161 GLF_API
162 VtUCharArray const & GetPostSurfaceShaderParams() const;
163
164 GLF_API
165 void SetPostSurfaceParams(TfToken const & identifier,
166 std::string const & shaderSource,
167 VtUCharArray const & shaderParams);
168
170
171 GLF_API
172 bool operator ==(GlfSimpleLight const &other) const;
173 GLF_API
174 bool operator !=(GlfSimpleLight const &other) const;
175
176private:
177 GLF_API
178 friend std::ostream & operator <<(std::ostream &out,
179 const GlfSimpleLight& v);
180 GfVec4f _ambient;
181 GfVec4f _diffuse;
182 GfVec4f _specular;
183 GfVec4f _position;
184 GfVec3f _spotDirection;
185 float _spotCutoff;
186 float _spotFalloff;
187 GfVec3f _attenuation;
188 bool _isCameraSpaceLight;
189 bool _hasIntensity;
190
191 bool _hasShadow;
192 int _shadowResolution;
193 float _shadowBias;
194 float _shadowBlur;
195 int _shadowIndexStart;
196 int _shadowIndexEnd;
197
198 GfMatrix4d _transform;
199 std::vector<GfMatrix4d> _shadowMatrices;
200
201 // domeLight specific parameters
202 bool _isDomeLight;
203 // path to texture for dome light.
204 SdfAssetPath _domeLightTextureFile;
205
206 TfToken _postSurfaceIdentifier;
207 std::string _postSurfaceShaderSource;
208 VtUCharArray _postSurfaceShaderParams;
209
210 SdfPath _id;
211};
212
213// VtValue requirements
214GLF_API
215std::ostream& operator<<(std::ostream& out, const GlfSimpleLight& v);
216
217typedef std::vector<class GlfSimpleLight> GlfSimpleLightVector;
218
219// VtValue requirements
220GLF_API
221std::ostream& operator<<(std::ostream& out, const GlfSimpleLightVector& pv);
222
223
224PXR_NAMESPACE_CLOSE_SCOPE
225
226#endif
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Basic type for a vector of 3 float components.
Definition: vec3f.h:46
Basic type for a vector of 4 float components.
Definition: vec4f.h:46
Contains an asset path and optional evaluated and resolved paths.
Definition: assetPath.h:78
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...