Loading...
Searching...
No Matches
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
104{
105public:
109 static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
110
115 explicit UsdShadeMaterial(const UsdPrim& prim=UsdPrim())
116 : UsdShadeNodeGraph(prim)
117 {
118 }
119
123 explicit UsdShadeMaterial(const UsdSchemaBase& schemaObj)
124 : UsdShadeNodeGraph(schemaObj)
125 {
126 }
127
129 USDSHADE_API
131
135 USDSHADE_API
136 static const TfTokenVector &
137 GetSchemaAttributeNames(bool includeInherited=true);
138
148 USDSHADE_API
149 static UsdShadeMaterial
150 Get(const UsdStagePtr &stage, const SdfPath &path);
151
174 USDSHADE_API
175 static UsdShadeMaterial
176 Define(const UsdStagePtr &stage, const SdfPath &path);
177
178protected:
182 USDSHADE_API
184
185private:
186 // needs to invoke _GetStaticTfType.
187 friend class UsdSchemaRegistry;
188 USDSHADE_API
189 static const TfType &_GetStaticTfType();
190
191 static bool _IsTypedSchema();
192
193 // override SchemaBase virtuals.
194 USDSHADE_API
195 const TfType &_GetTfType() const override;
196
197public:
198 // --------------------------------------------------------------------- //
199 // SURFACE
200 // --------------------------------------------------------------------- //
209 USDSHADE_API
211
217 USDSHADE_API
218 UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
219
220public:
221 // --------------------------------------------------------------------- //
222 // DISPLACEMENT
223 // --------------------------------------------------------------------- //
232 USDSHADE_API
234
240 USDSHADE_API
241 UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
242
243public:
244 // --------------------------------------------------------------------- //
245 // VOLUME
246 // --------------------------------------------------------------------- //
255 USDSHADE_API
257
263 USDSHADE_API
264 UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
265
266public:
267 // ===================================================================== //
268 // Feel free to add custom code below this line, it will be preserved by
269 // the code generator.
270 //
271 // Just remember to:
272 // - Close the class declaration with };
273 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
274 // - Close the include guard with #endif
275 // ===================================================================== //
276 // --(BEGIN CUSTOM CODE)--
277
278 // --------------------------------------------------------------------- //
281 // --------------------------------------------------------------------- //
282
284 typedef std::function<bool (const SdfPath &)> PathPredicate;
285
287
288
289 // --------------------------------------------------------------------- //
308
315 USDSHADE_API
317 =UsdShadeTokens->universalRenderContext) const;
318
327 USDSHADE_API
329 =UsdShadeTokens->universalRenderContext) const;
330
338 USDSHADE_API
339 std::vector<UsdShadeOutput> GetSurfaceOutputs() const;
340
342 USDSHADE_API
344 const TfToken &renderContext,
345 TfToken *sourceName=nullptr,
346 UsdShadeAttributeType *sourceType=nullptr) const;
347
360 USDSHADE_API
362 const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext},
363 TfToken *sourceName=nullptr,
364 UsdShadeAttributeType *sourceType=nullptr) const;
365
372 USDSHADE_API
374 =UsdShadeTokens->universalRenderContext) const;
375
384 USDSHADE_API
386 =UsdShadeTokens->universalRenderContext) const;
387
395 USDSHADE_API
396 std::vector<UsdShadeOutput> GetDisplacementOutputs() const;
397
399 USDSHADE_API
401 const TfToken &renderContext,
402 TfToken *sourceName=nullptr,
403 UsdShadeAttributeType *sourceType=nullptr) const;
404
417 USDSHADE_API
419 const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext},
420 TfToken *sourceName=nullptr,
421 UsdShadeAttributeType *sourceType=nullptr) const;
422
429 USDSHADE_API
431 =UsdShadeTokens->universalRenderContext) const;
432
441 USDSHADE_API
443 =UsdShadeTokens->universalRenderContext) const;
444
451 USDSHADE_API
452 std::vector<UsdShadeOutput> GetVolumeOutputs() const;
453
455 USDSHADE_API
457 const TfToken &renderContext,
458 TfToken *sourceName=nullptr,
459 UsdShadeAttributeType *sourceType=nullptr) const;
460
473 USDSHADE_API
475 const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext},
476 TfToken *sourceName=nullptr,
477 UsdShadeAttributeType *sourceType=nullptr) const;
478
480
481private:
482 // Helper method to compute the sources of a given output, identified by its
483 // baseName, for the renderContexts in the specified contextVector.
484 UsdShadeAttributeVector _ComputeNamedOutputSources(
485 const TfToken &baseName,
486 const TfTokenVector &contextVector) const;
487
488 // Helper method to compute the source shader of a given output, identified
489 // by its baseName, for the renderContexts in the specified contextVector.
490 UsdShadeShader _ComputeNamedOutputShader(
491 const TfToken &baseName,
492 const TfTokenVector &contextVector,
493 TfToken *sourceName,
494 UsdShadeAttributeType *sourceType) const;
495
496 // Helper method to retrieve outputs in all renderContexts that match the
497 // given terminalName.
498 std::vector<UsdShadeOutput> _GetOutputsForTerminalName(
499 const TfToken& terminalName) const;
500
501public:
502 // --------------------------------------------------------------------- //
554 // --------------------------------------------------------------------- //
593 USDSHADE_API
594 std::pair<UsdStagePtr, UsdEditTarget>
595 GetEditContextForVariant(const TfToken &MaterialVariantName,
596 const SdfLayerHandle &layer = SdfLayerHandle()) const;
597
600 USDSHADE_API
602
631 USDSHADE_API
633 const UsdPrim &masterPrim,
634 const std::vector<UsdPrim> &MaterialPrims,
635 const TfToken &masterVariantSetName = TfToken());
636
638
639 // --------------------------------------------------------------------- //
647 // --------------------------------------------------------------------- //
648
651 USDSHADE_API
653
656 USDSHADE_API
658
664 USDSHADE_API
666 const PcpPrimIndex & primIndex,
667 const PathPredicate & pathIsMaterialPredicate);
668
671 USDSHADE_API
672 void SetBaseMaterial(const UsdShadeMaterial& baseMaterial) const;
673
676 USDSHADE_API
677 void SetBaseMaterialPath(const SdfPath& baseMaterialPath) const;
678
680 USDSHADE_API
681 void ClearBaseMaterial() const;
682
683 // Check if this Material has a base Material
684 USDSHADE_API
685 bool HasBaseMaterial() const;
686
688
689};
690
691PXR_NAMESPACE_CLOSE_SCOPE
692
693#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 optional evaluated and resolved paths.
Definition: assetPath.h:79
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:281
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:183
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:104
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:109
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:284
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:115
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:123
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:90
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.