Loading...
Searching...
No Matches
material.h
Go to the documentation of this file.
1//
2// Copyright 2016 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 USDSHADE_GENERATED_MATERIAL_H
25#define USDSHADE_GENERATED_MATERIAL_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usd/usdShade/api.h"
32#include "pxr/usd/usd/prim.h"
33#include "pxr/usd/usd/stage.h"
35
36#include "pxr/usd/usd/variantSets.h"
39
40#include "pxr/base/vt/value.h"
41
42#include "pxr/base/gf/vec3d.h"
43#include "pxr/base/gf/vec3f.h"
45
46#include "pxr/base/tf/token.h"
47#include "pxr/base/tf/type.h"
48
49PXR_NAMESPACE_OPEN_SCOPE
50
51class SdfAssetPath;
52
53// -------------------------------------------------------------------------- //
54// MATERIAL //
55// -------------------------------------------------------------------------- //
56
113{
114public:
118 static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
119
124 explicit UsdShadeMaterial(const UsdPrim& prim=UsdPrim())
125 : UsdShadeNodeGraph(prim)
126 {
127 }
128
132 explicit UsdShadeMaterial(const UsdSchemaBase& schemaObj)
133 : UsdShadeNodeGraph(schemaObj)
134 {
135 }
136
138 USDSHADE_API
140
144 USDSHADE_API
145 static const TfTokenVector &
146 GetSchemaAttributeNames(bool includeInherited=true);
147
157 USDSHADE_API
158 static UsdShadeMaterial
159 Get(const UsdStagePtr &stage, const SdfPath &path);
160
183 USDSHADE_API
184 static UsdShadeMaterial
185 Define(const UsdStagePtr &stage, const SdfPath &path);
186
187protected:
191 USDSHADE_API
193
194private:
195 // needs to invoke _GetStaticTfType.
196 friend class UsdSchemaRegistry;
197 USDSHADE_API
198 static const TfType &_GetStaticTfType();
199
200 static bool _IsTypedSchema();
201
202 // override SchemaBase virtuals.
203 USDSHADE_API
204 const TfType &_GetTfType() const override;
205
206public:
207 // --------------------------------------------------------------------- //
208 // SURFACE
209 // --------------------------------------------------------------------- //
218 USDSHADE_API
220
226 USDSHADE_API
227 UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
228
229public:
230 // --------------------------------------------------------------------- //
231 // DISPLACEMENT
232 // --------------------------------------------------------------------- //
241 USDSHADE_API
243
249 USDSHADE_API
250 UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
251
252public:
253 // --------------------------------------------------------------------- //
254 // VOLUME
255 // --------------------------------------------------------------------- //
264 USDSHADE_API
266
272 USDSHADE_API
273 UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
274
275public:
276 // ===================================================================== //
277 // Feel free to add custom code below this line, it will be preserved by
278 // the code generator.
279 //
280 // Just remember to:
281 // - Close the class declaration with };
282 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
283 // - Close the include guard with #endif
284 // ===================================================================== //
285 // --(BEGIN CUSTOM CODE)--
286
287 // --------------------------------------------------------------------- //
290 // --------------------------------------------------------------------- //
291
293 typedef std::function<bool (const SdfPath &)> PathPredicate;
294
296
297
298 // --------------------------------------------------------------------- //
317
324 USDSHADE_API
326 =UsdShadeTokens->universalRenderContext) const;
327
336 USDSHADE_API
338 =UsdShadeTokens->universalRenderContext) const;
339
347 USDSHADE_API
348 std::vector<UsdShadeOutput> GetSurfaceOutputs() const;
349
351 USDSHADE_API
353 const TfToken &renderContext,
354 TfToken *sourceName=nullptr,
355 UsdShadeAttributeType *sourceType=nullptr) const;
356
369 USDSHADE_API
371 const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext},
372 TfToken *sourceName=nullptr,
373 UsdShadeAttributeType *sourceType=nullptr) const;
374
381 USDSHADE_API
383 =UsdShadeTokens->universalRenderContext) const;
384
393 USDSHADE_API
395 =UsdShadeTokens->universalRenderContext) const;
396
404 USDSHADE_API
405 std::vector<UsdShadeOutput> GetDisplacementOutputs() const;
406
408 USDSHADE_API
410 const TfToken &renderContext,
411 TfToken *sourceName=nullptr,
412 UsdShadeAttributeType *sourceType=nullptr) const;
413
426 USDSHADE_API
428 const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext},
429 TfToken *sourceName=nullptr,
430 UsdShadeAttributeType *sourceType=nullptr) const;
431
438 USDSHADE_API
440 =UsdShadeTokens->universalRenderContext) const;
441
450 USDSHADE_API
452 =UsdShadeTokens->universalRenderContext) const;
453
460 USDSHADE_API
461 std::vector<UsdShadeOutput> GetVolumeOutputs() const;
462
464 USDSHADE_API
466 const TfToken &renderContext,
467 TfToken *sourceName=nullptr,
468 UsdShadeAttributeType *sourceType=nullptr) const;
469
482 USDSHADE_API
484 const TfTokenVector &contextVector={UsdShadeTokens->universalRenderContext},
485 TfToken *sourceName=nullptr,
486 UsdShadeAttributeType *sourceType=nullptr) const;
487
489
490private:
491 // Helper method to compute the sources of a given output, identified by its
492 // baseName, for the renderContexts in the specified contextVector.
493 UsdShadeAttributeVector _ComputeNamedOutputSources(
494 const TfToken &baseName,
495 const TfTokenVector &contextVector) const;
496
497 // Helper method to compute the source shader of a given output, identified
498 // by its baseName, for the renderContexts in the specified contextVector.
499 UsdShadeShader _ComputeNamedOutputShader(
500 const TfToken &baseName,
501 const TfTokenVector &contextVector,
502 TfToken *sourceName,
503 UsdShadeAttributeType *sourceType) const;
504
505 // Helper method to retrieve outputs in all renderContexts that match the
506 // given terminalName.
507 std::vector<UsdShadeOutput> _GetOutputsForTerminalName(
508 const TfToken& terminalName) const;
509
510public:
511 // --------------------------------------------------------------------- //
563 // --------------------------------------------------------------------- //
602 USDSHADE_API
603 std::pair<UsdStagePtr, UsdEditTarget>
604 GetEditContextForVariant(const TfToken &MaterialVariantName,
605 const SdfLayerHandle &layer = SdfLayerHandle()) const;
606
609 USDSHADE_API
611
640 USDSHADE_API
642 const UsdPrim &masterPrim,
643 const std::vector<UsdPrim> &MaterialPrims,
644 const TfToken &masterVariantSetName = TfToken());
645
647
648 // --------------------------------------------------------------------- //
656 // --------------------------------------------------------------------- //
657
660 USDSHADE_API
662
665 USDSHADE_API
667
673 USDSHADE_API
675 const PcpPrimIndex & primIndex,
676 const PathPredicate & pathIsMaterialPredicate);
677
680 USDSHADE_API
681 void SetBaseMaterial(const UsdShadeMaterial& baseMaterial) const;
682
685 USDSHADE_API
686 void SetBaseMaterialPath(const SdfPath& baseMaterialPath) const;
687
689 USDSHADE_API
690 void ClearBaseMaterial() const;
691
692 // Check if this Material has a base Material
693 USDSHADE_API
694 bool HasBaseMaterial() const;
695
697
698};
699
700PXR_NAMESPACE_CLOSE_SCOPE
701
702#endif
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:78
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
This is a small-vector class with local storage optimization, the local storage can be specified via ...
Definition: smallVector.h:179
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
TfType represents a dynamic runtime type.
Definition: type.h:65
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
The base class for all schema types in Usd.
Definition: schemaBase.h:56
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:113
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:118
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:293
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:124
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:132
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:81
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:48
Base class for all USD shaders.
Definition: shader.h:86
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:56
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:164
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:129
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:457
USDSHADE_API TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.