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