HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simpleLightingContext.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_LIGHTING_CONTEXT_H
25 #define PXR_IMAGING_GLF_SIMPLE_LIGHTING_CONTEXT_H
26 
27 /// \file glf/simpleLightingContext.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/glf/api.h"
34 
35 #include "pxr/base/gf/matrix4d.h"
36 #include "pxr/base/gf/vec4f.h"
37 
39 #include "pxr/base/tf/refBase.h"
40 #include "pxr/base/tf/weakBase.h"
41 
43 
44 
49 
51 public:
53 
54  GLF_API
55  static GlfSimpleLightingContextRefPtr New();
56 
57  GLF_API
58  void SetLights(GlfSimpleLightVector const & lights);
59  GLF_API
61 
62  // returns the effective number of lights taken into account
63  // in composable/compatible shader constraints
64  GLF_API
65  int GetNumLightsUsed() const;
66 
67  // returns the number of shadow maps needed, by summing shadow maps
68  // allocated to each light.
69  GLF_API
70  int ComputeNumShadowsUsed() const;
71 
72  GLF_API
73  void SetShadows(GlfSimpleShadowArrayRefPtr const & shadows);
74  GLF_API
75  GlfSimpleShadowArrayRefPtr const & GetShadows();
76 
77  GLF_API
78  void SetMaterial(GlfSimpleMaterial const & material);
79  GLF_API
80  GlfSimpleMaterial const & GetMaterial() const;
81 
82  GLF_API
83  void SetSceneAmbient(GfVec4f const & sceneAmbient);
84  GLF_API
85  GfVec4f const & GetSceneAmbient() const;
86 
87  GLF_API
88  void SetCamera(GfMatrix4d const &worldToViewMatrix,
89  GfMatrix4d const &projectionMatrix);
90 
91  GLF_API
92  void SetUseLighting(bool val);
93  GLF_API
94  bool GetUseLighting() const;
95 
96  // returns true if any light has shadow enabled.
97  GLF_API
98  bool GetUseShadows() const;
99 
100  GLF_API
101  void SetUseColorMaterialDiffuse(bool val);
102  GLF_API
103  bool GetUseColorMaterialDiffuse() const;
104 
105  GLF_API
106  void InitUniformBlockBindings(GlfBindingMapPtr const &bindingMap) const;
107  GLF_API
108  void InitSamplerUnitBindings(GlfBindingMapPtr const &bindingMap) const;
109 
110  GLF_API
111  void BindUniformBlocks(GlfBindingMapPtr const &bindingMap);
112  GLF_API
113  void BindSamplers(GlfBindingMapPtr const &bindingMap);
114 
115  GLF_API
116  void UnbindSamplers(GlfBindingMapPtr const &bindingMap);
117 
118  GLF_API
119  void SetStateFromOpenGL();
120 
121 protected:
122  GLF_API
124  GLF_API
126 
127 private:
128  GlfSimpleLightVector _lights;
129  GlfSimpleShadowArrayRefPtr _shadows;
130 
131  GfMatrix4d _worldToViewMatrix;
132  GfMatrix4d _projectionMatrix;
133 
134  GlfSimpleMaterial _material;
135  GfVec4f _sceneAmbient;
136 
137  bool _useLighting;
138  bool _useShadows;
139  bool _useColorMaterialDiffuse;
140 
141  GlfUniformBlockRefPtr _lightingUniformBlock;
142  GlfUniformBlockRefPtr _shadowUniformBlock;
143  GlfUniformBlockRefPtr _materialUniformBlock;
144  GlfUniformBlockRefPtr _bindlessShadowlUniformBlock;
145 
146  bool _lightingUniformBlockValid;
147  bool _shadowUniformBlockValid;
148  bool _materialUniformBlockValid;
149 };
150 
151 
153 
154 #endif
GLF_API bool GetUseColorMaterialDiffuse() const
#define GLF_API
Definition: api.h:40
GLF_API void SetStateFromOpenGL()
GLF_API void BindSamplers(GlfBindingMapPtr const &bindingMap)
GLF_API void InitUniformBlockBindings(GlfBindingMapPtr const &bindingMap) const
GLF_API void SetLights(GlfSimpleLightVector const &lights)
GLuint const GLfloat * val
Definition: glew.h:2794
GLF_API void SetMaterial(GlfSimpleMaterial const &material)
GLF_API void SetSceneAmbient(GfVec4f const &sceneAmbient)
GLF_API GfVec4f const & GetSceneAmbient() const
GLF_API int ComputeNumShadowsUsed() const
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_AND_REF_PTRS(GlfBindingMap)
GLF_API GlfSimpleLightingContext()
GlfSimpleLightingContext This
GLF_API GlfSimpleMaterial const & GetMaterial() const
GLF_API void InitSamplerUnitBindings(GlfBindingMapPtr const &bindingMap) const
GLF_API bool GetUseLighting() const
GLF_API int GetNumLightsUsed() const
GLF_API void SetUseLighting(bool val)
GLF_API bool GetUseShadows() const
Definition: vec4f.h:63
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
GLF_API void UnbindSamplers(GlfBindingMapPtr const &bindingMap)
GLF_API GlfSimpleShadowArrayRefPtr const & GetShadows()
GLF_API ~GlfSimpleLightingContext()
GLF_API void BindUniformBlocks(GlfBindingMapPtr const &bindingMap)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
static GLF_API GlfSimpleLightingContextRefPtr New()
GLF_API void SetShadows(GlfSimpleShadowArrayRefPtr const &shadows)
GLF_API GlfSimpleLightVector & GetLights()
GLF_API void SetUseColorMaterialDiffuse(bool val)
GLF_API void SetCamera(GfMatrix4d const &worldToViewMatrix, GfMatrix4d const &projectionMatrix)
std::vector< class GlfSimpleLight > GlfSimpleLightVector
Definition: simpleLight.h:192