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
147 HD_API
148 void SetOverrideColor(GfVec4f const &color);
149 const GfVec4f& GetOverrideColor() const { return _overrideColor; }
150
153 HD_API
154 void SetWireframeColor(GfVec4f const &color);
155 const GfVec4f& GetWireframeColor() const { return _wireframeColor; }
156
157 HD_API
158 void SetMaskColor(GfVec4f const &color);
159 const GfVec4f& GetMaskColor() const { return _maskColor; }
160
161 HD_API
162 void SetIndicatorColor(GfVec4f const &color);
163 const GfVec4f& GetIndicatorColor() const { return _indicatorColor; }
164
167 HD_API
168 void SetPointColor(GfVec4f const &color);
169 const GfVec4f& GetPointColor() const { return _pointColor; }
170
172 HD_API
173 void SetPointSize(float size);
174 float GetPointSize() const { return _pointSize; }
175
177 HD_API
178 void SetPointSelectedSize(float size);
179 float GetPointSelectedSize() const { return _pointSelectedSize; }
180
182 HD_API
183 void SetLightingEnabled(bool enabled);
184 bool GetLightingEnabled() const { return _lightingEnabled; }
185
186 HD_API
187 void SetClippingEnabled(bool enabled);
188 bool GetClippingEnabled() const { return _clippingEnabled; }
189
190 // ---------------------------------------------------------------------- //
192 // ---------------------------------------------------------------------- //
193
195 HD_API
196 void SetAovBindings(HdRenderPassAovBindingVector const &aovBindings);
197 HD_API
198 HdRenderPassAovBindingVector const& GetAovBindings() const;
199
201 HD_API
202 void SetAovInputBindings(HdRenderPassAovBindingVector const &aovBindings);
203 HD_API
204 HdRenderPassAovBindingVector const& GetAovInputBindings() const;
205
208 HD_API
209 void SetUseAovMultiSample(bool state);
210 HD_API
211 bool GetUseAovMultiSample() const;
212
213 HD_API
214 void SetCullStyle(HdCullStyle cullStyle);
215 HD_API
216 HdCullStyle GetCullStyle() const { return _cullStyle; }
217
218 HD_API
219 void SetAlphaThreshold(float alphaThreshold);
220 float GetAlphaThreshold() const { return _alphaThreshold; }
221
222 HD_API
223 void SetTessLevel(float level);
224 float GetTessLevel() const { return _tessLevel; }
225
226 HD_API
227 void SetDrawingRange(GfVec2f const &drawRange);
228 GfVec2f GetDrawingRange() const { return _drawRange; } // in pixel
229 HD_API
230 GfVec2f GetDrawingRangeNDC() const; // in ndc
231
232 HD_API
233 void SetDepthBiasUseDefault(bool useDefault);
234 bool GetDepthBiasUseDefault() const { return _depthBiasUseDefault; }
235
236 HD_API
237 void SetDepthBiasEnabled(bool enabled);
238 bool GetDepthBiasEnabled() const { return _depthBiasEnabled; }
239
240 HD_API
241 void SetDepthBias(float constantFactor, float slopeFactor);
242
243 HD_API
244 void SetDepthFunc(HdCompareFunction depthFunc);
245 HdCompareFunction GetDepthFunc() const { return _depthFunc; }
246
247 HD_API
248 void SetEnableDepthMask(bool state);
249 HD_API
250 bool GetEnableDepthMask() const;
251
252 HD_API
253 void SetEnableDepthTest(bool enabled);
254 HD_API
255 bool GetEnableDepthTest() const;
256
257 HD_API
258 void SetEnableDepthClamp(bool enabled);
259 HD_API
260 bool GetEnableDepthClamp() const;
261
262 HD_API
263 void SetDepthRange(GfVec2f const &depthRange);
264 HD_API
265 const GfVec2f& GetDepthRange() const;
266
267 HD_API
268 void SetStencil(HdCompareFunction func, int ref, int mask,
269 HdStencilOp fail, HdStencilOp zfail, HdStencilOp zpass);
270 HdCompareFunction GetStencilFunc() const { return _stencilFunc; }
271 int GetStencilRef() const { return _stencilRef; }
272 int GetStencilMask() const { return _stencilMask; }
273 HdStencilOp GetStencilFailOp() const { return _stencilFailOp; }
274 HdStencilOp GetStencilDepthFailOp() const { return _stencilZFailOp; }
275 HdStencilOp GetStencilDepthPassOp() const { return _stencilZPassOp; }
276 HD_API
277 void SetStencilEnabled(bool enabled);
278 HD_API
279 bool GetStencilEnabled() const;
280
281 HD_API
282 void SetLineWidth(float width);
283 float GetLineWidth() const { return _lineWidth; }
284
285 HD_API
286 void SetBlend(HdBlendOp colorOp,
287 HdBlendFactor colorSrcFactor,
288 HdBlendFactor colorDstFactor,
289 HdBlendOp alphaOp,
290 HdBlendFactor alphaSrcFactor,
291 HdBlendFactor alphaDstFactor);
292 HdBlendOp GetBlendColorOp() { return _blendColorOp; }
293 HdBlendFactor GetBlendColorSrcFactor() { return _blendColorSrcFactor; }
294 HdBlendFactor GetBlendColorDstFactor() { return _blendColorDstFactor; }
295 HdBlendOp GetBlendAlphaOp() { return _blendAlphaOp; }
296 HdBlendFactor GetBlendAlphaSrcFactor() { return _blendAlphaSrcFactor; }
297 HdBlendFactor GetBlendAlphaDstFactor() { return _blendAlphaDstFactor; }
298 HD_API
299 void SetBlendConstantColor(GfVec4f const & color);
300 const GfVec4f& GetBlendConstantColor() const { return _blendConstantColor; }
301 HD_API
302 void SetBlendEnabled(bool enabled);
303
304 HD_API
305 void SetAlphaToCoverageEnabled(bool enabled);
306 bool GetAlphaToCoverageEnabled() const { return _alphaToCoverageEnabled; }
307
308 HD_API
309 void SetColorMaskUseDefault(bool useDefault);
310 bool GetColorMaskUseDefault() const { return _colorMaskUseDefault;}
311
312 HD_API
313 void SetConservativeRasterizationEnabled(bool enabled);
314 bool GetConservativeRasterizationEnabled() const {
315 return _conservativeRasterizationEnabled;
316 }
317
318 HD_API
319 void SetVolumeRenderingConstants(float stepSize, float stepSizeLighting);
320
321 enum ColorMask {
322 ColorMaskNone,
323 ColorMaskRGB,
324 ColorMaskRGBA
325 };
326
327 HD_API
328 void SetColorMasks(std::vector<ColorMask> const& masks);
329 std::vector<ColorMask> const& GetColorMasks() const { return _colorMasks; }
330
331 HD_API
332 void SetMultiSampleEnabled(bool enabled);
333 bool GetMultiSampleEnabled() const { return _multiSampleEnabled; }
334
335protected:
336 // ---------------------------------------------------------------------- //
337 // Camera and framing state
338 // ---------------------------------------------------------------------- //
339 HdCamera const *_camera;
340 GfVec4f _viewport;
341 CameraUtilFraming _framing;
342 std::optional<CameraUtilConformWindowPolicy> _overrideWindowPolicy;
343
344 // ---------------------------------------------------------------------- //
345 // Application rendering state
346 // ---------------------------------------------------------------------- //
347 GfVec4f _overrideColor;
348 GfVec4f _wireframeColor;
349 GfVec4f _pointColor;
350 float _pointSize;
351 bool _lightingEnabled;
352 bool _clippingEnabled;
353
354 GfVec4f _maskColor;
355 GfVec4f _indicatorColor;
356 float _pointSelectedSize;
357
358 // ---------------------------------------------------------------------- //
359 // Render pipeline state
360 // ---------------------------------------------------------------------- //
361 float _alphaThreshold;
362 float _tessLevel;
363 GfVec2f _drawRange;
364
365 bool _depthBiasUseDefault; // inherit existing state, ignore values below.
366 bool _depthBiasEnabled;
367 float _depthBiasConstantFactor;
368 float _depthBiasSlopeFactor;
369 HdCompareFunction _depthFunc;
370 bool _depthMaskEnabled;
371 bool _depthTestEnabled;
372 bool _depthClampEnabled;
373 GfVec2f _depthRange;
374
375 HdCullStyle _cullStyle;
376
377 // Stencil RenderPassState
378 HdCompareFunction _stencilFunc;
379 int _stencilRef;
380 int _stencilMask;
381 HdStencilOp _stencilFailOp;
382 HdStencilOp _stencilZFailOp;
383 HdStencilOp _stencilZPassOp;
384 bool _stencilEnabled;
385
386 // Line width
387 float _lineWidth;
388
389 // Blending
390 HdBlendOp _blendColorOp;
391 HdBlendFactor _blendColorSrcFactor;
392 HdBlendFactor _blendColorDstFactor;
393 HdBlendOp _blendAlphaOp;
394 HdBlendFactor _blendAlphaSrcFactor;
395 HdBlendFactor _blendAlphaDstFactor;
396 GfVec4f _blendConstantColor;
397 bool _blendEnabled;
398
399 // alpha to coverage
400 bool _alphaToCoverageEnabled;
401
402 bool _colorMaskUseDefault;
403 std::vector<ColorMask> _colorMasks;
404
405 HdRenderPassAovBindingVector _aovBindings;
406 HdRenderPassAovBindingVector _aovInputBindings;
407 bool _useMultiSampleAov;
408
409 bool _conservativeRasterizationEnabled;
410
411 float _stepSize;
412 float _stepSizeLighting;
413
414 bool _multiSampleEnabled;
415};
416
417PXR_NAMESPACE_CLOSE_SCOPE
418
419#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:87
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 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.
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...