Loading...
Searching...
No Matches
colorChannelTask.h
1//
2// Copyright 2019 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_COLORCHANNEL_TASK_H
8#define HDX_COLORCHANNEL_TASK_H
9
10#include "pxr/pxr.h"
11#include "pxr/usd/sdf/path.h"
12#include "pxr/imaging/hdx/api.h"
13#include "pxr/imaging/hdx/task.h"
14#include "pxr/imaging/hdx/tokens.h"
15#include "pxr/imaging/hgi/graphicsCmds.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
24{
25public:
26 HDX_API
27 HdxColorChannelTask(HdSceneDelegate* delegate, SdfPath const& id);
28
29 HDX_API
30 ~HdxColorChannelTask() override;
31
33 HDX_API
34 void Prepare(HdTaskContext* ctx,
35 HdRenderIndex* renderIndex) override;
36
38 HDX_API
39 void Execute(HdTaskContext* ctx) override;
40
41protected:
43 HDX_API
44 void _Sync(HdSceneDelegate* delegate,
45 HdTaskContext* ctx,
46 HdDirtyBits* dirtyBits) override;
47
48private:
49 HdxColorChannelTask() = delete;
51 HdxColorChannelTask &operator =(const HdxColorChannelTask &) = delete;
52
53 // Utility function to update the shader uniform parameters.
54 // Returns true if the values were updated. False if unchanged.
55 bool _UpdateParameterBuffer(float screenSizeX, float screenSizeY);
56
58 void _ApplyColorChannel();
59
60 // This struct must match ParameterBuffer in colorChannel.glslfx.
61 // Be careful to remember the std430 rules.
62 struct _ParameterBuffer
63 {
64 float screenSize[2];
65 int channel;
66 bool operator==(const _ParameterBuffer& other) const {
67 return channel == other.channel &&
68 screenSize[0] == other.screenSize[0] &&
69 screenSize[1] == other.screenSize[1];
70 }
71 };
72
73 std::unique_ptr<class HdxFullscreenShader> _compositor;
74 _ParameterBuffer _parameterData;
75
76 // The color channel to be rendered (see HdxColorChannelTokens for the
77 // possible values).
78 TfToken _channel;
79};
80
81
87{
89
90 // Specifies which output color channel should be drawn. Defaults to 'color'
91 // (untouched RGBA).
92 TfToken channel = HdxColorChannelTokens->color;
93};
94
95// VtValue requirements
96HDX_API
97std::ostream& operator<<(std::ostream& out, const HdxColorChannelTaskParams& pv);
98HDX_API
99bool operator==(const HdxColorChannelTaskParams& lhs,
100 const HdxColorChannelTaskParams& rhs);
101HDX_API
102bool operator!=(const HdxColorChannelTaskParams& lhs,
103 const HdxColorChannelTaskParams& rhs);
104
105
106PXR_NAMESPACE_CLOSE_SCOPE
107
108#endif
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.
A task for choosing a color channel for display.
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 the color channel 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
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
ColorChannelTask parameters.