Loading...
Searching...
No Matches
renderPassState.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_RENDER_PASS_STATE_H
8#define PXR_IMAGING_HD_RENDER_PASS_STATE_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hd/api.h"
12#include "pxr/imaging/hd/aov.h"
13#include "pxr/imaging/hd/version.h"
14#include "pxr/imaging/hd/enums.h"
15
16#include "pxr/imaging/cameraUtil/framing.h"
17
18#include "pxr/usd/sdf/path.h"
19
20#include "pxr/base/tf/token.h"
21#include "pxr/base/vt/value.h"
23#include "pxr/base/gf/vec2f.h"
24#include "pxr/base/gf/vec4d.h"
25#include "pxr/base/gf/vec4f.h"
26
27#include <memory>
28
29#include <optional>
30
31PXR_NAMESPACE_OPEN_SCOPE
32
33
34using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
35using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
36
37class HdCamera;
38
46{
47public:
48 HD_API
50 HD_API
51 virtual ~HdRenderPassState();
52
57 HD_API
58 virtual void Prepare(HdResourceRegistrySharedPtr const &resourceRegistry);
59
60 // ---------------------------------------------------------------------- //
62 // ---------------------------------------------------------------------- //
63
64 using ClipPlanesVector = std::vector<GfVec4d>;
65
67 HD_API
68 void SetCamera(const HdCamera *camera);
69
74 HD_API
76 const std::optional<CameraUtilConformWindowPolicy> &
77 overrideWindowPolicy);
78
81 HD_API
82 void SetFraming(const CameraUtilFraming &framing);
83
88 HD_API
89 void SetViewport(const GfVec4d &viewport);
90
92 HdCamera const *
93 GetCamera() const { return _camera; }
94
97 const CameraUtilFraming &
98 GetFraming() const { return _framing; }
99
102 const std::optional<CameraUtilConformWindowPolicy> &
103 GetOverrideWindowPolicy() const { return _overrideWindowPolicy; }
104
108 HD_API
109 CameraUtilConformWindowPolicy
111
116 HD_API
118
121 HD_API
123
127 GfVec4f const & GetViewport() const { return _viewport; }
128
133 HD_API
135
138 HD_API
139 virtual ClipPlanesVector const & GetClipPlanes() const;
140
141 // ---------------------------------------------------------------------- //
143 // ---------------------------------------------------------------------- //
144
148 HD_API
149 void SetOverrideColor(GfVec4f const &color);
150 const GfVec4f& GetOverrideColor() const { return _overrideColor; }
151
155 HD_API
156 void SetWireframeColor(GfVec4f const &color);
157 const GfVec4f& GetWireframeColor() const { return _wireframeColor; }
158
160 HD_API
161 void SetMaskColor(GfVec4f const &color);
162 const GfVec4f& GetMaskColor() const { return _maskColor; }
163
165 HD_API
166 void SetIndicatorColor(GfVec4f const &color);
167 const GfVec4f& GetIndicatorColor() const { return _indicatorColor; }
168
172 HD_API
173 void SetPointColor(GfVec4f const &color);
174 const GfVec4f& GetPointColor() const { return _pointColor; }
175
177 HD_API
178 void SetPointSize(float size);
179 float GetPointSize() const { return _pointSize; }
180
182 HD_API
183 void SetPointSelectedSize(float size);
184 float GetPointSelectedSize() const { return _pointSelectedSize; }
185
187 HD_API
188 void SetLightingEnabled(bool enabled);
189 bool GetLightingEnabled() const { return _lightingEnabled; }
190
191 HD_API
192 void SetClippingEnabled(bool enabled);
193 bool GetClippingEnabled() const { return _clippingEnabled; }
194
195 // ---------------------------------------------------------------------- //
197 // ---------------------------------------------------------------------- //
198
200 HD_API
201 void SetAovBindings(HdRenderPassAovBindingVector const &aovBindings);
202 HD_API
203 HdRenderPassAovBindingVector const& GetAovBindings() const;
204
206 HD_API
207 void SetAovInputBindings(HdRenderPassAovBindingVector const &aovBindings);
208 HD_API
209 HdRenderPassAovBindingVector const& GetAovInputBindings() const;
210
213 HD_API
214 void SetUseAovMultiSample(bool state);
215 HD_API
216 bool GetUseAovMultiSample() const;
217
218 HD_API
219 void SetCullStyle(HdCullStyle cullStyle);
220 HD_API
221 HdCullStyle GetCullStyle() const { return _cullStyle; }
222
223 HD_API
224 void SetAlphaThreshold(float alphaThreshold);
225 float GetAlphaThreshold() const { return _alphaThreshold; }
226
227 HD_API
228 void SetTessLevel(float level);
229 float GetTessLevel() const { return _tessLevel; }
230
231 HD_API
232 void SetDrawingRange(GfVec2f const &drawRange);
233 GfVec2f GetDrawingRange() const { return _drawRange; } // in pixel
234 HD_API
235 GfVec2f GetDrawingRangeNDC() const; // in ndc
236
237 HD_API
238 void SetDepthBiasUseDefault(bool useDefault);
239 bool GetDepthBiasUseDefault() const { return _depthBiasUseDefault; }
240
241 HD_API
242 void SetDepthBiasEnabled(bool enabled);
243 bool GetDepthBiasEnabled() const { return _depthBiasEnabled; }
244
245 HD_API
246 void SetDepthBias(float constantFactor, float slopeFactor);
247
248 HD_API
249 void SetDepthFunc(HdCompareFunction depthFunc);
250 HdCompareFunction GetDepthFunc() const { return _depthFunc; }
251
252 HD_API
253 void SetEnableDepthMask(bool state);
254 HD_API
255 bool GetEnableDepthMask() const;
256
257 HD_API
258 void SetEnableDepthTest(bool enabled);
259 HD_API
260 bool GetEnableDepthTest() const;
261
262 HD_API
263 void SetEnableDepthClamp(bool enabled);
264 HD_API
265 bool GetEnableDepthClamp() const;
266
267 HD_API
268 void SetDepthRange(GfVec2f const &depthRange);
269 HD_API
270 const GfVec2f& GetDepthRange() const;
271
272 HD_API
273 void SetStencil(HdCompareFunction func, int ref, int mask,
274 HdStencilOp fail, HdStencilOp zfail, HdStencilOp zpass);
275 HdCompareFunction GetStencilFunc() const { return _stencilFunc; }
276 int GetStencilRef() const { return _stencilRef; }
277 int GetStencilMask() const { return _stencilMask; }
278 HdStencilOp GetStencilFailOp() const { return _stencilFailOp; }
279 HdStencilOp GetStencilDepthFailOp() const { return _stencilZFailOp; }
280 HdStencilOp GetStencilDepthPassOp() const { return _stencilZPassOp; }
281 HD_API
282 void SetStencilEnabled(bool enabled);
283 HD_API
284 bool GetStencilEnabled() const;
285
286 HD_API
287 void SetLineWidth(float width);
288 float GetLineWidth() const { return _lineWidth; }
289
290 HD_API
291 void SetBlend(HdBlendOp colorOp,
292 HdBlendFactor colorSrcFactor,
293 HdBlendFactor colorDstFactor,
294 HdBlendOp alphaOp,
295 HdBlendFactor alphaSrcFactor,
296 HdBlendFactor alphaDstFactor);
297 HdBlendOp GetBlendColorOp() { return _blendColorOp; }
298 HdBlendFactor GetBlendColorSrcFactor() { return _blendColorSrcFactor; }
299 HdBlendFactor GetBlendColorDstFactor() { return _blendColorDstFactor; }
300 HdBlendOp GetBlendAlphaOp() { return _blendAlphaOp; }
301 HdBlendFactor GetBlendAlphaSrcFactor() { return _blendAlphaSrcFactor; }
302 HdBlendFactor GetBlendAlphaDstFactor() { return _blendAlphaDstFactor; }
303
304 // Blend constant color is specified in the render color space
305 HD_API
306 void SetBlendConstantColor(GfVec4f const & color);
307 const GfVec4f& GetBlendConstantColor() const { return _blendConstantColor; }
308 HD_API
309 void SetBlendEnabled(bool enabled);
310
311 HD_API
312 void SetAlphaToCoverageEnabled(bool enabled);
313 bool GetAlphaToCoverageEnabled() const { return _alphaToCoverageEnabled; }
314
315 HD_API
316 void SetColorMaskUseDefault(bool useDefault);
317 bool GetColorMaskUseDefault() const { return _colorMaskUseDefault;}
318
319 HD_API
320 void SetConservativeRasterizationEnabled(bool enabled);
321 bool GetConservativeRasterizationEnabled() const {
322 return _conservativeRasterizationEnabled;
323 }
324
325 HD_API
326 void SetVolumeRenderingConstants(float stepSize, float stepSizeLighting);
327
328 enum ColorMask {
329 ColorMaskNone,
330 ColorMaskRGB,
331 ColorMaskRGBA
332 };
333
334 HD_API
335 void SetColorMasks(std::vector<ColorMask> const& masks);
336 std::vector<ColorMask> const& GetColorMasks() const { return _colorMasks; }
337
338 HD_API
339 void SetMultiSampleEnabled(bool enabled);
340 bool GetMultiSampleEnabled() const { return _multiSampleEnabled; }
341
342protected:
343 // ---------------------------------------------------------------------- //
344 // Camera and framing state
345 // ---------------------------------------------------------------------- //
346 HdCamera const *_camera;
347 GfVec4f _viewport;
348 CameraUtilFraming _framing;
349 std::optional<CameraUtilConformWindowPolicy> _overrideWindowPolicy;
350
351 // ---------------------------------------------------------------------- //
352 // Application rendering state
353 // ---------------------------------------------------------------------- //
354 GfVec4f _overrideColor;
355 GfVec4f _wireframeColor;
356 GfVec4f _pointColor;
357 float _pointSize;
358 bool _lightingEnabled;
359 bool _clippingEnabled;
360
361 GfVec4f _maskColor;
362 GfVec4f _indicatorColor;
363 float _pointSelectedSize;
364
365 // ---------------------------------------------------------------------- //
366 // Render pipeline state
367 // ---------------------------------------------------------------------- //
368 float _alphaThreshold;
369 float _tessLevel;
370 GfVec2f _drawRange;
371
372 bool _depthBiasUseDefault; // inherit existing state, ignore values below.
373 bool _depthBiasEnabled;
374 float _depthBiasConstantFactor;
375 float _depthBiasSlopeFactor;
376 HdCompareFunction _depthFunc;
377 bool _depthMaskEnabled;
378 bool _depthTestEnabled;
379 bool _depthClampEnabled;
380 GfVec2f _depthRange;
381
382 HdCullStyle _cullStyle;
383
384 // Stencil RenderPassState
385 HdCompareFunction _stencilFunc;
386 int _stencilRef;
387 int _stencilMask;
388 HdStencilOp _stencilFailOp;
389 HdStencilOp _stencilZFailOp;
390 HdStencilOp _stencilZPassOp;
391 bool _stencilEnabled;
392
393 // Line width
394 float _lineWidth;
395
396 // Blending
397 HdBlendOp _blendColorOp;
398 HdBlendFactor _blendColorSrcFactor;
399 HdBlendFactor _blendColorDstFactor;
400 HdBlendOp _blendAlphaOp;
401 HdBlendFactor _blendAlphaSrcFactor;
402 HdBlendFactor _blendAlphaDstFactor;
403 GfVec4f _blendConstantColor;
404 bool _blendEnabled;
405
406 // alpha to coverage
407 bool _alphaToCoverageEnabled;
408
409 bool _colorMaskUseDefault;
410 std::vector<ColorMask> _colorMasks;
411
412 HdRenderPassAovBindingVector _aovBindings;
413 HdRenderPassAovBindingVector _aovInputBindings;
414 bool _useMultiSampleAov;
415
416 bool _conservativeRasterizationEnabled;
417
418 float _stepSize;
419 float _stepSizeLighting;
420
421 bool _multiSampleEnabled;
422};
423
424PXR_NAMESPACE_CLOSE_SCOPE
425
426#endif // PXR_IMAGING_HD_RENDER_PASS_STATE_H
Framing information.
Definition: framing.h:63
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Basic type for a vector of 2 float components.
Definition: vec2f.h:46
Basic type for a vector of 4 double components.
Definition: vec4d.h:46
Basic type for a vector of 4 float components.
Definition: vec4f.h:46
Hydra schema for a camera that pulls the params (see above) during Sync.
Definition: camera.h:92
A set of rendering parameters used among render passes.
HD_API GfMatrix4d GetImageToWorldMatrix() const
Compute a transform from window relative coordinates (x,y,z,1) to homogeneous world coordinates (x,...
GfVec4f const & GetViewport() const
Only use when clients did not specify a camera framing.
HD_API CameraUtilConformWindowPolicy GetWindowPolicy() const
The resolved window policy to conform the camera frustum.
virtual HD_API ClipPlanesVector const & GetClipPlanes() const
Returns HdCamera's clip planes.
HD_API void SetMaskColor(GfVec4f const &color)
The color is specified in the render color space.
HD_API void SetFraming(const CameraUtilFraming &framing)
Sets the framing to show the camera.
HD_API void SetOverrideWindowPolicy(const std::optional< CameraUtilConformWindowPolicy > &overrideWindowPolicy)
Sets whether to override the window policy used to conform the camera if its aspect ratio is not matc...
HD_API void SetAovInputBindings(HdRenderPassAovBindingVector const &aovBindings)
Set the AOVs that this renderpass needs to read from.
virtual HD_API void Prepare(HdResourceRegistrySharedPtr const &resourceRegistry)
Schedule to update renderPassState parameters.
HD_API void SetAovBindings(HdRenderPassAovBindingVector const &aovBindings)
Set the attachments for this renderpass to render into.
HD_API void SetCamera(const HdCamera *camera)
Sets the camera.
HD_API void SetPointColor(GfVec4f const &color)
Set a point color for rendering where the R, G and B components are the color and the alpha component...
HD_API void SetOverrideColor(GfVec4f const &color)
Set an override color for rendering where the R, G and B components are the color and the alpha compo...
HdCamera const * GetCamera() const
Get camera.
HD_API void SetPointSize(float size)
Set the point size for unselected points.
HD_API void SetViewport(const GfVec4d &viewport)
Sets the viewport to show the camera.
HD_API void SetWireframeColor(GfVec4f const &color)
Set a wireframe color for rendering where the R, G and B components are the color and the alpha compo...
HD_API void SetPointSelectedSize(float size)
Set the point size for selected points.
virtual HD_API GfMatrix4d GetProjectionMatrix() const
Compute projection matrix using physical attributes of an HdCamera.
HD_API void SetLightingEnabled(bool enabled)
XXX: Hacky way of disabling lighting.
const std::optional< CameraUtilConformWindowPolicy > & GetOverrideWindowPolicy() const
The override value for the window policy to conform the camera frustum that can be specified by the a...
HD_API void SetUseAovMultiSample(bool state)
Returns true if the render pass wants to render into the multi-sample aovs.
const CameraUtilFraming & GetFraming() const
Get framing information determining how the filmback plane maps to pixels.
HD_API void SetIndicatorColor(GfVec4f const &color)
The color is specified in the render color space.
virtual HD_API GfMatrix4d GetWorldToViewMatrix() const
Camera getter API.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...