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 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"
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  GlfSimpleLightVector _glfSimpleLights;
99 
100  size_t _AppendLightsOfType(HdRenderIndex &renderIndex,
101  std::vector<TfToken> const &lightTypes,
102  SdfPathVector const &lightIncludePaths,
103  SdfPathVector const &lightExcludePaths,
104  std::map<TfToken, SdfPathVector> *lights);
105 
106  HdxSimpleLightTask() = delete;
107  HdxSimpleLightTask(const HdxSimpleLightTask &) = delete;
108  HdxSimpleLightTask &operator =(const HdxSimpleLightTask &) = delete;
109 };
110 
111 struct HdxSimpleLightTaskParams {
112  HdxSimpleLightTaskParams()
113  : cameraPath()
114  , lightIncludePaths(1, SdfPath::AbsoluteRootPath())
115  , lightExcludePaths()
116  , enableShadows(false)
117  , viewport(0.0f)
118  , material()
119  , sceneAmbient(0)
120  {}
121 
122  SdfPath cameraPath;
123  SdfPathVector lightIncludePaths;
124  SdfPathVector lightExcludePaths;
125  bool enableShadows;
126  GfVec4f viewport;
127 
128  // XXX: compatibility hack for passing some unit tests until we have
129  // more formal material plumbing.
130  GlfSimpleMaterial material;
131  GfVec4f sceneAmbient;
132 };
133 
134 // VtValue requirements
135 HDX_API
136 std::ostream& operator<<(std::ostream& out, const HdxSimpleLightTaskParams& pv);
137 HDX_API
138 bool operator==(const HdxSimpleLightTaskParams& lhs, const HdxSimpleLightTaskParams& rhs);
139 HDX_API
140 bool operator!=(const HdxSimpleLightTaskParams& lhs, const HdxSimpleLightTaskParams& rhs);
141 
142 struct HdxShadowParams {
143  HdxShadowParams()
144  : shadowMatrix()
145  , bias(0.0)
146  , blur(0.0)
147  , resolution(0)
148  , enabled(false)
149  {}
150 
151  HdxShadowMatrixComputationSharedPtr shadowMatrix;
152  double bias;
153  double blur;
154  int resolution;
155  bool enabled;
156 };
157 
158 // VtValue requirements
159 HDX_API
160 std::ostream& operator<<(std::ostream& out, const HdxShadowParams& pv);
161 HDX_API
162 bool operator==(const HdxShadowParams& lhs, const HdxShadowParams& rhs);
163 HDX_API
164 bool operator!=(const HdxShadowParams& lhs, const HdxShadowParams& rhs);
165 
166 
167 PXR_NAMESPACE_CLOSE_SCOPE
168 
169 #endif //PXR_IMAGING_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:117
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