This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
41 GLF_API
42 GfVec4f const & GetAmbient() const;
43 GLF_API
44 void SetAmbient(GfVec4f const & ambient);
45
46 GLF_API
47 GfVec4f const & GetDiffuse() const;
48 GLF_API
49 void SetDiffuse(GfVec4f const & diffuse);
50
51 GLF_API
52 GfVec4f const & GetSpecular() const;
53 GLF_API
54 void SetSpecular(GfVec4f const & specular);
55
56 GLF_API
57 GfVec4f const & GetPosition() const;
58 GLF_API
59 void SetPosition(GfVec4f const & position);
60
61 GLF_API
62 GfVec3f const & GetSpotDirection() const;
63 GLF_API
64 void SetSpotDirection(GfVec3f const & spotDirection);
65
66 GLF_API
67 float const & GetSpotCutoff() const;
68 GLF_API
69 void SetSpotCutoff(float const & spotCutoff);
70
71 GLF_API
72 float const & GetSpotFalloff() const;
73 GLF_API
74 void SetSpotFalloff(float const & spotFalloff);
75
76 GLF_API
77 GfVec3f const & GetAttenuation() const;
78 GLF_API
79 void SetAttenuation(GfVec3f const & attenuation);
80
81 GLF_API
82 std::vector<GfMatrix4d> const & GetShadowMatrices() const;
83 GLF_API
84 void SetShadowMatrices(std::vector<GfMatrix4d> const &matrix);
85
86 GLF_API
87 int GetShadowResolution() const;
88 GLF_API
89 void SetShadowResolution(int resolution);
90
91 GLF_API
92 float GetShadowBias() const;
93 GLF_API
94 void SetShadowBias(float bias);
95
96 GLF_API
97 float GetShadowBlur() const;
98 GLF_API
99 void SetShadowBlur(float blur);
100
101 GLF_API
102 int GetShadowIndexStart() const;
103 GLF_API
104 void SetShadowIndexStart(int shadowStart);
105
106 GLF_API
107 int GetShadowIndexEnd() const;
108 GLF_API
109 void SetShadowIndexEnd(int shadowEnd);
110
111 GLF_API
112 bool HasShadow() const;
113 GLF_API
114 void SetHasShadow(bool hasShadow);
115
116 GLF_API
117 bool HasIntensity() const;
118 GLF_API
119 void SetHasIntensity(bool hasIntensity);
120
121 GLF_API
122 bool IsCameraSpaceLight() const;
123 GLF_API
124
125 void SetIsCameraSpaceLight(bool isCameraSpaceLight);
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
140 GLF_API
141 const SdfAssetPath &GetDomeLightTextureFile() const;
142 GLF_API
143 void SetDomeLightTextureFile(const SdfAssetPath &);
144
145
153
154 GLF_API
155 TfToken const & GetPostSurfaceIdentifier() const;
156 GLF_API
157 std::string const & GetPostSurfaceShaderSource() const;
158 GLF_API
159 VtUCharArray const & GetPostSurfaceShaderParams() const;
160
161 GLF_API
162 void SetPostSurfaceParams(TfToken const & identifier,
163 std::string const & shaderSource,
164 VtUCharArray const & shaderParams);
165
167
168 GLF_API
169 bool operator ==(GlfSimpleLight const &other) const;
170 GLF_API
171 bool operator !=(GlfSimpleLight const &other) const;
172
173private:
174 GLF_API
175 friend std::ostream & operator <<(std::ostream &out,
176 const GlfSimpleLight& v);
177 GfVec4f _ambient;
178 GfVec4f _diffuse;
179 GfVec4f _specular;
180 GfVec4f _position;
181 GfVec3f _spotDirection;
182 float _spotCutoff;
183 float _spotFalloff;
184 GfVec3f _attenuation;
185 bool _isCameraSpaceLight;
186 bool _hasIntensity;
187
188 bool _hasShadow;
189 int _shadowResolution;
190 float _shadowBias;
191 float _shadowBlur;
192 int _shadowIndexStart;
193 int _shadowIndexEnd;
194
195 GfMatrix4d _transform;
196 std::vector<GfMatrix4d> _shadowMatrices;
197
198 // domeLight specific parameters
199 bool _isDomeLight;
200 // path to texture for dome light.
201 SdfAssetPath _domeLightTextureFile;
202
203 TfToken _postSurfaceIdentifier;
204 std::string _postSurfaceShaderSource;
205 VtUCharArray _postSurfaceShaderParams;
206
207 SdfPath _id;
208};
209
210// VtValue requirements
211GLF_API
212std::ostream& operator<<(std::ostream& out, const GlfSimpleLight& v);
213
214typedef std::vector<class GlfSimpleLight> GlfSimpleLightVector;
215
216// VtValue requirements
217GLF_API
218std::ostream& operator<<(std::ostream& out, const GlfSimpleLightVector& pv);
219
220
221PXR_NAMESPACE_CLOSE_SCOPE
222
223#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 an optional resolved path.
Definition: assetPath.h:30
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...