All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
31 #include "pxr/usd/usdShade/nodeGraph.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdShade/tokens.h"
35 
36 #include "pxr/usd/usd/variantSets.h"
37 #include "pxr/usd/usdGeom/subset.h"
38 #include "pxr/usd/usdShade/connectableAPI.h"
39 
40 #include "pxr/base/vt/value.h"
41 
42 #include "pxr/base/gf/vec3d.h"
43 #include "pxr/base/gf/vec3f.h"
44 #include "pxr/base/gf/matrix4d.h"
45 
46 #include "pxr/base/tf/token.h"
47 #include "pxr/base/tf/type.h"
48 
49 PXR_NAMESPACE_OPEN_SCOPE
50 
51 class SdfAssetPath;
52 
53 // -------------------------------------------------------------------------- //
54 // MATERIAL //
55 // -------------------------------------------------------------------------- //
56 
112 {
113 public:
118 
123  explicit UsdShadeMaterial(const UsdPrim& prim=UsdPrim())
124  : UsdShadeNodeGraph(prim)
125  {
126  }
127 
131  explicit UsdShadeMaterial(const UsdSchemaBase& schemaObj)
132  : UsdShadeNodeGraph(schemaObj)
133  {
134  }
135 
137  USDSHADE_API
138  virtual ~UsdShadeMaterial();
139 
143  USDSHADE_API
144  static const TfTokenVector &
145  GetSchemaAttributeNames(bool includeInherited=true);
146 
156  USDSHADE_API
157  static UsdShadeMaterial
158  Get(const UsdStagePtr &stage, const SdfPath &path);
159 
182  USDSHADE_API
183  static UsdShadeMaterial
184  Define(const UsdStagePtr &stage, const SdfPath &path);
185 
186 protected:
190  USDSHADE_API
191  UsdSchemaType _GetSchemaType() const override;
192 
193 private:
194  // needs to invoke _GetStaticTfType.
195  friend class UsdSchemaRegistry;
196  USDSHADE_API
197  static const TfType &_GetStaticTfType();
198 
199  static bool _IsTypedSchema();
200 
201  // override SchemaBase virtuals.
202  USDSHADE_API
203  const TfType &_GetTfType() const override;
204 
205 public:
206  // --------------------------------------------------------------------- //
207  // SURFACE
208  // --------------------------------------------------------------------- //
216  USDSHADE_API
218 
224  USDSHADE_API
225  UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
226 
227 public:
228  // --------------------------------------------------------------------- //
229  // DISPLACEMENT
230  // --------------------------------------------------------------------- //
238  USDSHADE_API
240 
246  USDSHADE_API
247  UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
248 
249 public:
250  // --------------------------------------------------------------------- //
251  // VOLUME
252  // --------------------------------------------------------------------- //
260  USDSHADE_API
261  UsdAttribute GetVolumeAttr() const;
262 
268  USDSHADE_API
269  UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
270 
271 public:
272  // ===================================================================== //
273  // Feel free to add custom code below this line, it will be preserved by
274  // the code generator.
275  //
276  // Just remember to:
277  // - Close the class declaration with };
278  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
279  // - Close the include guard with #endif
280  // ===================================================================== //
281  // --(BEGIN CUSTOM CODE)--
282 
283  // --------------------------------------------------------------------- //
286  // --------------------------------------------------------------------- //
287 
289  typedef std::function<bool (const SdfPath &)> PathPredicate;
290 
292 
293  // --------------------------------------------------------------------- //
299  // --------------------------------------------------------------------- //
300 
307  USDSHADE_API
308  //[[deprecated("Please use UsdShadeMaterialBindingAPI instead.")]]
309  bool Bind(const UsdPrim& prim) const;
310 
320  USDSHADE_API
321  //[[deprecated("Please use UsdShadeMaterialBindingAPI instead.")]]
322  static bool Unbind(const UsdPrim& prim);
323 
337  //[[deprecated("Please use UsdShadeMaterialBindingAPI instead.")]]
338  USDSHADE_API
339  static UsdRelationship GetBindingRel(const UsdPrim& prim);
340 
345  //[[deprecated("Please use UsdShadeMaterialBindingAPI instead.")]]
346  USDSHADE_API
347  static UsdShadeMaterial GetBoundMaterial(const UsdPrim &prim);
348 
350 
351  // --------------------------------------------------------------------- //
370 
377  USDSHADE_API
378  UsdShadeOutput CreateSurfaceOutput(const TfToken &renderContext
379  =UsdShadeTokens->universalRenderContext) const;
380 
389  USDSHADE_API
390  UsdShadeOutput GetSurfaceOutput(const TfToken &renderContext
391  =UsdShadeTokens->universalRenderContext) const;
392 
404  USDSHADE_API
406  const TfToken &renderContext=UsdShadeTokens->universalRenderContext,
407  TfToken *sourceName=nullptr,
408  UsdShadeAttributeType *sourceType=nullptr) const;
409 
416  USDSHADE_API
417  UsdShadeOutput CreateDisplacementOutput(const TfToken &renderContext
418  =UsdShadeTokens->universalRenderContext) const;
419 
428  USDSHADE_API
429  UsdShadeOutput GetDisplacementOutput(const TfToken &renderContext
430  =UsdShadeTokens->universalRenderContext) const;
431 
443  USDSHADE_API
445  const TfToken &renderContext=UsdShadeTokens->universalRenderContext,
446  TfToken *sourceName=nullptr,
447  UsdShadeAttributeType *sourceType=nullptr) const;
448 
455  USDSHADE_API
456  UsdShadeOutput CreateVolumeOutput(const TfToken &renderContext
457  =UsdShadeTokens->universalRenderContext) const;
458 
467  USDSHADE_API
468  UsdShadeOutput GetVolumeOutput(const TfToken &renderContext
469  =UsdShadeTokens->universalRenderContext) const;
470 
482  USDSHADE_API
484  const TfToken &renderContext=UsdShadeTokens->universalRenderContext,
485  TfToken *sourceName=nullptr,
486  UsdShadeAttributeType *sourceType=nullptr) const;
487 
489 
490 private:
491  // Helper method to compute the source of a given output, identified by its
492  // baseName, for the specified renderContext.
493  bool _ComputeNamedOutputSource(
494  const TfToken &baseName,
495  const TfToken &renderContext,
496  UsdShadeConnectableAPI *source,
497  TfToken *sourceName,
498  UsdShadeAttributeType *sourceType) const;
499 
500  // Helper method to compute the source shader of a given output, identified
501  // by its baseName, for the specified renderContext.
502  UsdShadeShader _ComputeNamedOutputShader(
503  const TfToken &baseName,
504  const TfToken &renderContext,
505  TfToken *sourceName,
506  UsdShadeAttributeType *sourceType) const;
507 
508 public:
509  // --------------------------------------------------------------------- //
561  // --------------------------------------------------------------------- //
600  USDSHADE_API
601  std::pair<UsdStagePtr, UsdEditTarget>
602  GetEditContextForVariant(const TfToken &MaterialVariantName,
603  const SdfLayerHandle &layer = SdfLayerHandle()) const;
604 
607  USDSHADE_API
609 
638  USDSHADE_API
639  static bool CreateMasterMaterialVariant(
640  const UsdPrim &masterPrim,
641  const std::vector<UsdPrim> &MaterialPrims,
642  const TfToken &masterVariantSetName = TfToken());
643 
645 
646  // --------------------------------------------------------------------- //
654  // --------------------------------------------------------------------- //
655 
658  USDSHADE_API
660 
663  USDSHADE_API
665 
671  USDSHADE_API
673  const PcpPrimIndex & primIndex,
674  const PathPredicate & pathIsMaterialPredicate);
675 
678  USDSHADE_API
679  void SetBaseMaterial(const UsdShadeMaterial& baseMaterial) const;
680 
683  USDSHADE_API
684  void SetBaseMaterialPath(const SdfPath& baseMaterialPath) const;
685 
687  USDSHADE_API
688  void ClearBaseMaterial() const;
689 
690  // Check if this Material has a base Material
691  USDSHADE_API
692  bool HasBaseMaterial() const;
693 
695 
696 
697  // --------------------------------------------------------------------- //
734 
751  USDSHADE_API
753  const UsdGeomImageable &geom,
754  const TfToken &subsetName,
755  const VtIntArray &indices,
756  const TfToken &elementType=UsdGeomTokens->face);
757 
762  USDSHADE_API
763  static std::vector<UsdGeomSubset> GetMaterialBindSubsets(
764  const UsdGeomImageable &geom);
765 
769  USDSHADE_API
771  const UsdGeomImageable &geom,
772  const TfToken &familyType);
773 
785  USDSHADE_API
787  const UsdGeomImageable &geom);
788 
790 };
791 
792 PXR_NAMESPACE_CLOSE_SCOPE
793 
794 #endif
USDSHADE_API SdfPath GetBaseMaterialPath() const
Get the base Material of this Material.
USDSHADE_API UsdVariantSet GetMaterialVariant() const
Return a UsdVariantSet object for interacting with the Material variant variantSet.
static USDSHADE_API UsdGeomSubset CreateMaterialBindSubset(const UsdGeomImageable &geom, const TfToken &subsetName, const VtIntArray &indices, const TfToken &elementType=UsdGeomTokens->face)
static USDSHADE_API UsdShadeMaterial GetBoundMaterial(const UsdPrim &prim)
static USDSHADE_API bool Unbind(const UsdPrim &prim)
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:77
USDSHADE_API UsdShadeShader ComputeSurfaceSource(const TfToken &renderContext=UsdShadeTokens->universalRenderContext, TfToken *sourceName=nullptr, UsdShadeAttributeType *sourceType=nullptr) const
Computes the resolved &quot;surface&quot; output source for the given renderContext.
USDSHADE_API bool Bind(const UsdPrim &prim) const
UsdShadeMaterial(const UsdSchemaBase &schemaObj)
Construct a UsdShadeMaterial on the prim held by schemaObj .
Definition: material.h:131
static USDSHADE_API bool SetMaterialBindSubsetsFamilyType(const UsdGeomImageable &geom, const TfToken &familyType)
USDSHADE_API UsdAttribute GetSurfaceAttr() const
Represents the universal &quot;surface&quot; output terminal of a material.
USDSHADE_API UsdShadeOutput CreateDisplacementOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Creates and returns the &quot;displacement&quot; output on this material for the specified renderContext.
USDSHADE_API void SetBaseMaterial(const UsdShadeMaterial &baseMaterial) const
Set the base Material of this Material.
USDSHADE_API UsdShadeOutput GetDisplacementOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Returns the &quot;displacement&quot; output of this material for the specified renderContext.
USDSHADE_API UsdShadeShader ComputeVolumeSource(const TfToken &renderContext=UsdShadeTokens->universalRenderContext, TfToken *sourceName=nullptr, UsdShadeAttributeType *sourceType=nullptr) const
Computes the resolved &quot;volume&quot; output source for the given renderContext.
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...
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
Represents a concrete typed schema.
USDSHADE_API UsdShadeOutput CreateSurfaceOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Creates and returns the &quot;surface&quot; output on this material for the specified renderContext.
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
Definition: material.h:117
A node-graph is a container for shading nodes, as well as other node-graphs.
Definition: nodeGraph.h:79
static USDSHADE_API SdfPath FindBaseMaterialPathInPrimIndex(const PcpPrimIndex &primIndex, const PathPredicate &pathIsMaterialPredicate)
Given a PcpPrimIndex, searches it for an arc to a parent material.
static USDSHADE_API UsdRelationship GetBindingRel(const UsdPrim &prim)
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
USDSHADE_API UsdAttribute GetVolumeAttr() const
Represents the universal &quot;volume&quot; output terminal of a 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 TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:56
USDGEOM_API TfStaticData< UsdGeomTokensType > UsdGeomTokens
A global variable with static, efficient TfTokens for use in all public USD API.
USDSHADE_API UsdSchemaType _GetSchemaType() const override
Returns the type of schema this class belongs to.
UsdShadeConnectableAPI is an API schema that provides a common interface for creating outputs and mak...
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...
UsdSchemaType
An enum representing which type of schema a given schema class belongs to.
Definition: common.h:149
USDSHADE_API UsdAttribute GetDisplacementAttr() const
Represents the universal &quot;displacement&quot; output terminal of a material.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
USDSHADE_API UsdShadeMaterial GetBaseMaterial() const
Get the path to the base Material of this Material.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
USDSHADE_API void ClearBaseMaterial() const
Clear the base Material of this Material.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
USDSHADE_API UsdShadeShader ComputeDisplacementSource(const TfToken &renderContext=UsdShadeTokens->universalRenderContext, TfToken *sourceName=nullptr, UsdShadeAttributeType *sourceType=nullptr) const
Computes the resolved &quot;displacement&quot; output source for the given renderContext.
static USDSHADE_API std::vector< UsdGeomSubset > GetMaterialBindSubsets(const UsdGeomImageable &geom)
virtual USDSHADE_API ~UsdShadeMaterial()
Destructor.
USDSHADE_API void SetBaseMaterialPath(const SdfPath &baseMaterialPath) const
Set the path to the base Material of this Material.
static USDSHADE_API TfToken GetMaterialBindSubsetsFamilyType(const UsdGeomImageable &geom)
std::function< bool(const SdfPath &)> PathPredicate
A function type that takes a path and returns a bool.
Definition: material.h:289
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
Encodes a subset of a piece of geometry (i.e.
Definition: subset.h:85
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...
Base class for all USD shaders.
Definition: shader.h:89
TfType represents a dynamic runtime type.
Definition: type.h:70
USDSHADE_API UsdShadeOutput GetSurfaceOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Returns the &quot;surface&quot; output of this material for the specified renderContext.
Singleton registry that provides access to prim and property definition information for registered Us...
A Material provides a container into which multiple &quot;render targets&quot; can add data that defines a &quot;sha...
Definition: material.h:111
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.
This class encapsulates a shader or node-graph output, which is a connectable property representing a...
Definition: output.h:47
The base class for all schema types in Usd.
Definition: schemaBase.h:56
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 std::pair< UsdStagePtr, UsdEditTarget > GetEditContextForVariant(const TfToken &MaterialVariantName, const SdfLayerHandle &layer=SdfLayerHandle()) const
Helper function for configuring a UsdStage&#39;s UsdEditTarget to author Material variations.
Base class for all prims that may require rendering or visualization of some sort.
Definition: imageable.h:74
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
USDSHADE_API UsdShadeOutput CreateVolumeOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Creates and returns the &quot;volume&quot; output on this material for the specified renderContext.
UsdShadeMaterial(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeMaterial on UsdPrim prim .
Definition: material.h:123
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 GetVolumeOutput(const TfToken &renderContext=UsdShadeTokens->universalRenderContext) const
Returns the &quot;volume&quot; output of this material for the specified renderContext.