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  // --------------------------------------------------------------------- //
217  USDSHADE_API
219 
225  USDSHADE_API
226  UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
227 
228 public:
229  // --------------------------------------------------------------------- //
230  // DISPLACEMENT
231  // --------------------------------------------------------------------- //
240  USDSHADE_API
242 
248  USDSHADE_API
249  UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
250 
251 public:
252  // --------------------------------------------------------------------- //
253  // VOLUME
254  // --------------------------------------------------------------------- //
263  USDSHADE_API
264  UsdAttribute GetVolumeAttr() const;
265 
271  USDSHADE_API
272  UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
273 
274 public:
275  // ===================================================================== //
276  // Feel free to add custom code below this line, it will be preserved by
277  // the code generator.
278  //
279  // Just remember to:
280  // - Close the class declaration with };
281  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
282  // - Close the include guard with #endif
283  // ===================================================================== //
284  // --(BEGIN CUSTOM CODE)--
285 
286  // --------------------------------------------------------------------- //
289  // --------------------------------------------------------------------- //
290 
292  typedef std::function<bool (const SdfPath &)> PathPredicate;
293 
295 
296 
297  // --------------------------------------------------------------------- //
316 
323  USDSHADE_API
324  UsdShadeOutput CreateSurfaceOutput(const TfToken &renderContext
325  =UsdShadeTokens->universalRenderContext) const;
326 
335  USDSHADE_API
336  UsdShadeOutput GetSurfaceOutput(const TfToken &renderContext
337  =UsdShadeTokens->universalRenderContext) const;
338 
346  USDSHADE_API
347  std::vector<UsdShadeOutput> GetSurfaceOutputs() const;
348 
360  USDSHADE_API
362  const TfToken &renderContext=UsdShadeTokens->universalRenderContext,
363  TfToken *sourceName=nullptr,
364  UsdShadeAttributeType *sourceType=nullptr) const;
365 
372  USDSHADE_API
373  UsdShadeOutput CreateDisplacementOutput(const TfToken &renderContext
374  =UsdShadeTokens->universalRenderContext) const;
375 
384  USDSHADE_API
385  UsdShadeOutput GetDisplacementOutput(const TfToken &renderContext
386  =UsdShadeTokens->universalRenderContext) const;
387 
395  USDSHADE_API
396  std::vector<UsdShadeOutput> GetDisplacementOutputs() const;
397 
409  USDSHADE_API
411  const TfToken &renderContext=UsdShadeTokens->universalRenderContext,
412  TfToken *sourceName=nullptr,
413  UsdShadeAttributeType *sourceType=nullptr) const;
414 
421  USDSHADE_API
422  UsdShadeOutput CreateVolumeOutput(const TfToken &renderContext
423  =UsdShadeTokens->universalRenderContext) const;
424 
433  USDSHADE_API
434  UsdShadeOutput GetVolumeOutput(const TfToken &renderContext
435  =UsdShadeTokens->universalRenderContext) const;
436 
443  USDSHADE_API
444  std::vector<UsdShadeOutput> GetVolumeOutputs() const;
445 
457  USDSHADE_API
459  const TfToken &renderContext=UsdShadeTokens->universalRenderContext,
460  TfToken *sourceName=nullptr,
461  UsdShadeAttributeType *sourceType=nullptr) const;
462 
464 
465 private:
466  // Helper method to compute the source of a given output, identified by its
467  // baseName, for the specified renderContext.
468  bool _ComputeNamedOutputSource(
469  const TfToken &baseName,
470  const TfToken &renderContext,
471  UsdShadeConnectableAPI *source,
472  TfToken *sourceName,
473  UsdShadeAttributeType *sourceType) const;
474 
475  // Helper method to compute the source shader of a given output, identified
476  // by its baseName, for the specified renderContext.
477  UsdShadeShader _ComputeNamedOutputShader(
478  const TfToken &baseName,
479  const TfToken &renderContext,
480  TfToken *sourceName,
481  UsdShadeAttributeType *sourceType) const;
482 
483  // Helper method to retrieve outputs in all renderContexts that match the
484  // given terminalName.
485  std::vector<UsdShadeOutput> _GetOutputsForTerminalName(
486  const TfToken& terminalName) const;
487 
488 public:
489  // --------------------------------------------------------------------- //
541  // --------------------------------------------------------------------- //
580  USDSHADE_API
581  std::pair<UsdStagePtr, UsdEditTarget>
582  GetEditContextForVariant(const TfToken &MaterialVariantName,
583  const SdfLayerHandle &layer = SdfLayerHandle()) const;
584 
587  USDSHADE_API
589 
618  USDSHADE_API
619  static bool CreateMasterMaterialVariant(
620  const UsdPrim &masterPrim,
621  const std::vector<UsdPrim> &MaterialPrims,
622  const TfToken &masterVariantSetName = TfToken());
623 
625 
626  // --------------------------------------------------------------------- //
634  // --------------------------------------------------------------------- //
635 
638  USDSHADE_API
640 
643  USDSHADE_API
645 
651  USDSHADE_API
653  const PcpPrimIndex & primIndex,
654  const PathPredicate & pathIsMaterialPredicate);
655 
658  USDSHADE_API
659  void SetBaseMaterial(const UsdShadeMaterial& baseMaterial) const;
660 
663  USDSHADE_API
664  void SetBaseMaterialPath(const SdfPath& baseMaterialPath) const;
665 
667  USDSHADE_API
668  void ClearBaseMaterial() const;
669 
670  // Check if this Material has a base Material
671  USDSHADE_API
672  bool HasBaseMaterial() const;
673 
675 
676 };
677 
678 PXR_NAMESPACE_CLOSE_SCOPE
679 
680 #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.
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:75
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.
UsdShadeMaterial(const UsdSchemaBase &schemaObj)
Construct a UsdShadeMaterial on the prim held by schemaObj .
Definition: material.h:131
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 std::vector< UsdShadeOutput > GetDisplacementOutputs() const
Returns the &quot;displacement&quot; outputs of this material for all available renderContexts.
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:80
static USDSHADE_API SdfPath FindBaseMaterialPathInPrimIndex(const PcpPrimIndex &primIndex, const PathPredicate &pathIsMaterialPredicate)
Given a PcpPrimIndex, searches it for an arc to a parent material.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
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
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:127
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:132
USDSHADE_API UsdShadeMaterial GetBaseMaterial() const
Get the path to the base Material of this Material.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
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:288
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.
virtual USDSHADE_API ~UsdShadeMaterial()
Destructor.
USDSHADE_API void SetBaseMaterialPath(const SdfPath &baseMaterialPath) const
Set the path to the base Material of this Material.
std::function< bool(const SdfPath &)> PathPredicate
A function type that takes a path and returns a bool.
Definition: material.h:292
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
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...
USDSHADE_API std::vector< UsdShadeOutput > GetSurfaceOutputs() const
Returns the &quot;surface&quot; outputs of this material for all available renderContexts.
Base class for all USD shaders.
Definition: shader.h:85
TfType represents a dynamic runtime type.
Definition: type.h:64
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 schema type information and the prim definitions for regis...
USDSHADE_API std::vector< UsdShadeOutput > GetVolumeOutputs() const
Returns the &quot;volume&quot; outputs of this material for all available renderContexts.
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 attribute representing ...
Definition: output.h:45
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.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
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.