All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simpleLightTask.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_LIGHT_TASK_H
25 #define HDX_SIMPLE_LIGHT_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
29 #include "pxr/imaging/hdx/version.h"
30 
31 #include "pxr/imaging/hd/changeTracker.h"
32 #include "pxr/imaging/hd/task.h"
33 
34 #include "pxr/imaging/glf/simpleLight.h"
35 #include "pxr/imaging/glf/simpleMaterial.h"
36 
37 #include "pxr/base/gf/matrix4d.h"
38 #include "pxr/base/gf/vec3f.h"
39 #include "pxr/base/tf/declarePtrs.h"
40 
41 #include <boost/shared_ptr.hpp>
42 
43 PXR_NAMESPACE_OPEN_SCOPE
44 
45 
46 class HdRenderIndex;
47 class HdSceneDelegate;
48 
49 typedef boost::shared_ptr<class HdRenderPass> HdRenderPassSharedPtr;
50 typedef boost::shared_ptr<class HdxSimpleLightingShader> HdxSimpleLightingShaderSharedPtr;
51 typedef boost::shared_ptr<class HdxShadowMatrixComputation> HdxShadowMatrixComputationSharedPtr;
52 
53 TF_DECLARE_REF_PTRS(GlfSimpleShadowArray);
54 
55 
56 class HdxSimpleLightTask : public HdTask {
57 public:
58  HDX_API
59  HdxSimpleLightTask(HdSceneDelegate* delegate, SdfPath const& id);
60 
61  HDX_API
62  virtual ~HdxSimpleLightTask();
63 
65  HDX_API
66  virtual void Sync(HdSceneDelegate* delegate,
67  HdTaskContext* ctx,
68  HdDirtyBits* dirtyBits) override;
69 
71  HDX_API
72  virtual void Prepare(HdTaskContext* ctx,
73  HdRenderIndex* renderIndex) override;
74 
76  HDX_API
77  virtual void Execute(HdTaskContext* ctx) override;
78 
79 private:
80  SdfPath _cameraId;
81  std::map<TfToken, SdfPathVector> _lightIds;
82  SdfPathVector _lightIncludePaths;
83  SdfPathVector _lightExcludePaths;
84  size_t _numLights;
85 
86  // Should be weak ptrs
87  HdxSimpleLightingShaderSharedPtr _lightingShader;
88  bool _enableShadows;
89  GfVec4f _viewport;
90 
91  // XXX: compatibility hack for passing some unit tests until we have
92  // more formal material plumbing.
93  GlfSimpleMaterial _material;
94  GfVec4f _sceneAmbient;
95 
96  // For now these are only valid for the lifetime of a single pass of
97  // the render graph. Maybe long-term these could be change-tracked.
98  GlfSimpleShadowArrayRefPtr _shadows;
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 
112 struct HdxSimpleLightTaskParams {
113  HdxSimpleLightTaskParams()
114  : cameraPath()
115  , lightIncludePaths(1, SdfPath::AbsoluteRootPath())
116  , lightExcludePaths()
117  , enableShadows(false)
118  , viewport(0.0f)
119  , material()
120  , sceneAmbient(0)
121  {}
122 
123  SdfPath cameraPath;
124  SdfPathVector lightIncludePaths;
125  SdfPathVector lightExcludePaths;
126  bool enableShadows;
127  GfVec4f viewport;
128 
129  // XXX: compatibility hack for passing some unit tests until we have
130  // more formal material plumbing.
131  GlfSimpleMaterial material;
132  GfVec4f sceneAmbient;
133 };
134 
135 // VtValue requirements
136 HDX_API
137 std::ostream& operator<<(std::ostream& out, const HdxSimpleLightTaskParams& pv);
138 HDX_API
139 bool operator==(const HdxSimpleLightTaskParams& lhs, const HdxSimpleLightTaskParams& rhs);
140 HDX_API
141 bool operator!=(const HdxSimpleLightTaskParams& lhs, const HdxSimpleLightTaskParams& rhs);
142 
143 struct HdxShadowParams {
144  HdxShadowParams()
145  : shadowMatrix()
146  , bias(0.0)
147  , blur(0.0)
148  , resolution(0)
149  , enabled(false)
150  {}
151 
152  HdxShadowMatrixComputationSharedPtr shadowMatrix;
153  double bias;
154  double blur;
155  int resolution;
156  bool enabled;
157 };
158 
159 // VtValue requirements
160 HDX_API
161 std::ostream& operator<<(std::ostream& out, const HdxShadowParams& pv);
162 HDX_API
163 bool operator==(const HdxShadowParams& lhs, const HdxShadowParams& rhs);
164 HDX_API
165 bool operator!=(const HdxShadowParams& lhs, const HdxShadowParams& rhs);
166 
167 
168 PXR_NAMESPACE_CLOSE_SCOPE
169 
170 #endif //HDX_SIMPLE_LIGHT_TASK_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:119
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:75