All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
colorChannelTask.h
1 //
2 // Copyright 2019 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_COLORCHANNEL_TASK_H
25 #define HDX_COLORCHANNEL_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/path.h"
29 #include "pxr/imaging/hdx/api.h"
30 #include "pxr/imaging/hd/task.h"
31 #include "pxr/imaging/hdx/tokens.h"
32 #include "pxr/imaging/garch/gl.h"
33 #include <string>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 class HdStGLSLProgram;
38 typedef boost::shared_ptr<class HdStGLSLProgram> HdStGLSLProgramSharedPtr;
39 
44 class HdxColorChannelTask : public HdTask
45 {
46 public:
47  HDX_API
48  HdxColorChannelTask(HdSceneDelegate* delegate, SdfPath const& id);
49 
50  HDX_API
51  virtual ~HdxColorChannelTask();
52 
54  HDX_API
55  virtual void Sync(HdSceneDelegate* delegate,
56  HdTaskContext* ctx,
57  HdDirtyBits* dirtyBits) override;
58 
60  HDX_API
61  virtual void Prepare(HdTaskContext* ctx,
62  HdRenderIndex* renderIndex) override;
63 
65  HDX_API
66  virtual void Execute(HdTaskContext* ctx) override;
67 
68 private:
69  HdxColorChannelTask() = delete;
70  HdxColorChannelTask(const HdxColorChannelTask &) = delete;
71  HdxColorChannelTask &operator =(const HdxColorChannelTask &) = delete;
72 
73  // Utility function to create the GL program for color channel
74  bool _CreateShaderResources();
75 
76  // Utility function to create buffer resources.
77  bool _CreateBufferResources();
78 
79  // Utility function to setup the copy-framebuffer
80  bool _CreateFramebufferResources();
81 
82  // Copies the client framebuffer texture into ours
83  void _CopyTexture();
84 
86  void _ApplyColorChannel();
87 
88  // Get an integer that represents the color channel. This can be used to
89  // pass the color channel option as a uniform uint argument of the glsl
90  // shader (see the `#define CHANNEL_*` lines in the shader).
91  // If _channel contains an invalid entry this will return 'color'.
92  GLint _GetChannelAsGLint();
93 
94  HdStGLSLProgramSharedPtr _shaderProgram;
95  GLuint _texture;
96  GfVec2i _textureSize;
97  GLint _locations[5];
98  GLuint _vertexBuffer;
99 
100  GLuint _copyFramebuffer;
101  GfVec2i _framebufferSize;
102 
103  // The color channel to be rendered (see HdxColorChannelTokens for the
104  // possible values).
105  TfToken _channel;
106 };
107 
108 
114 {
116 
117  // Resolution of bound framebuffer we are color correcting.
118  // This must be set if the viewport and framebuffer do not match.
119  GfVec2i framebufferSize = GfVec2i(0);
120 
121  // Specifies which output color channel should be drawn. Defaults to 'color'
122  // (untouched RGBA).
123  TfToken channel = HdxColorChannelTokens->color;
124 };
125 
126 // VtValue requirements
127 HDX_API
128 std::ostream& operator<<(std::ostream& out, const HdxColorChannelTaskParams& pv);
129 HDX_API
130 bool operator==(const HdxColorChannelTaskParams& lhs,
131  const HdxColorChannelTaskParams& rhs);
132 HDX_API
133 bool operator!=(const HdxColorChannelTaskParams& lhs,
134  const HdxColorChannelTaskParams& rhs);
135 
136 
137 PXR_NAMESPACE_CLOSE_SCOPE
138 
139 #endif
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:121
ColorChannelTask parameters.
Basic type for a vector of 2 int components.
Definition: vec2i.h:61
virtual HDX_API void Execute(HdTaskContext *ctx) override
Execute the color channel task.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
An instance of a glsl program.
Definition: glslProgram.h:44
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Adapter class providing data exchange with the client scene graph.
virtual HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
A task for choosing a color channel for display.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
virtual HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.