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
46PXR_NAMESPACE_OPEN_SCOPE
47
48
49using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
50using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
51
52class HdCamera;
53
61{
62public:
63 HD_API
65 HD_API
66 virtual ~HdRenderPassState();
67
72 HD_API
73 virtual void Prepare(HdResourceRegistrySharedPtr const &resourceRegistry);
74
75 // ---------------------------------------------------------------------- //
77 // ---------------------------------------------------------------------- //
78
79 using ClipPlanesVector = std::vector<GfVec4d>;
80
82 HD_API
83 void SetCamera(const HdCamera *camera);
84
92 HD_API
94 const std::pair<bool, CameraUtilConformWindowPolicy> &
95 overrideWindowPolicy);
96
99 HD_API
100 void SetFraming(const CameraUtilFraming &framing);
101
106 HD_API
107 void SetViewport(const GfVec4d &viewport);
108
113 HD_API
115 const HdCamera *camera,
116 const CameraUtilFraming &framing,
117 const std::pair<bool, CameraUtilConformWindowPolicy> &
118 overrideWindowPolicy);
119
124 HD_API
125 void SetCameraAndViewport(const HdCamera *camera,
126 const GfVec4d &viewport);
127
129 HdCamera const *
130 GetCamera() const { return _camera; }
131
134 const CameraUtilFraming &
135 GetFraming() const { return _framing; }
136
139 const std::pair<bool, CameraUtilConformWindowPolicy> &
140 GetOverrideWindowPolicy() const { return _overrideWindowPolicy; }
141
145 HD_API
146 CameraUtilConformWindowPolicy
148
153 HD_API
155
158 HD_API
160
164 GfVec4f const & GetViewport() const { return _viewport; }
165
170 HD_API
172
175 HD_API
176 virtual ClipPlanesVector const & GetClipPlanes() const;
177
178 // ---------------------------------------------------------------------- //
180 // ---------------------------------------------------------------------- //
181
184 HD_API
185 void SetOverrideColor(GfVec4f const &color);
186 const GfVec4f& GetOverrideColor() const { return _overrideColor; }
187
190 HD_API
191 void SetWireframeColor(GfVec4f const &color);
192 const GfVec4f& GetWireframeColor() const { return _wireframeColor; }
193
194 HD_API
195 void SetMaskColor(GfVec4f const &color);
196 const GfVec4f& GetMaskColor() const { return _maskColor; }
197
198 HD_API
199 void SetIndicatorColor(GfVec4f const &color);
200 const GfVec4f& GetIndicatorColor() const { return _indicatorColor; }
201
204 HD_API
205 void SetPointColor(GfVec4f const &color);
206 const GfVec4f& GetPointColor() const { return _pointColor; }
207
209 HD_API
210 void SetPointSize(float size);
211 float GetPointSize() const { return _pointSize; }
212
214 HD_API
215 void SetPointSelectedSize(float size);
216 float GetPointSelectedSize() const { return _pointSelectedSize; }
217
219 HD_API
220 void SetLightingEnabled(bool enabled);
221 bool GetLightingEnabled() const { return _lightingEnabled; }
222
223 HD_API
224 void SetClippingEnabled(bool enabled);
225 bool GetClippingEnabled() const { return _clippingEnabled; }
226
227 // ---------------------------------------------------------------------- //
229 // ---------------------------------------------------------------------- //
230
232 HD_API
233 void SetAovBindings(HdRenderPassAovBindingVector const &aovBindings);
234 HD_API
235 HdRenderPassAovBindingVector const& GetAovBindings() const;
236
238 HD_API
239 void SetAovInputBindings(HdRenderPassAovBindingVector const &aovBindings);
240 HD_API
241 HdRenderPassAovBindingVector const& GetAovInputBindings() const;
242
245 HD_API
246 void SetUseAovMultiSample(bool state);
247 HD_API
248 bool GetUseAovMultiSample() const;
249
250 HD_API
251 void SetCullStyle(HdCullStyle cullStyle);
252 HD_API
253 HdCullStyle GetCullStyle() const { return _cullStyle; }
254
255 HD_API
256 void SetAlphaThreshold(float alphaThreshold);
257 float GetAlphaThreshold() const { return _alphaThreshold; }
258
259 HD_API
260 void SetTessLevel(float level);
261 float GetTessLevel() const { return _tessLevel; }
262
263 HD_API
264 void SetDrawingRange(GfVec2f const &drawRange);
265 GfVec2f GetDrawingRange() const { return _drawRange; } // in pixel
266 HD_API
267 GfVec2f GetDrawingRangeNDC() const; // in ndc
268
269 HD_API
270 void SetDepthBiasUseDefault(bool useDefault);
271 bool GetDepthBiasUseDefault() const { return _depthBiasUseDefault; }
272
273 HD_API
274 void SetDepthBiasEnabled(bool enabled);
275 bool GetDepthBiasEnabled() const { return _depthBiasEnabled; }
276
277 HD_API
278 void SetDepthBias(float constantFactor, float slopeFactor);
279
280 HD_API
281 void SetDepthFunc(HdCompareFunction depthFunc);
282 HdCompareFunction GetDepthFunc() const { return _depthFunc; }
283
284 HD_API
285 void SetEnableDepthMask(bool state);
286 HD_API
287 bool GetEnableDepthMask() const;
288
289 HD_API
290 void SetEnableDepthTest(bool enabled);
291 HD_API
292 bool GetEnableDepthTest() const;
293
294 HD_API
295 void SetEnableDepthClamp(bool enabled);
296 HD_API
297 bool GetEnableDepthClamp() const;
298
299 HD_API
300 void SetDepthRange(GfVec2f const &depthRange);
301 HD_API
302 const GfVec2f& GetDepthRange() const;
303
304 HD_API
305 void SetStencil(HdCompareFunction func, int ref, int mask,
306 HdStencilOp fail, HdStencilOp zfail, HdStencilOp zpass);
307 HdCompareFunction GetStencilFunc() const { return _stencilFunc; }
308 int GetStencilRef() const { return _stencilRef; }
309 int GetStencilMask() const { return _stencilMask; }
310 HdStencilOp GetStencilFailOp() const { return _stencilFailOp; }
311 HdStencilOp GetStencilDepthFailOp() const { return _stencilZFailOp; }
312 HdStencilOp GetStencilDepthPassOp() const { return _stencilZPassOp; }
313 HD_API
314 void SetStencilEnabled(bool enabled);
315 HD_API
316 bool GetStencilEnabled() const;
317
318 HD_API
319 void SetLineWidth(float width);
320 float GetLineWidth() const { return _lineWidth; }
321
322 HD_API
323 void SetBlend(HdBlendOp colorOp,
324 HdBlendFactor colorSrcFactor,
325 HdBlendFactor colorDstFactor,
326 HdBlendOp alphaOp,
327 HdBlendFactor alphaSrcFactor,
328 HdBlendFactor alphaDstFactor);
329 HdBlendOp GetBlendColorOp() { return _blendColorOp; }
330 HdBlendFactor GetBlendColorSrcFactor() { return _blendColorSrcFactor; }
331 HdBlendFactor GetBlendColorDstFactor() { return _blendColorDstFactor; }
332 HdBlendOp GetBlendAlphaOp() { return _blendAlphaOp; }
333 HdBlendFactor GetBlendAlphaSrcFactor() { return _blendAlphaSrcFactor; }
334 HdBlendFactor GetBlendAlphaDstFactor() { return _blendAlphaDstFactor; }
335 HD_API
336 void SetBlendConstantColor(GfVec4f const & color);
337 const GfVec4f& GetBlendConstantColor() const { return _blendConstantColor; }
338 HD_API
339 void SetBlendEnabled(bool enabled);
340
341 HD_API
342 void SetAlphaToCoverageEnabled(bool enabled);
343 bool GetAlphaToCoverageEnabled() const { return _alphaToCoverageEnabled; }
344
345 HD_API
346 void SetColorMaskUseDefault(bool useDefault);
347 bool GetColorMaskUseDefault() const { return _colorMaskUseDefault;}
348
349 HD_API
350 void SetConservativeRasterizationEnabled(bool enabled);
351 bool GetConservativeRasterizationEnabled() const {
352 return _conservativeRasterizationEnabled;
353 }
354
355 HD_API
356 void SetVolumeRenderingConstants(float stepSize, float stepSizeLighting);
357
358 enum ColorMask {
359 ColorMaskNone,
360 ColorMaskRGB,
361 ColorMaskRGBA
362 };
363
364 HD_API
365 void SetColorMasks(std::vector<ColorMask> const& masks);
366 std::vector<ColorMask> const& GetColorMasks() const { return _colorMasks; }
367
368 HD_API
369 void SetMultiSampleEnabled(bool enabled);
370 bool GetMultiSampleEnabled() const { return _multiSampleEnabled; }
371
372protected:
373 // ---------------------------------------------------------------------- //
374 // Camera and framing state
375 // ---------------------------------------------------------------------- //
376 HdCamera const *_camera;
377 GfVec4f _viewport;
378 CameraUtilFraming _framing;
379 std::pair<bool, CameraUtilConformWindowPolicy> _overrideWindowPolicy;
380
381 // ---------------------------------------------------------------------- //
382 // Application rendering state
383 // ---------------------------------------------------------------------- //
384 GfVec4f _overrideColor;
385 GfVec4f _wireframeColor;
386 GfVec4f _pointColor;
387 float _pointSize;
388 bool _lightingEnabled;
389 bool _clippingEnabled;
390
391 GfVec4f _maskColor;
392 GfVec4f _indicatorColor;
393 float _pointSelectedSize;
394
395 // ---------------------------------------------------------------------- //
396 // Render pipeline state
397 // ---------------------------------------------------------------------- //
398 float _alphaThreshold;
399 float _tessLevel;
400 GfVec2f _drawRange;
401
402 bool _depthBiasUseDefault; // inherit existing state, ignore values below.
403 bool _depthBiasEnabled;
404 float _depthBiasConstantFactor;
405 float _depthBiasSlopeFactor;
406 HdCompareFunction _depthFunc;
407 bool _depthMaskEnabled;
408 bool _depthTestEnabled;
409 bool _depthClampEnabled;
410 GfVec2f _depthRange;
411
412 HdCullStyle _cullStyle;
413
414 // Stencil RenderPassState
415 HdCompareFunction _stencilFunc;
416 int _stencilRef;
417 int _stencilMask;
418 HdStencilOp _stencilFailOp;
419 HdStencilOp _stencilZFailOp;
420 HdStencilOp _stencilZPassOp;
421 bool _stencilEnabled;
422
423 // Line width
424 float _lineWidth;
425
426 // Blending
427 HdBlendOp _blendColorOp;
428 HdBlendFactor _blendColorSrcFactor;
429 HdBlendFactor _blendColorDstFactor;
430 HdBlendOp _blendAlphaOp;
431 HdBlendFactor _blendAlphaSrcFactor;
432 HdBlendFactor _blendAlphaDstFactor;
433 GfVec4f _blendConstantColor;
434 bool _blendEnabled;
435
436 // alpha to coverage
437 bool _alphaToCoverageEnabled;
438
439 bool _colorMaskUseDefault;
440 std::vector<ColorMask> _colorMasks;
441
442 HdRenderPassAovBindingVector _aovBindings;
443 HdRenderPassAovBindingVector _aovInputBindings;
444 bool _useMultiSampleAov;
445
446 bool _conservativeRasterizationEnabled;
447
448 float _stepSize;
449 float _stepSizeLighting;
450
451 bool _multiSampleEnabled;
452};
453
454PXR_NAMESPACE_CLOSE_SCOPE
455
456#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 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 SetCameraAndFraming(const HdCamera *camera, const CameraUtilFraming &framing, const std::pair< bool, CameraUtilConformWindowPolicy > &overrideWindowPolicy)
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::pair< bool, 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.
HD_API void SetOverrideWindowPolicy(const std::pair< bool, CameraUtilConformWindowPolicy > &overrideWindowPolicy)
Sets whether to override the window policy used to conform the camera if its aspect ratio is not matc...
const CameraUtilFraming & GetFraming() const
Get framing information determining how the filmback plane maps to pixels.
HD_API void SetCameraAndViewport(const HdCamera *camera, const GfVec4d &viewport)
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...