All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
material.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 USDSHADE_GENERATED_MATERIAL_H
8#define USDSHADE_GENERATED_MATERIAL_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usdShade/api.h"
15#include "pxr/usd/usd/prim.h"
16#include "pxr/usd/usd/stage.h"
18
19#include "pxr/usd/usd/variantSets.h"
22
23#include "pxr/base/vt/value.h"
24
25#include "pxr/base/gf/vec3d.h"
26#include "pxr/base/gf/vec3f.h"
28
29#include "pxr/base/tf/token.h"
30#include "pxr/base/tf/type.h"
31
32PXR_NAMESPACE_OPEN_SCOPE
33
34class SdfAssetPath;
35
36// -------------------------------------------------------------------------- //
37// MATERIAL //
38// -------------------------------------------------------------------------- //
39
96{
97public:
101 static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
102
107 explicit UsdShadeMaterial(const UsdPrim& prim=UsdPrim())
108 : UsdShadeNodeGraph(prim)
109 {
110 }
111
115 explicit UsdShadeMaterial(const UsdSchemaBase& schemaObj)
116 : UsdShadeNodeGraph(schemaObj)
117 {
118 }
119
121 USDSHADE_API
123
127 USDSHADE_API
128 static const TfTokenVector &
129 GetSchemaAttributeNames(bool includeInherited=true);
130
140 USDSHADE_API
141 static UsdShadeMaterial
142 Get(const UsdStagePtr &stage, const SdfPath &path);
143
166 USDSHADE_API
167 static UsdShadeMaterial
168 Define(const UsdStagePtr &stage, const SdfPath &path);
169
170protected:
174 USDSHADE_API
176
177private:
178 // needs to invoke _GetStaticTfType.
179 friend class UsdSchemaRegistry;
180 USDSHADE_API
181 static const TfType &_GetStaticTfType();
182
183 static bool _IsTypedSchema();
184
185 // override SchemaBase virtuals.
186 USDSHADE_API
187 const TfType &_GetTfType() const override;
188
189public:
190 // --------------------------------------------------------------------- //
191 // SURFACE
192 // --------------------------------------------------------------------- //
201 USDSHADE_API
203
209 USDSHADE_API
210 UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
211
212public:
213 // --------------------------------------------------------------------- //
214 // DISPLACEMENT
215 // --------------------------------------------------------------------- //
224 USDSHADE_API
226
232 USDSHADE_API
233 UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
234
235public:
236 // --------------------------------------------------------------------- //
237 // VOLUME
238 // --------------------------------------------------------------------- //
247 USDSHADE_API
249
255 USDSHADE_API
256 UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
257
258public:
259 // ===================================================================== //
260 // Feel free to add custom code below this line, it will be preserved by
261 // the code generator.
262 //
263 // Just remember to:
264 // - Close the class declaration with };
265 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
266 // - Close the include guard with #endif
267 // ===================================================================== //
268 // --(BEGIN CUSTOM CODE)--
269
270 // --------------------------------------------------------------------- //
273 // --------------------------------------------------------------------- //
274
276 typedef std::function<bool (const SdfPath &)> PathPredicate;
277
279
280
281 // --------------------------------------------------------------------- //
300
307 USDSHADE_API
309 =UsdShadeTokens->universalRenderContext) const;
310
319 USDSHADE_API
321 =UsdShadeTokens->universalRenderContext) const;
322
330 USDSHADE_API
331 std::vector<UsdShadeOutput> GetSurfaceOutputs() const;
332
334 USDSHADE_API
336 const TfToken &renderContext,
337 TfToken *sourceName=nullptr,
338 UsdShadeAttributeType *sourceType=nullptr) const;
339
352 USDSHADE_API
354 const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext},
355 TfToken *sourceName=nullptr,
356 UsdShadeAttributeType *sourceType=nullptr) const;
357
364 USDSHADE_API
366 =UsdShadeTokens->universalRenderContext) const;
367
376 USDSHADE_API
378 =UsdShadeTokens->universalRenderContext) const;
379
387 USDSHADE_API
388 std::vector<UsdShadeOutput> GetDisplacementOutputs() const;
389
391 USDSHADE_API
393 const TfToken &renderContext,
394 TfToken *sourceName=nullptr,
395 UsdShadeAttributeType *sourceType=nullptr) const;
396
409 USDSHADE_API
411 const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext},
412 TfToken *sourceName=nullptr,
413 UsdShadeAttributeType *sourceType=nullptr) const;
414
421 USDSHADE_API
423 =UsdShadeTokens->universalRenderContext) const;
424
433 USDSHADE_API
435 =UsdShadeTokens->universalRenderContext) const;
436
443 USDSHADE_API
444 std::vector<UsdShadeOutput> GetVolumeOutputs() const;
445
447 USDSHADE_API
449 const TfToken &renderContext,
450 TfToken *sourceName=nullptr,
451 UsdShadeAttributeType *sourceType=nullptr) const;
452
465 USDSHADE_API
467 const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext},
468 TfToken *sourceName=nullptr,
469 UsdShadeAttributeType *sourceType=nullptr) const;
470
472
473private:
474 // Helper method to compute the sources of a given output, identified by its
475 // baseName, for the renderContexts in the specified contextVector.
476 UsdShadeAttributeVector _ComputeNamedOutputSources(
477 const TfToken &baseName,
478 const TfTokenVector &contextVector) const;
479
480 // Helper method to compute the source shader of a given output, identified
481 // by its baseName, for the renderContexts in the specified contextVector.
482 UsdShadeShader _ComputeNamedOutputShader(
483 const TfToken &baseName,
484 const TfTokenVector &contextVector,
485 TfToken *sourceName,
486 UsdShadeAttributeType *sourceType) const;
487
488 // Helper method to retrieve outputs in all renderContexts that match the
489 // given terminalName.
490 std::vector<UsdShadeOutput> _GetOutputsForTerminalName(
491 const TfToken& terminalName) const;
492
493public:
494 // --------------------------------------------------------------------- //
546 // --------------------------------------------------------------------- //
585 USDSHADE_API
586 std::pair<UsdStagePtr, UsdEditTarget>
587 GetEditContextForVariant(const TfToken &MaterialVariantName,
588 const SdfLayerHandle &layer = SdfLayerHandle()) const;
589
592 USDSHADE_API
594
623 USDSHADE_API
625 const UsdPrim &masterPrim,
626 const std::vector<UsdPrim> &MaterialPrims,
627 const TfToken &masterVariantSetName = TfToken());
628
630
631 // --------------------------------------------------------------------- //
639 // --------------------------------------------------------------------- //
640
643 USDSHADE_API
645
648 USDSHADE_API
650
656 USDSHADE_API
658 const PcpPrimIndex & primIndex,
659 const PathPredicate & pathIsMaterialPredicate);
660
663 USDSHADE_API
664 void SetBaseMaterial(const UsdShadeMaterial& baseMaterial) const;
665
668 USDSHADE_API
669 void SetBaseMaterialPath(const SdfPath& baseMaterialPath) const;
670
672 USDSHADE_API
673 void ClearBaseMaterial() const;
674
675 // Check if this Material has a base Material
676 USDSHADE_API
677 bool HasBaseMaterial() const;
678
680
681};
682
683PXR_NAMESPACE_CLOSE_SCOPE
684
685#endif
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:62
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
This is a small-vector class with local storage optimization, the local storage can be specified via ...
Definition: smallVector.h:157
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
TfType represents a dynamic runtime type.
Definition: type.h:48
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:160
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
The base class for all schema types in Usd.
Definition: schemaBase.h:39
Singleton registry that provides access to schema type information and the prim definitions for regis...
A Material provides a container into which multiple "render contexts" can add data that defines a "sh...
Definition: material.h:96
USDSHADE_API UsdAttribute CreateVolumeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetVolumeAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USDSHADE_API UsdAttribute GetDisplacementAttr() const
Represents the universal "displacement" output terminal of a material.
USDSHADE_API UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetSurfaceAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USDSHADE_API UsdShadeShader ComputeSurfaceSource(const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext}, TfToken *sourceName=nullptr, UsdShadeAttributeType *sourceType=nullptr) const
Computes the resolved "surface" output source for the given contextVector.
USDSHADE_API UsdAttribute GetVolumeAttr() const
Represents the universal "volume" output terminal of a material.
virtual USDSHADE_API ~UsdShadeMaterial()
Destructor.
USDSHADE_API UsdShadeShader ComputeVolumeSource(const TfToken &renderContext, TfToken *sourceName=nullptr, UsdShadeAttributeType *sourceType=nullptr) const
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: material.h:101
USDSHADE_API void SetBaseMaterialPath(const SdfPath &baseMaterialPath) const
Set the path to the base Material of this Material.
static USDSHADE_API SdfPath FindBaseMaterialPathInPrimIndex(const PcpPrimIndex &primIndex, const PathPredicate &pathIsMaterialPredicate)
Given a PcpPrimIndex, searches it for an arc to a parent material.
USDSHADE_API UsdShadeOutput CreateVolumeOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Creates and returns the "volume" output on this material for the specified renderContext.
USDSHADE_API UsdShadeShader ComputeDisplacementSource(const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext}, TfToken *sourceName=nullptr, UsdShadeAttributeType *sourceType=nullptr) const
Computes the resolved "displacement" output source for the given contextVector.
static USDSHADE_API bool CreateMasterMaterialVariant(const UsdPrim &masterPrim, const std::vector< UsdPrim > &MaterialPrims, const TfToken &masterVariantSetName=TfToken())
Create a variantSet on masterPrim that will set the MaterialVariant on each of the given MaterialPrim...
USDSHADE_API UsdShadeOutput GetDisplacementOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Returns the "displacement" output of this material for the specified renderContext.
std::function< bool(const SdfPath &)> PathPredicate
A function type that takes a path and returns a bool.
Definition: material.h:276
USDSHADE_API std::pair< UsdStagePtr, UsdEditTarget > GetEditContextForVariant(const TfToken &MaterialVariantName, const SdfLayerHandle &layer=SdfLayerHandle()) const
Helper function for configuring a UsdStage's UsdEditTarget to author Material variations.
USDSHADE_API UsdShadeMaterial GetBaseMaterial() const
Get the path to the base Material of this Material.
UsdShadeMaterial(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeMaterial on UsdPrim prim .
Definition: material.h:107
USDSHADE_API UsdShadeShader ComputeVolumeSource(const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext}, TfToken *sourceName=nullptr, UsdShadeAttributeType *sourceType=nullptr) const
Computes the resolved "volume" output source for the given contextVector.
static USDSHADE_API UsdShadeMaterial Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdShadeMaterial holding the prim adhering to this schema at path on stage.
USDSHADE_API UsdShadeShader ComputeSurfaceSource(const TfToken &renderContext, TfToken *sourceName=nullptr, UsdShadeAttributeType *sourceType=nullptr) const
USDSHADE_API UsdAttribute GetSurfaceAttr() const
Represents the universal "surface" output terminal of a material.
USDSHADE_API UsdShadeShader ComputeDisplacementSource(const TfToken &renderContext, TfToken *sourceName=nullptr, UsdShadeAttributeType *sourceType=nullptr) const
USDSHADE_API void ClearBaseMaterial() const
Clear the base Material of this Material.
USDSHADE_API std::vector< UsdShadeOutput > GetVolumeOutputs() const
Returns the "volume" outputs of this material for all available renderContexts.
USDSHADE_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
USDSHADE_API UsdShadeOutput CreateDisplacementOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Creates and returns the "displacement" output on this material for the specified renderContext.
USDSHADE_API void SetBaseMaterial(const UsdShadeMaterial &baseMaterial) const
Set the base Material of this Material.
static USDSHADE_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
USDSHADE_API UsdVariantSet GetMaterialVariant() const
Return a UsdVariantSet object for interacting with the Material variant variantSet.
UsdShadeMaterial(const UsdSchemaBase &schemaObj)
Construct a UsdShadeMaterial on the prim held by schemaObj .
Definition: material.h:115
USDSHADE_API SdfPath GetBaseMaterialPath() const
Get the base Material of this Material.
USDSHADE_API std::vector< UsdShadeOutput > GetDisplacementOutputs() const
Returns the "displacement" outputs of this material for all available renderContexts.
USDSHADE_API UsdShadeOutput CreateSurfaceOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Creates and returns the "surface" output on this material for the specified renderContext.
static USDSHADE_API UsdShadeMaterial Define(const UsdStagePtr &stage, const SdfPath &path)
Attempt to ensure a UsdPrim adhering to this schema at path is defined (according to UsdPrim::IsDefin...
USDSHADE_API UsdShadeOutput GetVolumeOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Returns the "volume" output of this material for the specified renderContext.
USDSHADE_API std::vector< UsdShadeOutput > GetSurfaceOutputs() const
Returns the "surface" outputs of this material for all available renderContexts.
USDSHADE_API UsdShadeOutput GetSurfaceOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Returns the "surface" output of this material for the specified renderContext.
USDSHADE_API UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetDisplacementAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
A node-graph is a container for shading nodes, as well as other node-graphs.
Definition: nodeGraph.h:64
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:31
Base class for all USD shaders.
Definition: shader.h:69
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:39
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:112
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
USDSHADE_API TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.