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:
38
39 HDX_API
40 HdxSkydomeTask(HdSceneDelegate* delegate, SdfPath const& id);
41
42 HDX_API
43 ~HdxSkydomeTask() override;
44
46 HDX_API
47 void Prepare(HdTaskContext* ctx,
48 HdRenderIndex* renderIndex) override;
49
51 HDX_API
52 void Execute(HdTaskContext* ctx) override;
53
54protected:
56 HDX_API
57 void _Sync(HdSceneDelegate* delegate,
58 HdTaskContext* ctx,
59 HdDirtyBits* dirtyBits) override;
60
61private:
62 HdRenderIndex* _renderIndex;
63 HgiTextureHandle _skydomeTexture;
64 HgiSamplerHandle _skydomeSampler;
65 // Optional internal render setup task, for params unpacking.
66 // This is used for aov bindings, camera matrices and framing
67 HdxRenderSetupTaskSharedPtr _setupTask;
68 unsigned int _settingsVersion;
69 bool _skydomeVisibility;
70
71 HdxSkydomeTask() = delete;
72 HdxSkydomeTask(const HdxSkydomeTask &) = delete;
73 HdxSkydomeTask &operator =(const HdxSkydomeTask &) = delete;
74
75 HdRenderPassStateSharedPtr _GetRenderPassState(HdTaskContext *ctx) const;
76 bool _GetSkydomeTexture(HdTaskContext* ctx);
77 void _SetFragmentShader();
78
79 // Utility function to update the shader uniform parameters.
80 // Returns true if the values were updated. False if unchanged.
81 bool _UpdateParameterBuffer(
82 const GfMatrix4f& invProjMatrix,
83 const GfMatrix4f& viewToWorldMatrix,
84 const GfMatrix4f& lightTransform);
85
86 // This struct must match ParameterBuffer in Skydome.glslfx.
87 // Be careful to remember the std430 rules.
88 struct _ParameterBuffer
89 {
90 GfMatrix4f invProjMatrix;
91 GfMatrix4f viewToWorldMatrix;
92 GfMatrix4f lightTransform;
93 };
94
95 std::unique_ptr<class HdxFullscreenShader> _compositor;
96 _ParameterBuffer _parameterData;
97};
98
99
100PXR_NAMESPACE_CLOSE_SCOPE
101
102#endif
Stores a 4x4 matrix of float elements.
Definition matrix4f.h:71
The render index is part of the Hydra 1.0 API and is only used for emulation purposes so that HdScene...
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:281
RenderTask parameters (renderpass state).