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
55 HD_API
56 virtual void Copy(HdRenderPassState const& src);
57
62 HD_API
63 virtual void Prepare(HdResourceRegistrySharedPtr const &resourceRegistry);
64
65 // ---------------------------------------------------------------------- //
67 // ---------------------------------------------------------------------- //
68
69 using ClipPlanesVector = std::vector<GfVec4d>;
70
72 HD_API
73 void SetCamera(const HdCamera *camera);
74
79 HD_API
81 const std::optional<CameraUtilConformWindowPolicy> &
82 overrideWindowPolicy);
83
86 HD_API
87 void SetFraming(const CameraUtilFraming &framing);
88
93 HD_API
94 void SetViewport(const GfVec4d &viewport);
95
97 HdCamera const *
98 GetCamera() const { return _camera; }
99
102 const CameraUtilFraming &
103 GetFraming() const { return _framing; }
104
107 const std::optional<CameraUtilConformWindowPolicy> &
108 GetOverrideWindowPolicy() const { return _overrideWindowPolicy; }
109
113 HD_API
114 CameraUtilConformWindowPolicy
116
121 HD_API
123
126 HD_API
128
132 GfVec4f const & GetViewport() const { return _viewport; }
133
138 HD_API
140
143 HD_API
144 virtual ClipPlanesVector const & GetClipPlanes() const;
145
146 // ---------------------------------------------------------------------- //
148 // ---------------------------------------------------------------------- //
149
153 HD_API
154 void SetOverrideColor(GfVec4f const &color);
155 const GfVec4f& GetOverrideColor() const { return _overrideColor; }
156
160 HD_API
161 void SetWireframeColor(GfVec4f const &color);
162 const GfVec4f& GetWireframeColor() const { return _wireframeColor; }
163
165 HD_API
166 void SetMaskColor(GfVec4f const &color);
167 const GfVec4f& GetMaskColor() const { return _maskColor; }
168
170 HD_API
171 void SetIndicatorColor(GfVec4f const &color);
172 const GfVec4f& GetIndicatorColor() const { return _indicatorColor; }
173
177 HD_API
178 void SetPointColor(GfVec4f const &color);
179 const GfVec4f& GetPointColor() const { return _pointColor; }
180
182 HD_API
183 void SetPointSize(float size);
184 float GetPointSize() const { return _pointSize; }
185
187 HD_API
188 void SetPointSelectedSize(float size);
189 float GetPointSelectedSize() const { return _pointSelectedSize; }
190
192 HD_API
193 void SetLightingEnabled(bool enabled);
194 bool GetLightingEnabled() const { return _lightingEnabled; }
195
196 HD_API
197 void SetClippingEnabled(bool enabled);
198 bool GetClippingEnabled() const { return _clippingEnabled; }
199
200 HD_API
201 void SetEnableExposureCompensation(bool enableExposureCompensation);
202 bool GetEnableExposureCompensation() const { return _enableExposureCompensation; }
203
204 // ---------------------------------------------------------------------- //
206 // ---------------------------------------------------------------------- //
207
209 HD_API
210 void SetAovBindings(HdRenderPassAovBindingVector const &aovBindings);
211 HD_API
212 HdRenderPassAovBindingVector const& GetAovBindings() const;
213
215 HD_API
216 void SetAovInputBindings(HdRenderPassAovBindingVector const &aovBindings);
217 HD_API
218 HdRenderPassAovBindingVector const& GetAovInputBindings() const;
219
222 HD_API
223 void SetUseAovMultiSample(bool state);
224 HD_API
225 bool GetUseAovMultiSample() const;
226
227 HD_API
228 void SetCullStyle(HdCullStyle cullStyle);
229 HD_API
230 HdCullStyle GetCullStyle() const { return _cullStyle; }
231
232 HD_API
233 void SetAlphaThreshold(float alphaThreshold);
234 float GetAlphaThreshold() const { return _alphaThreshold; }
235
236 HD_API
237 void SetTessLevel(float level);
238 float GetTessLevel() const { return _tessLevel; }
239
240 HD_API
241 void SetDrawingRange(GfVec2f const &drawRange);
242 GfVec2f GetDrawingRange() const { return _drawRange; } // in pixel
243 HD_API
244 GfVec2f GetDrawingRangeNDC() const; // in ndc
245
246 HD_API
247 void SetDepthBiasUseDefault(bool useDefault);
248 bool GetDepthBiasUseDefault() const { return _depthBiasUseDefault; }
249
250 HD_API
251 void SetDepthBiasEnabled(bool enabled);
252 bool GetDepthBiasEnabled() const { return _depthBiasEnabled; }
253
254 HD_API
255 void SetDepthBias(float constantFactor, float slopeFactor);
256
257 HD_API
258 void SetDepthFunc(HdCompareFunction depthFunc);
259 HdCompareFunction GetDepthFunc() const { return _depthFunc; }
260
261 HD_API
262 void SetEnableDepthMask(bool state);
263 HD_API
264 bool GetEnableDepthMask() const;
265
266 HD_API
267 void SetEnableDepthTest(bool enabled);
268 HD_API
269 bool GetEnableDepthTest() const;
270
271 HD_API
272 void SetEnableDepthClamp(bool enabled);
273 HD_API
274 bool GetEnableDepthClamp() const;
275
276 HD_API
277 void SetDepthRange(GfVec2f const &depthRange);
278 HD_API
279 const GfVec2f& GetDepthRange() const;
280
281 HD_API
282 void SetStencil(HdCompareFunction func, int ref, int mask,
283 HdStencilOp fail, HdStencilOp zfail, HdStencilOp zpass);
284 HdCompareFunction GetStencilFunc() const { return _stencilFunc; }
285 int GetStencilRef() const { return _stencilRef; }
286 int GetStencilMask() const { return _stencilMask; }
287 HdStencilOp GetStencilFailOp() const { return _stencilFailOp; }
288 HdStencilOp GetStencilDepthFailOp() const { return _stencilZFailOp; }
289 HdStencilOp GetStencilDepthPassOp() const { return _stencilZPassOp; }
290 HD_API
291 void SetStencilEnabled(bool enabled);
292 HD_API
293 bool GetStencilEnabled() const;
294
295 HD_API
296 void SetLineWidth(float width);
297 float GetLineWidth() const { return _lineWidth; }
298
299 HD_API
300 void SetBlend(HdBlendOp colorOp,
301 HdBlendFactor colorSrcFactor,
302 HdBlendFactor colorDstFactor,
303 HdBlendOp alphaOp,
304 HdBlendFactor alphaSrcFactor,
305 HdBlendFactor alphaDstFactor);
306 HdBlendOp GetBlendColorOp() { return _blendColorOp; }
307 HdBlendFactor GetBlendColorSrcFactor() { return _blendColorSrcFactor; }
308 HdBlendFactor GetBlendColorDstFactor() { return _blendColorDstFactor; }
309 HdBlendOp GetBlendAlphaOp() { return _blendAlphaOp; }
310 HdBlendFactor GetBlendAlphaSrcFactor() { return _blendAlphaSrcFactor; }
311 HdBlendFactor GetBlendAlphaDstFactor() { return _blendAlphaDstFactor; }
312
313 // Blend constant color is specified in the render color space
314 HD_API
315 void SetBlendConstantColor(GfVec4f const & color);
316 const GfVec4f& GetBlendConstantColor() const { return _blendConstantColor; }
317 HD_API
318 void SetBlendEnabled(bool enabled);
319
320 HD_API
321 void SetAlphaToCoverageEnabled(bool enabled);
322 bool GetAlphaToCoverageEnabled() const { return _alphaToCoverageEnabled; }
323
324 HD_API
325 void SetColorMaskUseDefault(bool useDefault);
326 bool GetColorMaskUseDefault() const { return _colorMaskUseDefault;}
327
328 HD_API
329 void SetConservativeRasterizationEnabled(bool enabled);
330 bool GetConservativeRasterizationEnabled() const {
331 return _conservativeRasterizationEnabled;
332 }
333
334 HD_API
335 void SetVolumeRenderingConstants(float stepSize, float stepSizeLighting);
336
337 enum ColorMask {
338 ColorMaskNone,
339 ColorMaskRGB,
340 ColorMaskRGBA
341 };
342
343 HD_API
344 void SetColorMasks(std::vector<ColorMask> const& masks);
345 std::vector<ColorMask> const& GetColorMasks() const { return _colorMasks; }
346
347 HD_API
348 void SetMultiSampleEnabled(bool enabled);
349 bool GetMultiSampleEnabled() const { return _multiSampleEnabled; }
350
351protected:
352 // ---------------------------------------------------------------------- //
353 // Camera and framing state
354 // ---------------------------------------------------------------------- //
355 HdCamera const *_camera;
356 GfVec4f _viewport;
357 CameraUtilFraming _framing;
358 std::optional<CameraUtilConformWindowPolicy> _overrideWindowPolicy;
359
360 // ---------------------------------------------------------------------- //
361 // Application rendering state
362 // ---------------------------------------------------------------------- //
363 GfVec4f _overrideColor;
364 GfVec4f _wireframeColor;
365 GfVec4f _pointColor;
366 float _pointSize;
367 bool _lightingEnabled;
368 bool _clippingEnabled;
369 bool _enableExposureCompensation;
370
371 GfVec4f _maskColor;
372 GfVec4f _indicatorColor;
373 float _pointSelectedSize;
374
375 // ---------------------------------------------------------------------- //
376 // Render pipeline state
377 // ---------------------------------------------------------------------- //
378 float _alphaThreshold;
379 float _tessLevel;
380 GfVec2f _drawRange;
381
382 bool _depthBiasUseDefault; // inherit existing state, ignore values below.
383 bool _depthBiasEnabled;
384 float _depthBiasConstantFactor;
385 float _depthBiasSlopeFactor;
386 HdCompareFunction _depthFunc;
387 bool _depthMaskEnabled;
388 bool _depthTestEnabled;
389 bool _depthClampEnabled;
390 GfVec2f _depthRange;
391
392 HdCullStyle _cullStyle;
393
394 // Stencil RenderPassState
395 HdCompareFunction _stencilFunc;
396 int _stencilRef;
397 int _stencilMask;
398 HdStencilOp _stencilFailOp;
399 HdStencilOp _stencilZFailOp;
400 HdStencilOp _stencilZPassOp;
401 bool _stencilEnabled;
402
403 // Line width
404 float _lineWidth;
405
406 // Blending
407 HdBlendOp _blendColorOp;
408 HdBlendFactor _blendColorSrcFactor;
409 HdBlendFactor _blendColorDstFactor;
410 HdBlendOp _blendAlphaOp;
411 HdBlendFactor _blendAlphaSrcFactor;
412 HdBlendFactor _blendAlphaDstFactor;
413 GfVec4f _blendConstantColor;
414 bool _blendEnabled;
415
416 // alpha to coverage
417 bool _alphaToCoverageEnabled;
418
419 bool _colorMaskUseDefault;
420 std::vector<ColorMask> _colorMasks;
421
422 HdRenderPassAovBindingVector _aovBindings;
423 HdRenderPassAovBindingVector _aovInputBindings;
424 bool _useMultiSampleAov;
425
426 bool _conservativeRasterizationEnabled;
427
428 float _stepSize;
429 float _stepSizeLighting;
430
431 bool _multiSampleEnabled;
432};
433
434PXR_NAMESPACE_CLOSE_SCOPE
435
436#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:48
Basic type for a vector of 4 float components.
Definition vec4f.h:48
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.
virtual HD_API void Copy(HdRenderPassState const &src)
Copy state from src into this object.
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...