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
20
26{
27public:
29
30 HDX_API
31 HdxColorChannelTask(HdSceneDelegate* delegate, SdfPath const& id);
32
33 HDX_API
34 ~HdxColorChannelTask() override;
35
37 HDX_API
38 void Prepare(HdTaskContext* ctx,
39 HdRenderIndex* renderIndex) override;
40
42 HDX_API
43 void Execute(HdTaskContext* ctx) override;
44
45protected:
47 HDX_API
48 void _Sync(HdSceneDelegate* delegate,
49 HdTaskContext* ctx,
50 HdDirtyBits* dirtyBits) override;
51
52private:
53 HdxColorChannelTask() = delete;
55 HdxColorChannelTask &operator =(const HdxColorChannelTask &) = delete;
56
57 // Utility function to update the shader uniform parameters.
58 // Returns true if the values were updated. False if unchanged.
59 bool _UpdateParameterBuffer(float screenSizeX, float screenSizeY);
60
61 // This struct must match ParameterBuffer in colorChannel.glslfx.
62 // Be careful to remember the std430 rules.
63 struct _ParameterBuffer
64 {
65 float screenSize[2];
66 int channel;
67 bool operator==(const _ParameterBuffer& other) const {
68 return channel == other.channel &&
69 screenSize[0] == other.screenSize[0] &&
70 screenSize[1] == other.screenSize[1];
71 }
72 };
73
74 std::unique_ptr<class HdxFullscreenShader> _compositor;
75 _ParameterBuffer _parameterData;
76
77 // The color channel to be rendered (see HdxColorChannelTokens for the
78 // possible values).
79 TfToken _channel;
80};
81
82
88{
90
91 // Specifies which output color channel should be drawn. Defaults to 'color'
92 // (untouched RGBA).
93 TfToken channel = HdxColorChannelTokens->color;
94};
95
96// VtValue requirements
97HDX_API
98std::ostream& operator<<(std::ostream& out, const HdxColorChannelTaskParams& pv);
99HDX_API
100bool operator==(const HdxColorChannelTaskParams& lhs,
101 const HdxColorChannelTaskParams& rhs);
102HDX_API
103bool operator!=(const HdxColorChannelTaskParams& lhs,
104 const HdxColorChannelTaskParams& rhs);
105
106
107PXR_NAMESPACE_CLOSE_SCOPE
108
109#endif
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:105
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.