Loading...
Searching...
No Matches
renderPassState.h
1//
2// Copyright 2016 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 PXR_IMAGING_HD_RENDER_PASS_STATE_H
25#define PXR_IMAGING_HD_RENDER_PASS_STATE_H
26
27#include "pxr/pxr.h"
28#include "pxr/imaging/hd/api.h"
29#include "pxr/imaging/hd/aov.h"
30#include "pxr/imaging/hd/version.h"
31#include "pxr/imaging/hd/enums.h"
32
33#include "pxr/imaging/cameraUtil/framing.h"
34
35#include "pxr/usd/sdf/path.h"
36
37#include "pxr/base/tf/token.h"
38#include "pxr/base/vt/value.h"
40#include "pxr/base/gf/vec2f.h"
41#include "pxr/base/gf/vec4d.h"
42#include "pxr/base/gf/vec4f.h"
43
44#include <memory>
45
46#include <optional>
47
48PXR_NAMESPACE_OPEN_SCOPE
49
50
51using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
52using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
53
54class HdCamera;
55
63{
64public:
65 HD_API
67 HD_API
68 virtual ~HdRenderPassState();
69
74 HD_API
75 virtual void Prepare(HdResourceRegistrySharedPtr const &resourceRegistry);
76
77 // ---------------------------------------------------------------------- //
79 // ---------------------------------------------------------------------- //
80
81 using ClipPlanesVector = std::vector<GfVec4d>;
82
84 HD_API
85 void SetCamera(const HdCamera *camera);
86
91 HD_API
93 const std::optional<CameraUtilConformWindowPolicy> &
94 overrideWindowPolicy);
95
98 HD_API
99 void SetFraming(const CameraUtilFraming &framing);
100
105 HD_API
106 void SetViewport(const GfVec4d &viewport);
107
109 HdCamera const *
110 GetCamera() const { return _camera; }
111
114 const CameraUtilFraming &
115 GetFraming() const { return _framing; }
116
119 const std::optional<CameraUtilConformWindowPolicy> &
120 GetOverrideWindowPolicy() const { return _overrideWindowPolicy; }
121
125 HD_API
126 CameraUtilConformWindowPolicy
128
133 HD_API
135
138 HD_API
140
144 GfVec4f const & GetViewport() const { return _viewport; }
145
150 HD_API
152
155 HD_API
156 virtual ClipPlanesVector const & GetClipPlanes() const;
157
158 // ---------------------------------------------------------------------- //
160 // ---------------------------------------------------------------------- //
161
164 HD_API
165 void SetOverrideColor(GfVec4f const &color);
166 const GfVec4f& GetOverrideColor() const { return _overrideColor; }
167
170 HD_API
171 void SetWireframeColor(GfVec4f const &color);
172 const GfVec4f& GetWireframeColor() const { return _wireframeColor; }
173
174 HD_API
175 void SetMaskColor(GfVec4f const &color);
176 const GfVec4f& GetMaskColor() const { return _maskColor; }
177
178 HD_API
179 void SetIndicatorColor(GfVec4f const &color);
180 const GfVec4f& GetIndicatorColor() const { return _indicatorColor; }
181
184 HD_API
185 void SetPointColor(GfVec4f const &color);
186 const GfVec4f& GetPointColor() const { return _pointColor; }
187
189 HD_API
190 void SetPointSize(float size);
191 float GetPointSize() const { return _pointSize; }
192
194 HD_API
195 void SetPointSelectedSize(float size);
196 float GetPointSelectedSize() const { return _pointSelectedSize; }
197
199 HD_API
200 void SetLightingEnabled(bool enabled);
201 bool GetLightingEnabled() const { return _lightingEnabled; }
202
203 HD_API
204 void SetClippingEnabled(bool enabled);
205 bool GetClippingEnabled() const { return _clippingEnabled; }
206
207 // ---------------------------------------------------------------------- //
209 // ---------------------------------------------------------------------- //
210
212 HD_API
213 void SetAovBindings(HdRenderPassAovBindingVector const &aovBindings);
214 HD_API
215 HdRenderPassAovBindingVector const& GetAovBindings() const;
216
218 HD_API
219 void SetAovInputBindings(HdRenderPassAovBindingVector const &aovBindings);
220 HD_API
221 HdRenderPassAovBindingVector const& GetAovInputBindings() const;
222
225 HD_API
226 void SetUseAovMultiSample(bool state);
227 HD_API
228 bool GetUseAovMultiSample() const;
229
230 HD_API
231 void SetCullStyle(HdCullStyle cullStyle);
232 HD_API
233 HdCullStyle GetCullStyle() const { return _cullStyle; }
234
235 HD_API
236 void SetAlphaThreshold(float alphaThreshold);
237 float GetAlphaThreshold() const { return _alphaThreshold; }
238
239 HD_API
240 void SetTessLevel(float level);
241 float GetTessLevel() const { return _tessLevel; }
242
243 HD_API
244 void SetDrawingRange(GfVec2f const &drawRange);
245 GfVec2f GetDrawingRange() const { return _drawRange; } // in pixel
246 HD_API
247 GfVec2f GetDrawingRangeNDC() const; // in ndc
248
249 HD_API
250 void SetDepthBiasUseDefault(bool useDefault);
251 bool GetDepthBiasUseDefault() const { return _depthBiasUseDefault; }
252
253 HD_API
254 void SetDepthBiasEnabled(bool enabled);
255 bool GetDepthBiasEnabled() const { return _depthBiasEnabled; }
256
257 HD_API
258 void SetDepthBias(float constantFactor, float slopeFactor);
259
260 HD_API
261 void SetDepthFunc(HdCompareFunction depthFunc);
262 HdCompareFunction GetDepthFunc() const { return _depthFunc; }
263
264 HD_API
265 void SetEnableDepthMask(bool state);
266 HD_API
267 bool GetEnableDepthMask() const;
268
269 HD_API
270 void SetEnableDepthTest(bool enabled);
271 HD_API
272 bool GetEnableDepthTest() const;
273
274 HD_API
275 void SetEnableDepthClamp(bool enabled);
276 HD_API
277 bool GetEnableDepthClamp() const;
278
279 HD_API
280 void SetDepthRange(GfVec2f const &depthRange);
281 HD_API
282 const GfVec2f& GetDepthRange() const;
283
284 HD_API
285 void SetStencil(HdCompareFunction func, int ref, int mask,
286 HdStencilOp fail, HdStencilOp zfail, HdStencilOp zpass);
287 HdCompareFunction GetStencilFunc() const { return _stencilFunc; }
288 int GetStencilRef() const { return _stencilRef; }
289 int GetStencilMask() const { return _stencilMask; }
290 HdStencilOp GetStencilFailOp() const { return _stencilFailOp; }
291 HdStencilOp GetStencilDepthFailOp() const { return _stencilZFailOp; }
292 HdStencilOp GetStencilDepthPassOp() const { return _stencilZPassOp; }
293 HD_API
294 void SetStencilEnabled(bool enabled);
295 HD_API
296 bool GetStencilEnabled() const;
297
298 HD_API
299 void SetLineWidth(float width);
300 float GetLineWidth() const { return _lineWidth; }
301
302 HD_API
303 void SetBlend(HdBlendOp colorOp,
304 HdBlendFactor colorSrcFactor,
305 HdBlendFactor colorDstFactor,
306 HdBlendOp alphaOp,
307 HdBlendFactor alphaSrcFactor,
308 HdBlendFactor alphaDstFactor);
309 HdBlendOp GetBlendColorOp() { return _blendColorOp; }
310 HdBlendFactor GetBlendColorSrcFactor() { return _blendColorSrcFactor; }
311 HdBlendFactor GetBlendColorDstFactor() { return _blendColorDstFactor; }
312 HdBlendOp GetBlendAlphaOp() { return _blendAlphaOp; }
313 HdBlendFactor GetBlendAlphaSrcFactor() { return _blendAlphaSrcFactor; }
314 HdBlendFactor GetBlendAlphaDstFactor() { return _blendAlphaDstFactor; }
315 HD_API
316 void SetBlendConstantColor(GfVec4f const & color);
317 const GfVec4f& GetBlendConstantColor() const { return _blendConstantColor; }
318 HD_API
319 void SetBlendEnabled(bool enabled);
320
321 HD_API
322 void SetAlphaToCoverageEnabled(bool enabled);
323 bool GetAlphaToCoverageEnabled() const { return _alphaToCoverageEnabled; }
324
325 HD_API
326 void SetColorMaskUseDefault(bool useDefault);
327 bool GetColorMaskUseDefault() const { return _colorMaskUseDefault;}
328
329 HD_API
330 void SetConservativeRasterizationEnabled(bool enabled);
331 bool GetConservativeRasterizationEnabled() const {
332 return _conservativeRasterizationEnabled;
333 }
334
335 HD_API
336 void SetVolumeRenderingConstants(float stepSize, float stepSizeLighting);
337
338 enum ColorMask {
339 ColorMaskNone,
340 ColorMaskRGB,
341 ColorMaskRGBA
342 };
343
344 HD_API
345 void SetColorMasks(std::vector<ColorMask> const& masks);
346 std::vector<ColorMask> const& GetColorMasks() const { return _colorMasks; }
347
348 HD_API
349 void SetMultiSampleEnabled(bool enabled);
350 bool GetMultiSampleEnabled() const { return _multiSampleEnabled; }
351
352protected:
353 // ---------------------------------------------------------------------- //
354 // Camera and framing state
355 // ---------------------------------------------------------------------- //
356 HdCamera const *_camera;
357 GfVec4f _viewport;
358 CameraUtilFraming _framing;
359 std::optional<CameraUtilConformWindowPolicy> _overrideWindowPolicy;
360
361 // ---------------------------------------------------------------------- //
362 // Application rendering state
363 // ---------------------------------------------------------------------- //
364 GfVec4f _overrideColor;
365 GfVec4f _wireframeColor;
366 GfVec4f _pointColor;
367 float _pointSize;
368 bool _lightingEnabled;
369 bool _clippingEnabled;
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:80
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
Basic type for a vector of 2 float components.
Definition: vec2f.h:63
Basic type for a vector of 4 double components.
Definition: vec4d.h:63
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
Hydra schema for a camera that pulls the params (see above) during Sync.
Definition: camera.h:104
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...