HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simpleLightTask.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_HDX_SIMPLE_LIGHT_TASK_H
25 #define PXR_IMAGING_HDX_SIMPLE_LIGHT_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
30 
32 #include "pxr/imaging/hd/task.h"
33 
36 
37 #include "pxr/base/gf/matrix4d.h"
38 #include "pxr/base/gf/vec3f.h"
40 
41 #include <memory>
42 
44 
45 class HdRenderIndex;
46 class HdSceneDelegate;
47 
48 using HdRenderPassSharedPtr = std::shared_ptr<class HdRenderPass>;
50  std::shared_ptr<class HdStSimpleLightingShader>;
52  std::shared_ptr<class HdxShadowMatrixComputation>;
53 
55 
56 
57 class HdxSimpleLightTask : public HdTask {
58 public:
59  HDX_API
60  HdxSimpleLightTask(HdSceneDelegate* delegate, SdfPath const& id);
61 
62  HDX_API
63  virtual ~HdxSimpleLightTask();
64 
65  /// Sync the render pass resources
66  HDX_API
67  virtual void Sync(HdSceneDelegate* delegate,
68  HdTaskContext* ctx,
69  HdDirtyBits* dirtyBits) override;
70 
71  /// Prepare the tasks resources
72  HDX_API
73  virtual void Prepare(HdTaskContext* ctx,
74  HdRenderIndex* renderIndex) override;
75 
76  /// Execute render pass task
77  HDX_API
78  virtual void Execute(HdTaskContext* ctx) override;
79 
80 private:
81  SdfPath _cameraId;
82  std::map<TfToken, SdfPathVector> _lightIds;
83  SdfPathVector _lightIncludePaths;
84  SdfPathVector _lightExcludePaths;
85  size_t _numLights;
86 
87  // Should be weak ptrs
88  HdStSimpleLightingShaderSharedPtr _lightingShader;
89  bool _enableShadows;
90  GfVec4f _viewport;
91 
92  // XXX: compatibility hack for passing some unit tests until we have
93  // more formal material plumbing.
94  GlfSimpleMaterial _material;
95  GfVec4f _sceneAmbient;
96 
97  // For now these are only valid for the lifetime of a single pass of
98  // the render graph. Maybe long-term these could be change-tracked.
99  GlfSimpleLightVector _glfSimpleLights;
100 
101  size_t _AppendLightsOfType(HdRenderIndex &renderIndex,
102  std::vector<TfToken> const &lightTypes,
103  SdfPathVector const &lightIncludePaths,
104  SdfPathVector const &lightExcludePaths,
105  std::map<TfToken, SdfPathVector> *lights);
106 
107  HdxSimpleLightTask() = delete;
108  HdxSimpleLightTask(const HdxSimpleLightTask &) = delete;
109  HdxSimpleLightTask &operator =(const HdxSimpleLightTask &) = delete;
110 };
111 
114  : cameraPath()
115  , lightIncludePaths(1, SdfPath::AbsoluteRootPath())
117  , enableShadows(false)
118  , viewport(0.0f)
119  , material()
120  , sceneAmbient(0)
121  {}
122 
128 
129  // XXX: compatibility hack for passing some unit tests until we have
130  // more formal material plumbing.
133 };
134 
135 // VtValue requirements
136 HDX_API
137 std::ostream& operator<<(std::ostream& out, const HdxSimpleLightTaskParams& pv);
138 HDX_API
139 bool operator==(
140  const HdxSimpleLightTaskParams& lhs,
141  const HdxSimpleLightTaskParams& rhs);
142 HDX_API
143 bool operator!=(
144  const HdxSimpleLightTaskParams& lhs,
145  const HdxSimpleLightTaskParams& rhs);
146 
149  : shadowMatrix()
150  , bias(0.0)
151  , blur(0.0)
152  , resolution(0)
153  , enabled(false)
154  {}
155 
157  double bias;
158  double blur;
160  bool enabled;
161 };
162 
163 // VtValue requirements
164 HDX_API
165 std::ostream& operator<<(std::ostream& out, const HdxShadowParams& pv);
166 HDX_API
167 bool operator==(const HdxShadowParams& lhs, const HdxShadowParams& rhs);
168 HDX_API
169 bool operator!=(const HdxShadowParams& lhs, const HdxShadowParams& rhs);
170 
171 
173 
174 #endif //PXR_IMAGING_HDX_SIMPLE_LIGHT_TASK_H
TF_DECLARE_REF_PTRS(GlfSimpleShadowArray)
virtual HDX_API ~HdxSimpleLightTask()
std::shared_ptr< class HdRenderPass > HdRenderPassSharedPtr
Definition: engine.h:41
uint32_t HdDirtyBits
Definition: types.h:127
HDX_API std::ostream & operator<<(std::ostream &out, const HdxSimpleLightTaskParams &pv)
std::shared_ptr< class HdxShadowMatrixComputation > HdxShadowMatrixComputationSharedPtr
#define HDX_API
Definition: api.h:40
GLclampf f
Definition: glew.h:3499
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:563
GLfloat bias
Definition: glew.h:10274
GlfSimpleMaterial material
Definition: task.h:54
Definition: path.h:288
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:209
virtual HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:73
std::shared_ptr< class HdStSimpleLightingShader > HdStSimpleLightingShaderSharedPtr
Definition: vec4f.h:63
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
GLenum GLsizei const GLuint GLboolean enabled
Definition: glew.h:2579
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
SdfPathVector lightExcludePaths
virtual HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
virtual HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
SdfPathVector lightIncludePaths
HdxShadowMatrixComputationSharedPtr shadowMatrix
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:549
std::vector< class GlfSimpleLight > GlfSimpleLightVector
Definition: simpleLight.h:192