Loading...
Searching...
No Matches
renderSettings.h
1//
2// Copyright 2022 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_SETTINGS_H
8#define PXR_IMAGING_HD_RENDER_SETTINGS_H
9
10#include "pxr/imaging/hd/api.h"
11#include "pxr/imaging/hd/bprim.h"
12#include "pxr/imaging/hd/types.h"
13
14#include "pxr/usd/sdf/path.h"
15
16#include "pxr/base/gf/range2f.h"
17#include "pxr/base/gf/vec2f.h"
18#include "pxr/base/gf/vec2i.h"
19#include "pxr/base/tf/token.h"
20#include "pxr/base/vt/array.h"
22#include "pxr/base/vt/value.h"
23
24#include "pxr/pxr.h"
25
26#include <cstddef>
27#include <ostream>
28#include <string>
29#include <vector>
30
31PXR_NAMESPACE_OPEN_SCOPE
32
59{
60public:
61 // Change tracking for HdRenderSettings.
62 enum DirtyBits : HdDirtyBits {
63 Clean = 0,
64 DirtyActive = 1 << 1,
65 DirtyNamespacedSettings = 1 << 2,
66 DirtyRenderProducts = 1 << 3,
67 DirtyIncludedPurposes = 1 << 4,
68 DirtyMaterialBindingPurposes = 1 << 5,
69 DirtyRenderingColorSpace = 1 << 6,
70 DirtyUnionedSamplingInterval = 1 << 7,
71 DirtyFrameNumber = 1 << 8,
72 DirtyCamera = 1 << 9,
73 DirtyDisableDepthOfField = 1 << 10,
74 DirtyDisableMotionBlur = 1 << 11,
75 AllDirty = DirtyActive
76 | DirtyNamespacedSettings
77 | DirtyRenderProducts
78 | DirtyIncludedPurposes
79 | DirtyMaterialBindingPurposes
80 | DirtyRenderingColorSpace
81 | DirtyUnionedSamplingInterval
82 | DirtyFrameNumber
83 | DirtyCamera
84 | DirtyDisableDepthOfField
85 | DirtyDisableMotionBlur
86 };
87
88 HD_API
89 static std::string
90 StringifyDirtyBits(HdDirtyBits dirtyBits);
91
92 // Parameters that may be queried and invalidated.
93 //
94 // \note This mirrors UsdRender except that the render products and vars
95 // are "flattened out" similar to UsdRenderSpec.
96 struct RenderProduct {
97 struct RenderVar {
98 SdfPath varPath;
99 TfToken dataType;
100 std::string sourceName;
101 TfToken sourceType;
102 VtDictionary namespacedSettings;
103 };
104
106 //
107 // Path to product prim in scene description.
108 SdfPath productPath;
109 // The type of product, ex: "raster".
110 TfToken type;
111 // The name of the product, which uniquely identifies it.
112 TfToken name;
113 // The pixel resolution of the product.
114 GfVec2i resolution = GfVec2i(0);
115 // The render vars that the product is comprised of.
116 std::vector<RenderVar> renderVars;
117
119 //
120 // Path to the camera to use for this product.
121 SdfPath cameraPath;
122 // The pixel aspect ratio as adjusted by aspectRatioConformPolicy.
123 float pixelAspectRatio;
124 // The policy that was applied to conform aspect ratio
125 // mismatches between the aperture and image.
126 TfToken aspectRatioConformPolicy;
127 // The camera aperture size as adjusted by aspectRatioConformPolicy.
128 GfVec2f apertureSize = GfVec2f(0);
129 // The data window, in NDC terms relative to the aperture.
130 // (0,0) corresponds to bottom-left and (1,1) corresponds to
131 // top-right. Note that the data window can partially cover
132 // or extend beyond the unit range, for representing overscan
133 // or cropped renders.
134 GfRange2f dataWindowNDC;
135
137 //
138 bool disableMotionBlur;
139 bool disableDepthOfField;
140 VtDictionary namespacedSettings;
141 };
142
143 using RenderProducts = std::vector<RenderProduct>;
145
146 HD_API
147 ~HdRenderSettings() override;
148
149 // ------------------------------------------------------------------------
150 // Public API
151 // ------------------------------------------------------------------------
152 HD_API
153 bool IsActive() const;
154
155 HD_API
156 bool IsValid() const;
157
158 HD_API
159 const NamespacedSettings& GetNamespacedSettings() const;
160
161 HD_API
162 const RenderProducts& GetRenderProducts() const;
163
164 HD_API
165 const VtArray<TfToken>& GetIncludedPurposes() const;
166
167 HD_API
168 const VtArray<TfToken>& GetMaterialBindingPurposes() const;
169
170 HD_API
171 const TfToken& GetRenderingColorSpace() const;
172
173 // XXX: Using VtValue in a std::optional (C++17) sense.
174 HD_API
175 const VtValue& GetUnionedSamplingInterval() const;
176
177 // XXX: Using VtValue in a std::optional (C++17) sense.
178 HD_API
179 const VtValue& GetCamera() const;
180
181 HD_API
182 bool GetDisableDepthOfField() const;
183
184 HD_API
185 bool GetDisableMotionBlur() const;
186
194 HD_API
196
197 // ------------------------------------------------------------------------
198 // Satisfying HdBprim
199 // ------------------------------------------------------------------------
200 HD_API
201 void
202 Sync(HdSceneDelegate *sceneDelegate,
203 HdRenderParam *renderParam,
204 HdDirtyBits *dirtyBits) final;
205
206 HD_API
207 HdDirtyBits
208 GetInitialDirtyBitsMask() const override;
209
210protected:
211 HD_API
212 HdRenderSettings(SdfPath const& id);
213
214 // ------------------------------------------------------------------------
215 // Virtual API
216 // ------------------------------------------------------------------------
217 // This is called during Sync after dirty processing and before clearing the
218 // dirty bits.
219 virtual void
220 _Sync(HdSceneDelegate *sceneDelegate,
221 HdRenderParam *renderParam,
222 const HdDirtyBits *dirtyBits);
223
224
225private:
226 // Class cannot be default constructed or copied.
227 HdRenderSettings() = delete;
228 HdRenderSettings(const HdRenderSettings &) = delete;
229 HdRenderSettings &operator =(const HdRenderSettings &) = delete;
230
231 bool _active;
232 bool _dirtyProducts;
233 NamespacedSettings _namespacedSettings;
234 RenderProducts _products;
235 VtArray<TfToken> _includedPurposes;
236 VtArray<TfToken> _materialBindingPurposes;
237 TfToken _renderingColorSpace;
238 VtValue _vUnionedSamplingInterval;
239 VtValue _vCamera;
240 bool _disableDepthOfField;
241 bool _disableMotionBlur;
242};
243
244// VtValue requirements
245HD_API
246size_t hash_value(HdRenderSettings::RenderProduct const &rp);
247
248HD_API
249std::ostream& operator<<(
250 std::ostream& out, const HdRenderSettings::RenderProduct&);
251
252HD_API
253bool operator==(const HdRenderSettings::RenderProduct& lhs,
254 const HdRenderSettings::RenderProduct& rhs);
255HD_API
256bool operator!=(const HdRenderSettings::RenderProduct& lhs,
257 const HdRenderSettings::RenderProduct& rhs);
258HD_API
259std::ostream& operator<<(
260 std::ostream& out, const HdRenderSettings::RenderProduct::RenderVar&);
261
262HD_API
263bool operator==(const HdRenderSettings::RenderProduct::RenderVar& lhs,
264 const HdRenderSettings::RenderProduct::RenderVar& rhs);
265HD_API
266bool operator!=(const HdRenderSettings::RenderProduct::RenderVar& lhs,
267 const HdRenderSettings::RenderProduct::RenderVar& rhs);
268
269
270PXR_NAMESPACE_CLOSE_SCOPE
271
272#endif // PXR_IMAGING_HD_RENDER_SETTINGS_H
Basic type: 2-dimensional floating point range.
Definition: range2f.h:47
Basic type for a vector of 2 float components.
Definition: vec2f.h:46
Basic type for a vector of 2 int components.
Definition: vec2i.h:44
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:40
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Hydra prim backing render settings scene description.
HD_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) final
Synchronizes state from the delegate to this object.
HD_API bool GetAndResetHasDirtyProducts()
Returns whether the render products were invalidated since the last time this function was called.
HD_API HdDirtyBits GetInitialDirtyBitsMask() const override
Returns the minimal set of dirty bits to place in the change tracker for use in the first sync of thi...
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:281
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:213
A map with string keys and VtValue values.
Definition: dictionary.h:52
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:90
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...