All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialAPI.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 USDRI_GENERATED_MATERIALAPI_H
25 #define USDRI_GENERATED_MATERIALAPI_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdRi/api.h"
31 #include "pxr/usd/usd/apiSchemaBase.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdRi/tokens.h"
35 
36 #include "pxr/usd/usdShade/input.h"
37 #include "pxr/usd/usdShade/output.h"
38 #include "pxr/usd/usdShade/material.h"
39 
40 
41 #include "pxr/base/vt/value.h"
42 
43 #include "pxr/base/gf/vec3d.h"
44 #include "pxr/base/gf/vec3f.h"
45 #include "pxr/base/gf/matrix4d.h"
46 
47 #include "pxr/base/tf/token.h"
48 #include "pxr/base/tf/type.h"
49 
50 PXR_NAMESPACE_OPEN_SCOPE
51 
52 class SdfAssetPath;
53 
54 // -------------------------------------------------------------------------- //
55 // RIMATERIALAPI //
56 // -------------------------------------------------------------------------- //
57 
69 {
70 public:
75 
80  explicit UsdRiMaterialAPI(const UsdPrim& prim=UsdPrim())
81  : UsdAPISchemaBase(prim)
82  {
83  }
84 
88  explicit UsdRiMaterialAPI(const UsdSchemaBase& schemaObj)
89  : UsdAPISchemaBase(schemaObj)
90  {
91  }
92 
94  USDRI_API
95  virtual ~UsdRiMaterialAPI();
96 
100  USDRI_API
101  static const TfTokenVector &
102  GetSchemaAttributeNames(bool includeInherited=true);
103 
113  USDRI_API
114  static UsdRiMaterialAPI
115  Get(const UsdStagePtr &stage, const SdfPath &path);
116 
117 
130  USDRI_API
131  static UsdRiMaterialAPI
132  Apply(const UsdPrim &prim);
133 
134 protected:
138  USDRI_API
139  UsdSchemaType _GetSchemaType() const override;
140 
141 private:
142  // needs to invoke _GetStaticTfType.
143  friend class UsdSchemaRegistry;
144  USDRI_API
145  static const TfType &_GetStaticTfType();
146 
147  static bool _IsTypedSchema();
148 
149  // override SchemaBase virtuals.
150  USDRI_API
151  const TfType &_GetTfType() const override;
152 
153 public:
154  // --------------------------------------------------------------------- //
155  // SURFACE
156  // --------------------------------------------------------------------- //
163  USDRI_API
165 
171  USDRI_API
172  UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
173 
174 public:
175  // --------------------------------------------------------------------- //
176  // DISPLACEMENT
177  // --------------------------------------------------------------------- //
184  USDRI_API
186 
192  USDRI_API
193  UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
194 
195 public:
196  // --------------------------------------------------------------------- //
197  // VOLUME
198  // --------------------------------------------------------------------- //
205  USDRI_API
206  UsdAttribute GetVolumeAttr() const;
207 
213  USDRI_API
214  UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
215 
216 public:
217  // ===================================================================== //
218  // Feel free to add custom code below this line, it will be preserved by
219  // the code generator.
220  //
221  // Just remember to:
222  // - Close the class declaration with };
223  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
224  // - Close the include guard with #endif
225  // ===================================================================== //
226  // --(BEGIN CUSTOM CODE)--
227 
229  explicit UsdRiMaterialAPI(const UsdShadeMaterial& material)
230  : UsdRiMaterialAPI(material.GetPrim())
231  {
232  }
233 
234  // --------------------------------------------------------------------- //
236  // --------------------------------------------------------------------- //
238 
240  USDRI_API
242 
244  USDRI_API
246 
248  USDRI_API
250 
252 
253  // --------------------------------------------------------------------- //
255  // --------------------------------------------------------------------- //
257 
258  USDRI_API
259  bool SetSurfaceSource(const SdfPath &surfacePath) const;
260 
261  USDRI_API
262  bool SetDisplacementSource(const SdfPath &displacementPath) const;
263 
264  USDRI_API
265  bool SetVolumeSource(const SdfPath &volumePath) const;
266 
268 
269  // --------------------------------------------------------------------- //
271  // --------------------------------------------------------------------- //
273 
280  USDRI_API
281  UsdShadeShader GetSurface(bool ignoreBaseMaterial=false) const;
282 
289  USDRI_API
290  UsdShadeShader GetDisplacement(bool ignoreBaseMaterial=false) const;
291 
298  USDRI_API
299  UsdShadeShader GetVolume(bool ignoreBaseMaterial=false) const;
300 
302 
303 
304  // --------------------------------------------------------------------- //
308  // --------------------------------------------------------------------- //
310 
316  USDRI_API
317  bool SetInterfaceInputConsumer(UsdShadeInput &interfaceInput,
318  const UsdShadeInput &consumer) const;
319 
324  USDRI_API
327  bool computeTransitiveConsumers=false) const;
328 
330  USDRI_API
331  std::vector<UsdShadeInput> GetInterfaceInputs() const;
332 
334 
335 private:
336  UsdShadeShader _GetSourceShaderObject(const UsdShadeOutput &output,
337  bool ignoreBaseMaterial) const;
338 
339  // Helper method to get the deprecated 'bxdf' output.
340  UsdShadeOutput _GetBxdfOutput(const UsdPrim &materialPrim) const;
341 };
342 
343 PXR_NAMESPACE_CLOSE_SCOPE
344 
345 #endif
USDRI_API UsdShadeOutput GetDisplacementOutput() const
Returns the &quot;displacement&quot; output associated with the material.
USDRI_API UsdShadeShader GetDisplacement(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the &quot;displacement&quot; output on the material is connected to one...
USDRI_API UsdShadeShader GetVolume(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the &quot;volume&quot; output on the material is connected to one...
virtual USDRI_API ~UsdRiMaterialAPI()
Destructor.
USDRI_API std::vector< UsdShadeInput > GetInterfaceInputs() const
Returns all the interface inputs belonging to the material.
std::unordered_map< UsdShadeInput, std::vector< UsdShadeInput >, UsdShadeInput::Hash > InterfaceInputConsumersMap
Map of interface inputs to corresponding vectors of inputs that consume their values.
Definition: nodeGraph.h:346
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
Definition: materialAPI.h:74
USDRI_API UsdAttribute GetSurfaceAttr() const
C++ Type: TfToken Usd Type: SdfValueTypeNames-&gt;Token Variability: SdfVariabilityVarying Fallb...
The base class for all API schemas.
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
This class encapsulates a shader or node-graph input, which is a connectable property representing a ...
Definition: input.h:46
USDRI_API UsdShadeOutput GetVolumeOutput() const
Returns the &quot;volume&quot; output associated with the material.
UsdRiMaterialAPI(const UsdSchemaBase &schemaObj)
Construct a UsdRiMaterialAPI on the prim held by schemaObj .
Definition: materialAPI.h:88
USDRI_API bool SetInterfaceInputConsumer(UsdShadeInput &interfaceInput, const UsdShadeInput &consumer) const
Set the input consumer of the given interfaceInput to the specified input, consumer.
USDRI_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...
UsdSchemaType
An enum representing which type of schema a given schema class belongs to.
Definition: common.h:149
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
Single Apply API schema.
USDRI_API UsdShadeOutput GetSurfaceOutput() const
Returns the &quot;surface&quot; output associated with the material.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
USDRI_API UsdAttribute GetDisplacementAttr() const
C++ Type: TfToken Usd Type: SdfValueTypeNames-&gt;Token Variability: SdfVariabilityVarying Fallb...
USDRI_API UsdAttribute GetVolumeAttr() const
C++ Type: TfToken Usd Type: SdfValueTypeNames-&gt;Token Variability: SdfVariabilityVarying Fallb...
USDRI_API UsdShadeShader GetSurface(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the &quot;surface&quot; output on the material is connected to one...
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
UsdRiMaterialAPI(const UsdShadeMaterial &material)
A constructor for creating a MaterialAPI object from a material prim.
Definition: materialAPI.h:229
USDRI_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...
USDRI_API UsdSchemaType _GetSchemaType() const override
Returns the type of schema this class belongs to.
static USDRI_API UsdRiMaterialAPI Apply(const UsdPrim &prim)
Applies this single-apply API schema to the given prim.
static USDRI_API UsdRiMaterialAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdRiMaterialAPI holding the prim adhering to this schema at path on stage.
UsdRiMaterialAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdRiMaterialAPI on UsdPrim prim .
Definition: materialAPI.h:80
Base class for all USD shaders.
Definition: shader.h:89
TfType represents a dynamic runtime type.
Definition: type.h:70
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 USDRI_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...
USDRI_API UsdShadeNodeGraph::InterfaceInputConsumersMap ComputeInterfaceInputConsumersMap(bool computeTransitiveConsumers=false) const
Walks the namespace subtree below the material and computes a map containing the list of all inputs o...
USDRI_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...
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
This API provides outputs that connect a material prim to prman shaders and RIS objects.
Definition: materialAPI.h:68
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
UsdPrim GetPrim() const
Return this schema object&#39;s held prim.
Definition: schemaBase.h:119