Loading...
Searching...
No Matches
skydomeTask.h
1//
2// Copyright 2021 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef HDX_SKYDOME_TASK_H
8#define HDX_SKYDOME_TASK_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdx/api.h"
12#include "pxr/imaging/hdx/renderSetupTask.h"
13#include "pxr/imaging/hdx/task.h"
14
16#include "pxr/base/gf/vec2f.h"
17#include "pxr/usd/sdf/path.h"
18#include "pxr/imaging/hgi/graphicsCmds.h"
19
21
22PXR_NAMESPACE_OPEN_SCOPE
23
34class HdxSkydomeTask : public HdxTask
35{
36public:
37 HDX_API
38 HdxSkydomeTask(HdSceneDelegate* delegate, SdfPath const& id);
39
40 HDX_API
41 ~HdxSkydomeTask() override;
42
44 HDX_API
45 void Prepare(HdTaskContext* ctx,
46 HdRenderIndex* renderIndex) override;
47
49 HDX_API
50 void Execute(HdTaskContext* ctx) override;
51
52protected:
54 HDX_API
55 void _Sync(HdSceneDelegate* delegate,
56 HdTaskContext* ctx,
57 HdDirtyBits* dirtyBits) override;
58
59private:
60 HdRenderIndex* _renderIndex;
61 HgiTextureHandle _skydomeTexture;
62 // Optional internal render setup task, for params unpacking.
63 // This is used for aov bindings, camera matrices and framing
64 HdxRenderSetupTaskSharedPtr _setupTask;
65 unsigned int _settingsVersion;
66 bool _skydomeVisibility;
67
68 HdxSkydomeTask() = delete;
69 HdxSkydomeTask(const HdxSkydomeTask &) = delete;
70 HdxSkydomeTask &operator =(const HdxSkydomeTask &) = delete;
71
72 HdRenderPassStateSharedPtr _GetRenderPassState(HdTaskContext *ctx) const;
73 bool _GetSkydomeTexture(HdTaskContext* ctx);
74 void _SetFragmentShader();
75
76 // Utility function to update the shader uniform parameters.
77 // Returns true if the values were updated. False if unchanged.
78 bool _UpdateParameterBuffer(
79 const GfMatrix4f& invProjMatrix,
80 const GfMatrix4f& viewToWorldMatrix,
81 const GfMatrix4f& lightTransform);
82
83 // This struct must match ParameterBuffer in Skydome.glslfx.
84 // Be careful to remember the std430 rules.
85 struct _ParameterBuffer
86 {
87 GfMatrix4f invProjMatrix;
88 GfMatrix4f viewToWorldMatrix;
89 GfMatrix4f lightTransform;
90 };
91
92 std::unique_ptr<class HdxFullscreenShader> _compositor;
93 _ParameterBuffer _parameterData;
94};
95
96
97PXR_NAMESPACE_CLOSE_SCOPE
98
99#endif
Stores a 4x4 matrix of float elements.
Definition: matrix4f.h:71
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:104
Adapter class providing data exchange with the client scene graph.
If we have a domelight present in the lighting context the SkydomeTask will render the associated env...
Definition: skydomeTask.h:35
HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
HDX_API void Execute(HdTaskContext *ctx) override
Execute render pass task.
Base class for (some) tasks in Hdx that provides common progressive rendering and Hgi functionality.
Definition: task.h:28
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274