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/pxr.h"
11#include "pxr/imaging/hd/api.h"
12#include "pxr/imaging/hd/bprim.h"
13
14#include "pxr/base/vt/array.h"
16#include "pxr/base/gf/vec2i.h"
17#include "pxr/base/gf/vec2f.h"
18#include "pxr/base/gf/vec2d.h"
19#include "pxr/base/gf/range2f.h"
20
21#include <vector>
22
23PXR_NAMESPACE_OPEN_SCOPE
24
51{
52public:
53 // Change tracking for HdRenderSettings.
54 enum DirtyBits : HdDirtyBits {
55 Clean = 0,
56 DirtyActive = 1 << 1,
57 DirtyNamespacedSettings = 1 << 2,
58 DirtyRenderProducts = 1 << 3,
59 DirtyIncludedPurposes = 1 << 4,
60 DirtyMaterialBindingPurposes = 1 << 5,
61 DirtyRenderingColorSpace = 1 << 6,
62 DirtyShutterInterval = 1 << 7,
63 DirtyFrameNumber = 1 << 8,
64 AllDirty = DirtyActive
65 | DirtyNamespacedSettings
66 | DirtyRenderProducts
67 | DirtyIncludedPurposes
68 | DirtyMaterialBindingPurposes
69 | DirtyRenderingColorSpace
70 | DirtyShutterInterval
71 | DirtyFrameNumber
72 };
73
74 // Parameters that may be queried and invalidated.
75 //
76 // \note This mirrors UsdRender except that the render products and vars
77 // are "flattened out" similar to UsdRenderSpec.
78 struct RenderProduct {
79 struct RenderVar {
80 SdfPath varPath;
81 TfToken dataType;
82 std::string sourceName;
83 TfToken sourceType;
84 VtDictionary namespacedSettings;
85 };
86
88 //
89 // Path to product prim in scene description.
90 SdfPath productPath;
91 // The type of product, ex: "raster".
92 TfToken type;
93 // The name of the product, which uniquely identifies it.
94 TfToken name;
95 // The pixel resolution of the product.
96 GfVec2i resolution = GfVec2i(0);
97 // The render vars that the product is comprised of.
98 std::vector<RenderVar> renderVars;
99
101 //
102 // Path to the camera to use for this product.
103 SdfPath cameraPath;
104 // The pixel aspect ratio as adjusted by aspectRatioConformPolicy.
105 float pixelAspectRatio;
106 // The policy that was applied to conform aspect ratio
107 // mismatches between the aperture and image.
108 TfToken aspectRatioConformPolicy;
109 // The camera aperture size as adjusted by aspectRatioConformPolicy.
110 GfVec2f apertureSize = GfVec2f(0);
111 // The data window, in NDC terms relative to the aperture.
112 // (0,0) corresponds to bottom-left and (1,1) corresponds to
113 // top-right. Note that the data window can partially cover
114 // or extend beyond the unit range, for representing overscan
115 // or cropped renders.
116 GfRange2f dataWindowNDC;
117
119 //
120 bool disableMotionBlur;
121 bool disableDepthOfField;
122 VtDictionary namespacedSettings;
123 };
124
125 using RenderProducts = std::vector<RenderProduct>;
127
128 HD_API
129 ~HdRenderSettings() override;
130
131 // ------------------------------------------------------------------------
132 // Public API
133 // ------------------------------------------------------------------------
134 HD_API
135 bool IsActive() const;
136
137 HD_API
138 bool IsValid() const;
139
140 HD_API
141 const NamespacedSettings& GetNamespacedSettings() const;
142
143 HD_API
144 const RenderProducts& GetRenderProducts() const;
145
146 HD_API
147 const VtArray<TfToken>& GetIncludedPurposes() const;
148
149 HD_API
150 const VtArray<TfToken>& GetMaterialBindingPurposes() const;
151
152 HD_API
153 const TfToken& GetRenderingColorSpace() const;
154
155 // XXX Using VtValue in a std::optional (C++17) sense.
156 HD_API
157 const VtValue& GetShutterInterval() const;
158
159 // ------------------------------------------------------------------------
160 // Satisfying HdBprim
161 // ------------------------------------------------------------------------
162 HD_API
163 void
164 Sync(HdSceneDelegate *sceneDelegate,
165 HdRenderParam *renderParam,
166 HdDirtyBits *dirtyBits) override final;
167
168 HD_API
169 HdDirtyBits
170 GetInitialDirtyBitsMask() const override;
171
172protected:
173 HD_API
174 HdRenderSettings(SdfPath const& id);
175
176 // ------------------------------------------------------------------------
177 // Virtual API
178 // ------------------------------------------------------------------------
179 // This is called during Sync after dirty processing and before clearing the
180 // dirty bits.
181 virtual void
182 _Sync(HdSceneDelegate *sceneDelegate,
183 HdRenderParam *renderParam,
184 const HdDirtyBits *dirtyBits);
185
186
187private:
188 // Class cannot be default constructed or copied.
189 HdRenderSettings() = delete;
190 HdRenderSettings(const HdRenderSettings &) = delete;
191 HdRenderSettings &operator =(const HdRenderSettings &) = delete;
192
193 bool _active;
194 NamespacedSettings _namespacedSettings;
195 RenderProducts _products;
196 VtArray<TfToken> _includedPurposes;
197 VtArray<TfToken> _materialBindingPurposes;
198 TfToken _renderingColorSpace;
199 VtValue _vShutterInterval;
200};
201
202// VtValue requirements
203HD_API
204size_t hash_value(HdRenderSettings::RenderProduct const &rp);
205
206HD_API
207std::ostream& operator<<(
208 std::ostream& out, const HdRenderSettings::RenderProduct&);
209
210HD_API
211bool operator==(const HdRenderSettings::RenderProduct& lhs,
212 const HdRenderSettings::RenderProduct& rhs);
213HD_API
214bool operator!=(const HdRenderSettings::RenderProduct& lhs,
215 const HdRenderSettings::RenderProduct& rhs);
216HD_API
217std::ostream& operator<<(
218 std::ostream& out, const HdRenderSettings::RenderProduct::RenderVar&);
219
220HD_API
221bool operator==(const HdRenderSettings::RenderProduct::RenderVar& lhs,
222 const HdRenderSettings::RenderProduct::RenderVar& rhs);
223HD_API
224bool operator!=(const HdRenderSettings::RenderProduct::RenderVar& lhs,
225 const HdRenderSettings::RenderProduct::RenderVar& rhs);
226
227
228PXR_NAMESPACE_CLOSE_SCOPE
229
230#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 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...
HD_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override final
Synchronizes state from the delegate to this object.
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:211
A map with string keys and VtValue values.
Definition: dictionary.h:43
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].