HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pass.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef USDRENDER_GENERATED_PASS_H
8 #define USDRENDER_GENERATED_PASS_H
9 
10 /// \file usdRender/pass.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdRender/api.h"
14 #include "pxr/usd/usd/typed.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
18 
20 
21 #include "pxr/base/vt/value.h"
22 
23 #include "pxr/base/gf/vec3d.h"
24 #include "pxr/base/gf/vec3f.h"
25 #include "pxr/base/gf/matrix4d.h"
26 
27 #include "pxr/base/tf/token.h"
28 #include "pxr/base/tf/type.h"
29 
31 
32 class SdfAssetPath;
33 
34 // -------------------------------------------------------------------------- //
35 // RENDERPASS //
36 // -------------------------------------------------------------------------- //
37 
38 /// \class UsdRenderPass
39 ///
40 /// A RenderPass prim encapsulates necessary information
41 /// to generate multi-pass renders. In a multi-pass render, multiple
42 /// invocations ("passes") of the rendering process are used to
43 /// generate products using potentially distinct configurations of the
44 /// stage and renderer.
45 ///
46 /// UsdRenderPass houses properties for generating dependencies and
47 /// the necessary commands to run to generate renders, as well as
48 /// visibility and pruning controls for the scene.
49 ///
50 /// Whereas UsdRenderSettings describes information about the rendering
51 /// process itself (such as path-tracing parameters), UsdRenderPass
52 /// describes information to configure the scene contents and to
53 /// invoke the renderer as part of a render job that produces a
54 /// time-varying sequence of images.
55 ///
56 /// There are two consumers of RenderPass prims - a runtime executable that
57 /// generates images from usdRender prims, and pipeline specific code that
58 /// translates between usdRender prims and the pipeline's resource scheduling
59 /// software. We'll refer to the latter as 'job submission code'.
60 ///
61 /// The name of the prim is used as the pass's name.
62 ///
63 /// \anchor usdRender_renderVisibility
64 /// The set of objects visible in the render is specified via the
65 /// renderVisibility collection (UsdCollectionAPI), which can be accessed via
66 /// GetRenderVisibilityCollectionAPI(). This collection has includeRoot set to
67 /// true so that all objects participate in the render by default. To render
68 /// only a specific set of objects, there are two options. One is to modify the
69 /// collection paths to explicitly exclude objects that don't participate in
70 /// the render, assuming it is known; the other option is to set includeRoot to
71 /// false and explicitly include the desired objects. These are complementary
72 /// approaches that may each be preferable depending on the scenario.
73 ///
74 /// In addition, UsdCollectionAPI offers a membershipExpression attribute
75 /// providing a pattern-based description of the collection. To use
76 /// membershipExpression, includeRoot should be overridden to false.
77 ///
78 /// Note that prims for which UsdGeomImageable::ComputeEffectiveVisibility()
79 /// returns "invisible" cannot be overridden back to a visible state
80 /// via renderVisibility. Conceptually, render passes may be used to
81 /// partition scene contents across multiple images rendered from the
82 /// scene; they are not intended to restore parts of the scene that
83 /// had been marked invisible.
84 ///
85 /// In addition, renderVisibility only applies to renderable contents
86 /// of the scene itself, such as geometry and lights; it does not apply
87 /// to objects associated with the render settings, such as image
88 /// post-processing filters, even when UsdGeomVisibilityAPI may apply.
89 ///
90 /// \anchor usd_cameraVisibility
91 /// The cameraVisibility collection defines which scene objects should
92 /// be directly visible in camera. Objects that are not in this
93 /// collection should still participate in other light paths such
94 /// as shadowing, reflections, and refraction. By default everything in
95 /// the scene should be visible to camera, so this collection sets
96 /// includeRoot to 1.
97 ///
98 /// \anchor usd_matte
99 /// The matte collection defines scene objects that should act as
100 /// matte objects. Matte objects render with zero alpha. By
101 /// default, everything in the scene should render normally, so
102 /// this collection sets includeRoot to 0.
103 ///
104 /// \anchor usdRender_pruning
105 /// The prune collection specifies a collection of objects to be removed
106 /// ("pruned") from the scene prior to rendering. Whereas visibility
107 /// may be implemented by the renderer as a lightweight attribute
108 /// that is relatively cheap to toggle during interactive workflows,
109 /// pruning entirely removes the objects from the renderer's
110 /// extracted representation of the scene. This can provide a greater
111 /// runtime cost savings for batch rendering, with the tradeoff that
112 /// interactively modifying the prune collection is likely to be more
113 /// expensive than toggling visibility. In addition, some renderers
114 /// may not support visibility of certain kinds of scene objects or in
115 /// certain conditions; in these cases, pruning offers a guaranteed way
116 /// to remove such objects from the scene.
117 ///
118 ///
119 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
120 /// that are text/tokens, the actual token is published and defined in \ref UsdRenderTokens.
121 /// So to set an attribute to the value "rightHanded", use UsdRenderTokens->rightHanded
122 /// as the value.
123 ///
124 class UsdRenderPass : public UsdTyped
125 {
126 public:
127  /// Compile time constant representing what kind of schema this class is.
128  ///
129  /// \sa UsdSchemaKind
131 
132  /// Construct a UsdRenderPass on UsdPrim \p prim .
133  /// Equivalent to UsdRenderPass::Get(prim.GetStage(), prim.GetPath())
134  /// for a \em valid \p prim, but will not immediately throw an error for
135  /// an invalid \p prim
136  explicit UsdRenderPass(const UsdPrim& prim=UsdPrim())
137  : UsdTyped(prim)
138  {
139  }
140 
141  /// Construct a UsdRenderPass on the prim held by \p schemaObj .
142  /// Should be preferred over UsdRenderPass(schemaObj.GetPrim()),
143  /// as it preserves SchemaBase state.
144  explicit UsdRenderPass(const UsdSchemaBase& schemaObj)
145  : UsdTyped(schemaObj)
146  {
147  }
148 
149  /// Destructor.
151  virtual ~UsdRenderPass();
152 
153  /// Return a vector of names of all pre-declared attributes for this schema
154  /// class and all its ancestor classes. Does not include attributes that
155  /// may be authored by custom/extended methods of the schemas involved.
157  static const TfTokenVector &
158  GetSchemaAttributeNames(bool includeInherited=true);
159 
160  /// Return a UsdRenderPass holding the prim adhering to this
161  /// schema at \p path on \p stage. If no prim exists at \p path on
162  /// \p stage, or if the prim at that path does not adhere to this schema,
163  /// return an invalid schema object. This is shorthand for the following:
164  ///
165  /// \code
166  /// UsdRenderPass(stage->GetPrimAtPath(path));
167  /// \endcode
168  ///
170  static UsdRenderPass
171  Get(const UsdStagePtr &stage, const SdfPath &path);
172 
173  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
174  /// is defined (according to UsdPrim::IsDefined()) on this stage.
175  ///
176  /// If a prim adhering to this schema at \p path is already defined on this
177  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
178  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
179  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
180  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
181  /// current EditTarget for any nonexistent, or existing but not \a Defined
182  /// ancestors.
183  ///
184  /// The given \a path must be an absolute prim path that does not contain
185  /// any variant selections.
186  ///
187  /// If it is impossible to author any of the necessary PrimSpecs, (for
188  /// example, in case \a path cannot map to the current UsdEditTarget's
189  /// namespace) issue an error and return an invalid \a UsdPrim.
190  ///
191  /// Note that this method may return a defined prim whose typeName does not
192  /// specify this schema class, in case a stronger typeName opinion overrides
193  /// the opinion at the current EditTarget.
194  ///
196  static UsdRenderPass
197  Define(const UsdStagePtr &stage, const SdfPath &path);
198 
199 protected:
200  /// Returns the kind of schema this class belongs to.
201  ///
202  /// \sa UsdSchemaKind
204  UsdSchemaKind _GetSchemaKind() const override;
205 
206 private:
207  // needs to invoke _GetStaticTfType.
208  friend class UsdSchemaRegistry;
210  static const TfType &_GetStaticTfType();
211 
212  static bool _IsTypedSchema();
213 
214  // override SchemaBase virtuals.
216  const TfType &_GetTfType() const override;
217 
218 public:
219  // --------------------------------------------------------------------- //
220  // PASSTYPE
221  // --------------------------------------------------------------------- //
222  /// A string used to categorize differently structured
223  /// or executed types of passes within a customized pipeline.
224  ///
225  /// For example, when multiple DCC's (e.g. Houdini, Katana, Nuke)
226  /// each compute and contribute different Products to a final result,
227  /// it may be clearest and most flexible to create a separate
228  /// RenderPass for each.
229  ///
230  ///
231  /// | ||
232  /// | -- | -- |
233  /// | Declaration | `uniform token passType` |
234  /// | C++ Type | TfToken |
235  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
236  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
239 
240  /// See GetPassTypeAttr(), and also
241  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
242  /// If specified, author \p defaultValue as the attribute's default,
243  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
244  /// the default for \p writeSparsely is \c false.
246  UsdAttribute CreatePassTypeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
247 
248 public:
249  // --------------------------------------------------------------------- //
250  // COMMAND
251  // --------------------------------------------------------------------- //
252  /// The command to run in order to generate
253  /// renders for this pass. The job submission code can use
254  /// this to properly send tasks to the job scheduling software
255  /// that will generate products.
256  ///
257  /// The command can contain variables that will be substituted
258  /// appropriately during submission, as seen in the example below
259  /// with {fileName}.
260  ///
261  /// For example:
262  /// command[0] = "prman"
263  /// command[1] = "-progress"
264  /// command[2] = "-pixelvariance"
265  /// command[3] = "-0.15"
266  /// command[4] = "{fileName}" # the fileName property will be substituted
267  ///
268  ///
269  /// | ||
270  /// | -- | -- |
271  /// | Declaration | `uniform string[] command` |
272  /// | C++ Type | VtArray<std::string> |
273  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->StringArray |
274  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
277 
278  /// See GetCommandAttr(), and also
279  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
280  /// If specified, author \p defaultValue as the attribute's default,
281  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
282  /// the default for \p writeSparsely is \c false.
284  UsdAttribute CreateCommandAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
285 
286 public:
287  // --------------------------------------------------------------------- //
288  // FILENAME
289  // --------------------------------------------------------------------- //
290  /// The asset that contains the rendering prims or other
291  /// information needed to render this pass.
292  ///
293  ///
294  /// | ||
295  /// | -- | -- |
296  /// | Declaration | `uniform asset fileName` |
297  /// | C++ Type | SdfAssetPath |
298  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
299  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
302 
303  /// See GetFileNameAttr(), and also
304  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
305  /// If specified, author \p defaultValue as the attribute's default,
306  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
307  /// the default for \p writeSparsely is \c false.
309  UsdAttribute CreateFileNameAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
310 
311 public:
312  // --------------------------------------------------------------------- //
313  // RENDERSOURCE
314  // --------------------------------------------------------------------- //
315  /// The source prim to render from. If _fileName_ is not present,
316  /// the source is assumed to be a RenderSettings prim present in the current
317  /// Usd stage. If fileName is present, the source should be found in the
318  /// file there. This relationship might target a string attribute on this
319  /// or another prim that identifies the appropriate object in the external
320  /// container.
321  ///
322  /// For example, for a Usd-backed pass, this would point to a RenderSettings
323  /// prim. Houdini passes would point to a Rop. Nuke passes would point to
324  /// a write node.
325  ///
326  ///
329 
330  /// See GetRenderSourceRel(), and also
331  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
334 
335 public:
336  // --------------------------------------------------------------------- //
337  // INPUTPASSES
338  // --------------------------------------------------------------------- //
339  /// The set of other Passes that this Pass depends on
340  /// in order to be constructed properly. For example, a Pass A
341  /// may generate a texture, which is then used as an input to
342  /// Pass B.
343  ///
344  /// By default, usdRender makes some assumptions about the
345  /// relationship between this prim and the prims listed in inputPasses.
346  /// Namely, when per-frame tasks are generated from these pass prims,
347  /// usdRender will assume a one-to-one relationship between tasks
348  /// that share their frame number. Consider a pass named 'composite'
349  /// whose _inputPasses_ targets a Pass prim named 'beauty`.
350  /// By default, each frame for 'composite' will depend on the
351  /// same frame from 'beauty':
352  /// beauty.1 -> composite.1
353  /// beauty.2 -> composite.2
354  /// etc
355  ///
356  /// The consumer of this RenderPass graph of inputs will need to resolve
357  /// the transitive dependencies.
358  ///
359  ///
362 
363  /// See GetInputPassesRel(), and also
364  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
367 
368 public:
369  // ===================================================================== //
370  // Feel free to add custom code below this line, it will be preserved by
371  // the code generator.
372  //
373  // Just remember to:
374  // - Close the class declaration with };
375  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
376  // - Close the include guard with #endif
377  // ===================================================================== //
378  // --(BEGIN CUSTOM CODE)--
379 
380  /// Return the UsdCollectionAPI interface used for examining and
381  /// modifying the render visibility of this prim.
382  // For more information, see
383  // \\ref usdRender_renderVisibility "Render Visibility"
386 };
387 
389 
390 #endif
static USDRENDER_API UsdRenderPass Define(const UsdStagePtr &stage, const SdfPath &path)
#define USDRENDER_API
Definition: api.h:23
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDRENDER_API UsdRenderPass Get(const UsdStagePtr &stage, const SdfPath &path)
UsdRenderPass(const UsdSchemaBase &schemaObj)
Definition: pass.h:144
USDRENDER_API UsdRelationship CreateInputPassesRel() const
USDRENDER_API UsdCollectionAPI GetRenderVisibilityCollectionAPI() const
USDRENDER_API UsdRelationship GetInputPassesRel() const
static USDRENDER_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Represents a concrete typed schema.
USDRENDER_API UsdAttribute GetFileNameAttr() const
USDRENDER_API UsdAttribute GetPassTypeAttr() const
USDRENDER_API UsdAttribute CreateCommandAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:116
Definition: typed.h:44
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
USDRENDER_API UsdRelationship CreateRenderSourceRel() const
USDRENDER_API UsdRelationship GetRenderSourceRel() const
UsdSchemaKind
Definition: common.h:112
USDRENDER_API UsdSchemaKind _GetSchemaKind() const override
USDRENDER_API UsdAttribute GetCommandAttr() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
static const UsdSchemaKind schemaKind
Definition: pass.h:130
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDRENDER_API UsdAttribute CreatePassTypeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: type.h:47
virtual USDRENDER_API ~UsdRenderPass()
Destructor.
USDRENDER_API UsdAttribute CreateFileNameAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:146
UsdRenderPass(const UsdPrim &prim=UsdPrim())
Definition: pass.h:136