All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shadowTask.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_SHADOW_TASK_H
25 #define HDX_SHADOW_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
29 #include "pxr/imaging/hdx/version.h"
30 #include "pxr/imaging/hd/enums.h"
31 #include "pxr/imaging/hd/rprimCollection.h"
32 #include "pxr/imaging/hd/task.h"
33 
34 #include "pxr/base/gf/vec2f.h"
35 #include "pxr/base/gf/vec4f.h"
36 #include "pxr/base/gf/vec4d.h"
37 #include "pxr/base/tf/declarePtrs.h"
38 
39 #include <boost/shared_ptr.hpp>
40 
41 PXR_NAMESPACE_OPEN_SCOPE
42 
43 class GlfSimpleLight;
44 class HdRenderIndex;
45 class HdSceneDelegate;
47 
48 typedef boost::shared_ptr<class HdStRenderPassShader> HdStRenderPassShaderSharedPtr;
49 typedef boost::shared_ptr<class HdStShaderCode> HdStShaderCodeSharedPtr;
50 typedef boost::shared_ptr<class HdRenderPassState> HdRenderPassStateSharedPtr;
51 typedef boost::shared_ptr<class HdRenderPass> HdRenderPassSharedPtr;
52 typedef std::vector<HdRenderPassStateSharedPtr> HdRenderPassStateSharedPtrVector;
53 typedef std::vector<HdRenderPassSharedPtr> HdRenderPassSharedPtrVector;
54 
55 TF_DECLARE_WEAK_AND_REF_PTRS(GlfSimpleShadowArray);
56 
57 struct HdxShadowTaskParams {
58  HdxShadowTaskParams()
59  : overrideColor(0.0)
60  , wireframeColor(0.0)
61  , enableLighting(false)
62  , enableIdRender(false)
63  , enableSceneMaterials(true)
64  , alphaThreshold(0.0)
65  , depthBiasEnable(false)
66  , depthBiasConstantFactor(0.0f)
67  , depthBiasSlopeFactor(1.0f)
68  , depthFunc(HdCmpFuncLEqual)
69  , cullStyle(HdCullStyleBackUnlessDoubleSided)
70  , camera()
71  , viewport(0.0)
72  , lightIncludePaths(1, SdfPath::AbsoluteRootPath())
73  , lightExcludePaths()
74  {}
75 
76  // RenderPassState
77  GfVec4f overrideColor;
78  GfVec4f wireframeColor;
79  bool enableLighting;
80  bool enableIdRender;
81  bool enableSceneMaterials;
82  float alphaThreshold;
83  bool depthBiasEnable;
84  float depthBiasConstantFactor;
85  float depthBiasSlopeFactor;
86  HdCompareFunction depthFunc;
87  HdCullStyle cullStyle;
88 
89  // RenderPassState index objects
90  SdfPath camera;
91  GfVec4d viewport;
92 
93  // Lights/Shadows specific parameters
94  SdfPathVector lightIncludePaths;
95  SdfPathVector lightExcludePaths;
96 };
97 
102 class HdxShadowTask : public HdTask {
103 public:
104  HDX_API
105  HdxShadowTask(HdSceneDelegate* delegate, SdfPath const& id);
106 
107  HDX_API
108  virtual ~HdxShadowTask();
109 
111  HDX_API
112  virtual void Sync(HdSceneDelegate* delegate,
113  HdTaskContext* ctx,
114  HdDirtyBits* dirtyBits) override;
115 
117  HDX_API
118  virtual void Prepare(HdTaskContext* ctx,
119  HdRenderIndex* renderIndex) override;
120 
122  HDX_API
123  virtual void Execute(HdTaskContext* ctx) override;
124 
126  HDX_API
127  virtual const TfTokenVector &GetRenderTags() const override;
128 
129 
130 private:
131  void _SetHdStRenderPassState(HdxShadowTaskParams const &params,
132  HdStRenderPassState *renderPassState);
133 
134  void _UpdateDirtyParams(HdRenderPassStateSharedPtr &renderPassState,
135  HdxShadowTaskParams const &params);
136 
137  static HdStShaderCodeSharedPtr _overrideShader;
138  static void _CreateOverrideShader();
139 
140  HdRenderPassSharedPtrVector _passes;
141  HdRenderPassStateSharedPtrVector _renderPassStates;
142  HdxShadowTaskParams _params;
143  TfTokenVector _renderTags;
144 
145 
146  HdxShadowTask() = delete;
147  HdxShadowTask(const HdxShadowTask &) = delete;
148  HdxShadowTask &operator =(const HdxShadowTask &) = delete;
149 };
150 
151 // VtValue requirements
152 HDX_API
153 std::ostream& operator<<(std::ostream& out, const HdxShadowTaskParams& pv);
154 HDX_API
155 bool operator==(const HdxShadowTaskParams& lhs, const HdxShadowTaskParams& rhs);
156 HDX_API
157 bool operator!=(const HdxShadowTaskParams& lhs, const HdxShadowTaskParams& rhs);
158 
159 
160 PXR_NAMESPACE_CLOSE_SCOPE
161 
162 #endif //HDX_SHADOW_TASK_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:119
virtual HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
A set of rendering parameters used among render passes.
Basic type for a vector of 4 double components.
Definition: vec4d.h:63
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
virtual HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
Adapter class providing data exchange with the client scene graph.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
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].
virtual HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
A task for generating shadow maps.
Definition: shadowTask.h:102
virtual HDX_API const TfTokenVector & GetRenderTags() const override
Collect Render Tags used by the task.