All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simpleLightingShader.h
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 HDX_SIMPLE_LIGHTING_SHADER_H
25 #define HDX_SIMPLE_LIGHTING_SHADER_H
26 
27 #include "pxr/imaging/glf/glew.h"
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/hdx/api.h"
31 #include "pxr/imaging/hd/version.h"
32 #include "pxr/imaging/hd/materialParam.h"
33 #include "pxr/imaging/hd/resource.h"
34 #include "pxr/imaging/hdSt/lightingShader.h"
35 #include "pxr/imaging/hdSt/resourceBinder.h"
36 
37 #include "pxr/imaging/glf/bindingMap.h"
38 #include "pxr/imaging/hio/glslfx.h"
39 #include "pxr/imaging/glf/simpleLightingContext.h"
40 
41 #include "pxr/base/gf/matrix4d.h"
42 
43 #include "pxr/base/tf/declarePtrs.h"
44 #include "pxr/base/tf/token.h"
45 
46 #include <boost/scoped_ptr.hpp>
47 #include <boost/shared_ptr.hpp>
48 
49 #include <string>
50 
51 PXR_NAMESPACE_OPEN_SCOPE
52 
53 
54 typedef boost::shared_ptr<class HdxSimpleLightingShader> HdxSimpleLightingShaderSharedPtr;
55 typedef boost::shared_ptr<class HdStTextureResource>
56  HdStTextureResourceSharedPtr;
62 public:
63  HDX_API
65  HDX_API
66  virtual ~HdxSimpleLightingShader();
67 
69  HDX_API
70  ID ComputeHash() const override;
71  HDX_API
72  std::string GetSource(TfToken const &shaderStageKey) const override;
73  HDX_API
74  void BindResources(HdSt_ResourceBinder const &binder, int program) override;
75  HDX_API
76  void UnbindResources(HdSt_ResourceBinder const &binder, int program) override;
77  HDX_API
78  void AddBindings(HdBindingRequestVector *customBindings) override;
79 
81  HDST_API
82  HdMaterialParamVector const& GetParams() const override;
83 
85  HDX_API
86  void SetCamera(
87  GfMatrix4d const &worldToViewMatrix,
88  GfMatrix4d const &projectionMatrix) override;
89 
90  HDX_API
91  void SetLightingStateFromOpenGL();
92  HDX_API
93  void SetLightingState(GlfSimpleLightingContextPtr const &lightingContext);
94 
95  GlfSimpleLightingContextRefPtr GetLightingContext() {
96  return _lightingContext;
97  };
98 
99 private:
100  GlfSimpleLightingContextRefPtr _lightingContext;
101  GlfBindingMapRefPtr _bindingMap;
102  bool _useLighting;
103  boost::scoped_ptr<HioGlslfx> _glslfx;
104 
105  HdMaterialParamVector _lightTextureParams;
106 };
107 
108 
109 PXR_NAMESPACE_CLOSE_SCOPE
110 
111 #endif // HDX_SIMPLE_LIGHTING_SHADER_H
HDST_API HdMaterialParamVector const & GetParams() const override
HdStShaderCode overrides.
HDX_API void AddBindings(HdBindingRequestVector *customBindings) override
Add custom bindings (used by codegen)
A shader that supports simple lighting functionality.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
HDX_API void SetCamera(GfMatrix4d const &worldToViewMatrix, GfMatrix4d const &projectionMatrix) override
HdStLightingShader overrides.
A lighting shader base class.
HDX_API void UnbindResources(HdSt_ResourceBinder const &binder, int program) override
Unbinds shader-specific resources.
HDX_API std::string GetSource(TfToken const &shaderStageKey) const override
Returns the shader source provided by this shader for shaderStageKey.
HDX_API ID ComputeHash() const override
HdShader overrides.
HDX_API void BindResources(HdSt_ResourceBinder const &binder, int program) override
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the G...