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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HDX_SIMPLE_LIGHT_TASK_H
8 #define PXR_IMAGING_HDX_SIMPLE_LIGHT_TASK_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdx/api.h"
13 
14 #include "pxr/imaging/hd/task.h"
15 
18 
20 
21 #include "pxr/base/gf/vec3f.h"
23 
24 #include <memory>
25 
27 
28 class HdRenderIndex;
29 class HdSceneDelegate;
30 class HdCamera;
32 
33 using HdRenderPassSharedPtr = std::shared_ptr<class HdRenderPass>;
35  std::shared_ptr<class HdStSimpleLightingShader>;
37  std::shared_ptr<class HdxShadowMatrixComputation>;
38 
40 
41 
42 class HdxSimpleLightTask : public HdTask
43 {
44 public:
46 
47  HDX_API
48  HdxSimpleLightTask(HdSceneDelegate* delegate, SdfPath const& id);
49 
50  HDX_API
51  ~HdxSimpleLightTask() override;
52 
53  /// Sync the render pass resources
54  HDX_API
55  void Sync(HdSceneDelegate* delegate,
56  HdTaskContext* ctx,
57  HdDirtyBits* dirtyBits) override;
58 
59  /// Prepare the tasks resources
60  HDX_API
61  void Prepare(HdTaskContext* ctx,
62  HdRenderIndex* renderIndex) override;
63 
64  /// Execute render pass task
65  HDX_API
66  void Execute(HdTaskContext* ctx) override;
67 
68 private:
69  std::vector<GfMatrix4d> _ComputeShadowMatrices(
70  const HdCamera * camera,
71  HdxShadowMatrixComputationSharedPtr const &computation) const;
72 
73  SdfPath _cameraId;
74  std::map<TfToken, SdfPathVector> _lightIds;
75  SdfPathVector _lightIncludePaths;
76  SdfPathVector _lightExcludePaths;
77  size_t _numLightIds;
78  size_t _maxLights;
79  unsigned _sprimIndexVersion;
80  unsigned _settingsVersion;
81 
82  // Should be weak ptrs
83  HdStSimpleLightingShaderSharedPtr _lightingShader;
84  bool _enableShadows;
85  GfVec4f _viewport;
86  CameraUtilFraming _framing;
87  std::pair<bool, CameraUtilConformWindowPolicy> _overrideWindowPolicy;
88 
89  // XXX: compatibility hack for passing some unit tests until we have
90  // more formal material plumbing.
91  GlfSimpleMaterial _material;
92  GfVec4f _sceneAmbient;
93 
94  // For now these are only valid for the lifetime of a single pass of
95  // the render graph. Maybe long-term these could be change-tracked.
96  GlfSimpleLightVector _glfSimpleLights;
97 
98  HdBufferArrayRangeSharedPtr _lightingBar;
99  HdBufferArrayRangeSharedPtr _lightSourcesBar;
100  HdBufferArrayRangeSharedPtr _shadowsBar;
101  HdBufferArrayRangeSharedPtr _materialBar;
102 
103  bool _rebuildLightingBufferSources;
104  bool _rebuildLightAndShadowBufferSources;
105  bool _rebuildMaterialBufferSources;
106 
107  size_t _AppendLightsOfType(HdRenderIndex &renderIndex,
108  TfTokenVector const &lightTypes,
109  SdfPathVector const &lightIncludePaths,
110  SdfPathVector const &lightExcludePaths,
111  std::map<TfToken, SdfPathVector> *lights);
112 
113  HdxSimpleLightTask() = delete;
114  HdxSimpleLightTask(const HdxSimpleLightTask &) = delete;
115  HdxSimpleLightTask &operator =(const HdxSimpleLightTask &) = delete;
116 };
117 
119 {
121  : cameraPath()
122  , lightIncludePaths(1, SdfPath::AbsoluteRootPath())
124  , enableShadows(false)
125  , viewport(0.0f)
127  , material()
128  , sceneAmbient(0)
129  {}
130 
137  std::pair<bool, CameraUtilConformWindowPolicy> overrideWindowPolicy;
138 
139  // XXX: compatibility hack for passing some unit tests until we have
140  // more formal material plumbing.
143 };
144 
145 // VtValue requirements
146 HDX_API
147 std::ostream& operator<<(std::ostream& out, const HdxSimpleLightTaskParams& pv);
148 HDX_API
149 bool operator==(
150  const HdxSimpleLightTaskParams& lhs,
151  const HdxSimpleLightTaskParams& rhs);
152 HDX_API
153 bool operator!=(
154  const HdxSimpleLightTaskParams& lhs,
155  const HdxSimpleLightTaskParams& rhs);
156 
159  : shadowMatrix()
160  , bias(0.0)
161  , blur(0.0)
162  , resolution(0)
163  , enabled(false)
164  {}
165 
167  double bias;
168  double blur;
170  bool enabled;
171 };
172 
173 // VtValue requirements
174 HDX_API
175 std::ostream& operator<<(std::ostream& out, const HdxShadowParams& pv);
176 HDX_API
177 bool operator==(const HdxShadowParams& lhs, const HdxShadowParams& rhs);
178 HDX_API
179 bool operator!=(const HdxShadowParams& lhs, const HdxShadowParams& rhs);
180 
181 
183 
184 #endif //PXR_IMAGING_HDX_SIMPLE_LIGHT_TASK_H
TF_DECLARE_REF_PTRS(GlfSimpleShadowArray)
std::shared_ptr< class HdRenderPass > HdRenderPassSharedPtr
Definition: engine.h:24
uint32_t HdDirtyBits
Definition: types.h:143
HDX_API std::ostream & operator<<(std::ostream &out, const HdxSimpleLightTaskParams &pv)
std::shared_ptr< class HdxShadowMatrixComputation > HdxShadowMatrixComputationSharedPtr
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2539
#define HDX_API
Definition: api.h:23
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
GLfloat f
Definition: glcorearb.h:1926
std::vector< class SdfPath > SdfPathVector
std::pair< bool, CameraUtilConformWindowPolicy > overrideWindowPolicy
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
GlfSimpleMaterial material
Definition: task.h:43
Definition: path.h:273
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
std::shared_ptr< class HdStSimpleLightingShader > HdStSimpleLightingShaderSharedPtr
Definition: vec4f.h:45
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
CameraUtilFraming framing
HDX_API ~HdxSimpleLightTask() override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:27
SdfPathVector lightExcludePaths
SdfPathVector lightIncludePaths
HdxShadowMatrixComputationSharedPtr shadowMatrix
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
std::vector< class GlfSimpleLight > GlfSimpleLightVector
Definition: simpleLight.h:254
Increase width or height.
Definition: conformWindow.h:33