All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shader.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_SHADER_H
25 #define USDSHADE_GENERATED_SHADER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdShade/api.h"
31 #include "pxr/usd/usd/typed.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/usdShade/input.h"
37 #include "pxr/usd/usdShade/output.h"
38 #include "pxr/usd/ndr/declare.h"
39 #include "pxr/usd/sdr/shaderNode.h"
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 // SHADER //
56 // -------------------------------------------------------------------------- //
57 
89 class UsdShadeShader : public UsdTyped
90 {
91 public:
96 
101  explicit UsdShadeShader(const UsdPrim& prim=UsdPrim())
102  : UsdTyped(prim)
103  {
104  }
105 
109  explicit UsdShadeShader(const UsdSchemaBase& schemaObj)
110  : UsdTyped(schemaObj)
111  {
112  }
113 
115  USDSHADE_API
116  virtual ~UsdShadeShader();
117 
121  USDSHADE_API
122  static const TfTokenVector &
123  GetSchemaAttributeNames(bool includeInherited=true);
124 
134  USDSHADE_API
135  static UsdShadeShader
136  Get(const UsdStagePtr &stage, const SdfPath &path);
137 
160  USDSHADE_API
161  static UsdShadeShader
162  Define(const UsdStagePtr &stage, const SdfPath &path);
163 
164 protected:
168  USDSHADE_API
169  UsdSchemaType _GetSchemaType() const override;
170 
171 private:
172  // needs to invoke _GetStaticTfType.
173  friend class UsdSchemaRegistry;
174  USDSHADE_API
175  static const TfType &_GetStaticTfType();
176 
177  static bool _IsTypedSchema();
178 
179  // override SchemaBase virtuals.
180  USDSHADE_API
181  const TfType &_GetTfType() const override;
182 
183 public:
184  // --------------------------------------------------------------------- //
185  // IMPLEMENTATIONSOURCE
186  // --------------------------------------------------------------------- //
205  USDSHADE_API
207 
213  USDSHADE_API
214  UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
215 
216 public:
217  // --------------------------------------------------------------------- //
218  // ID
219  // --------------------------------------------------------------------- //
233  USDSHADE_API
234  UsdAttribute GetIdAttr() const;
235 
241  USDSHADE_API
242  UsdAttribute CreateIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
243 
244 public:
245  // ===================================================================== //
246  // Feel free to add custom code below this line, it will be preserved by
247  // the code generator.
248  //
249  // Just remember to:
250  // - Close the class declaration with };
251  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
252  // - Close the include guard with #endif
253  // ===================================================================== //
254  // --(BEGIN CUSTOM CODE)--
255 
260  USDSHADE_API
261  UsdShadeShader(const UsdShadeConnectableAPI &connectable);
262 
271  USDSHADE_API
273 
274  // -------------------------------------------------------------------------
284 
290  USDSHADE_API
291  UsdShadeOutput CreateOutput(const TfToken& name,
292  const SdfValueTypeName& typeName);
293 
296  USDSHADE_API
297  UsdShadeOutput GetOutput(const TfToken &name) const;
298 
301  USDSHADE_API
302  std::vector<UsdShadeOutput> GetOutputs() const;
303 
305 
306  // -------------------------------------------------------------------------
307 
316 
321  USDSHADE_API
322  UsdShadeInput CreateInput(const TfToken& name,
323  const SdfValueTypeName& typeName);
324 
327  USDSHADE_API
328  UsdShadeInput GetInput(const TfToken &name) const;
329 
332  USDSHADE_API
333  std::vector<UsdShadeInput> GetInputs() const;
334 
336 
337  // -------------------------------------------------------------------------
338 
346 
382  USDSHADE_API
384 
388  USDSHADE_API
389  bool SetShaderId(const TfToken &id) const;
390 
398  USDSHADE_API
399  bool GetShaderId(TfToken *id) const;
400 
406  USDSHADE_API
407  bool SetSourceAsset(
408  const SdfAssetPath &sourceAsset,
409  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
410 
426  USDSHADE_API
427  bool GetSourceAsset(
428  SdfAssetPath *sourceAsset,
429  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
430 
436  USDSHADE_API
437  bool SetSourceCode(
438  const std::string &sourceCode,
439  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
440 
456  USDSHADE_API
457  bool GetSourceCode(
458  std::string *sourceCode,
459  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
460 
462 
463  // -------------------------------------------------------------------------
464 
482 
485  USDSHADE_API
486  NdrTokenMap GetSdrMetadata() const;
487 
490  USDSHADE_API
491  std::string GetSdrMetadataByKey(const TfToken &key) const;
492 
495  USDSHADE_API
496  void SetSdrMetadata(const NdrTokenMap &sdrMetadata) const;
497 
500  USDSHADE_API
501  void SetSdrMetadataByKey(
502  const TfToken &key,
503  const std::string &value) const;
504 
507  USDSHADE_API
508  bool HasSdrMetadata() const;
509 
512  USDSHADE_API
513  bool HasSdrMetadataByKey(const TfToken &key) const;
514 
517  USDSHADE_API
518  void ClearSdrMetadata() const;
519 
522  USDSHADE_API
523  void ClearSdrMetadataByKey(const TfToken &key) const;
524 
526 
531  USDSHADE_API
532  SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType)
533  const;
534 
535 };
536 
537 PXR_NAMESPACE_CLOSE_SCOPE
538 
539 #endif
USDSHADE_API void ClearSdrMetadataByKey(const TfToken &key) const
Clears the entry corresponding to the given key in the &quot;sdrMetadata&quot; dictionary authored in the curre...
USDSHADE_API bool GetSourceAsset(SdfAssetPath *sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Fetches the shader&#39;s source asset value for the specified sourceType value from the info:sourceType:s...
USDSHADE_API UsdAttribute GetIdAttr() const
The id is an identifier for the type or purpose of the shader.
USDSHADE_API UsdAttribute GetImplementationSourceAttr() const
Specifies the attribute that should be consulted to get the shader&#39;s implementation or its source cod...
USDSHADE_API bool SetSourceAsset(const SdfAssetPath &sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Sets the shader&#39;s source-asset path value to sourceAsset for the given source type, sourceType.
USDSHADE_API std::vector< UsdShadeInput > GetInputs() const
Inputs are represented by attributes in the &quot;inputs:&quot; namespace.
USDSHADE_API bool HasSdrMetadata() const
Returns true if the shader has a non-empty composed &quot;sdrMetadata&quot; dictionary value.
USDSHADE_API bool SetSourceCode(const std::string &sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Sets the shader&#39;s source-code value to sourceCode for the given source type, sourceType.
USDSHADE_API TfToken GetImplementationSource() const
Reads the value of info:implementationSource attribute and returns a token identifying the attribute ...
Represents a value type name, i.e.
Definition: valueTypeName.h:83
USDSHADE_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName)
Create an output which can either have a value or can be connected.
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
Represents a concrete typed schema.
UsdShadeShader(const UsdSchemaBase &schemaObj)
Construct a UsdShadeShader on the prim held by schemaObj .
Definition: shader.h:109
USDSHADE_API UsdShadeConnectableAPI ConnectableAPI() const
Contructs and returns a UsdShadeConnectableAPI object with this shader.
USDSHADE_API bool SetShaderId(const TfToken &id) const
Sets the shader&#39;s ID value.
static USDSHADE_API UsdShadeShader Define(const UsdStagePtr &stage, const SdfPath &path)
Attempt to ensure a UsdPrim adhering to this schema at path is defined (according to UsdPrim::IsDefin...
This class encapsulates a shader or node-graph input, which is a connectable property representing a ...
Definition: input.h:46
USDSHADE_API NdrTokenMap GetSdrMetadata() const
Returns this shader&#39;s composed &quot;sdrMetadata&quot; dictionary as a NdrTokenMap.
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
Definition: shader.h:95
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
USDSHADE_API TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.
USDSHADE_API SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType) const
This method attempts to ensure that there is a ShaderNode in the shader registry (i.e.
UsdShadeShader(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeShader on UsdPrim prim .
Definition: shader.h:101
UsdShadeConnectableAPI is an API schema that provides a common interface for creating outputs and mak...
UsdSchemaType
An enum representing which type of schema a given schema class belongs to.
Definition: common.h:149
USDSHADE_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName)
Create an input which can either have a value or can be connected.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
The base class for all typed schemas (those that can impart a typeName to a UsdPrim), and therefore the base class for all instantiable and &quot;IsA&quot; schemas.
Definition: typed.h:47
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
USDSHADE_API void ClearSdrMetadata() const
Clears any &quot;sdrMetadata&quot; value authored on the shader in the current EditTarget.
USDSHADE_API UsdSchemaType _GetSchemaType() const override
Returns the type of schema this class belongs to.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
USDSHADE_API void SetSdrMetadataByKey(const TfToken &key, const std::string &value) const
Sets the value corresponding to key to the given string value, in the shader&#39;s &quot;sdrMetadata&quot; dictiona...
USDSHADE_API UsdAttribute CreateIdAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetIdAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs() const
Outputs are represented by attributes in the &quot;outputs:&quot; namespace.
static USDSHADE_API UsdShadeShader Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdShadeShader holding the prim adhering to this schema at path on stage.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
USDSHADE_API bool HasSdrMetadataByKey(const TfToken &key) const
Returns true if there is a value corresponding to the given key in the composed &quot;sdrMetadata&quot; diction...
USDSHADE_API std::string GetSdrMetadataByKey(const TfToken &key) const
Returns the value corresponding to key in the composed sdrMetadata dictionary.
USDSHADE_API UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetImplementationSourceAttr(), and also Create vs Get Property Methods for when to use Get vs Cre...
USDSHADE_API UsdShadeInput GetInput(const TfToken &name) const
Return the requested input if it exists.
Base class for all USD shaders.
Definition: shader.h:89
virtual USDSHADE_API ~UsdShadeShader()
Destructor.
TfType represents a dynamic runtime type.
Definition: type.h:70
Singleton registry that provides access to prim and property definition information for registered Us...
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 bool GetSourceCode(std::string *sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Fetches the shader&#39;s source code for the specified sourceType value by reading the info:sourceType:so...
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 UsdShadeOutput GetOutput(const TfToken &name) const
Return the requested output if it exists.
USDSHADE_API bool GetShaderId(TfToken *id) const
Fetches the shader&#39;s ID value from the info:id attribute, if the shader&#39;s info:implementationSource i...
USDSHADE_API void SetSdrMetadata(const NdrTokenMap &sdrMetadata) const
Authors the given sdrMetadata on this shader at the current EditTarget.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182