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 
35 #include "pxr/usd/usdShade/input.h"
36 #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 
85 class UsdShadeShader : public UsdTyped
86 {
87 public:
92 
97  explicit UsdShadeShader(const UsdPrim& prim=UsdPrim())
98  : UsdTyped(prim)
99  {
100  }
101 
105  explicit UsdShadeShader(const UsdSchemaBase& schemaObj)
106  : UsdTyped(schemaObj)
107  {
108  }
109 
111  USDSHADE_API
112  virtual ~UsdShadeShader();
113 
117  USDSHADE_API
118  static const TfTokenVector &
119  GetSchemaAttributeNames(bool includeInherited=true);
120 
130  USDSHADE_API
131  static UsdShadeShader
132  Get(const UsdStagePtr &stage, const SdfPath &path);
133 
156  USDSHADE_API
157  static UsdShadeShader
158  Define(const UsdStagePtr &stage, const SdfPath &path);
159 
160 protected:
164  USDSHADE_API
165  UsdSchemaKind _GetSchemaKind() const override;
166 
167 private:
168  // needs to invoke _GetStaticTfType.
169  friend class UsdSchemaRegistry;
170  USDSHADE_API
171  static const TfType &_GetStaticTfType();
172 
173  static bool _IsTypedSchema();
174 
175  // override SchemaBase virtuals.
176  USDSHADE_API
177  const TfType &_GetTfType() const override;
178 
179 public:
180  // ===================================================================== //
181  // Feel free to add custom code below this line, it will be preserved by
182  // the code generator.
183  //
184  // Just remember to:
185  // - Close the class declaration with };
186  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
187  // - Close the include guard with #endif
188  // ===================================================================== //
189  // --(BEGIN CUSTOM CODE)--
190 
191  // -------------------------------------------------------------------------
195 
203  USDSHADE_API
204  UsdShadeShader(const UsdShadeConnectableAPI &connectable);
205 
214  USDSHADE_API
216 
218 
219  // -------------------------------------------------------------------------
229 
235  USDSHADE_API
236  UsdShadeOutput CreateOutput(const TfToken& name,
237  const SdfValueTypeName& typeName);
238 
241  USDSHADE_API
242  UsdShadeOutput GetOutput(const TfToken &name) const;
243 
248  USDSHADE_API
249  std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
250 
252 
253  // -------------------------------------------------------------------------
254 
263 
268  USDSHADE_API
269  UsdShadeInput CreateInput(const TfToken& name,
270  const SdfValueTypeName& typeName);
271 
274  USDSHADE_API
275  UsdShadeInput GetInput(const TfToken &name) const;
276 
281  USDSHADE_API
282  std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
283 
285 
286  // -------------------------------------------------------------------------
290 
292  USDSHADE_API
294 
296  USDSHADE_API
297  UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
298 
300  USDSHADE_API
301  UsdAttribute GetIdAttr() const;
302 
304  USDSHADE_API
305  UsdAttribute CreateIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
306 
308  USDSHADE_API
310 
312  USDSHADE_API
313  bool SetShaderId(const TfToken &id) const;
314 
316  USDSHADE_API
317  bool GetShaderId(TfToken *id) const;
318 
320  USDSHADE_API
321  bool SetSourceAsset(
322  const SdfAssetPath &sourceAsset,
323  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
324 
326  USDSHADE_API
327  bool GetSourceAsset(
328  SdfAssetPath *sourceAsset,
329  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
330 
332  USDSHADE_API
334  const TfToken &subIdentifier,
335  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
336 
338  USDSHADE_API
340  TfToken *subIdentifier,
341  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
342 
344  USDSHADE_API
345  bool SetSourceCode(
346  const std::string &sourceCode,
347  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
348 
350  USDSHADE_API
351  bool GetSourceCode(
352  std::string *sourceCode,
353  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
354 
356  USDSHADE_API
357  SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType)
358  const;
359 
361 
362  // -------------------------------------------------------------------------
363 
381 
384  USDSHADE_API
385  NdrTokenMap GetSdrMetadata() const;
386 
389  USDSHADE_API
390  std::string GetSdrMetadataByKey(const TfToken &key) const;
391 
394  USDSHADE_API
395  void SetSdrMetadata(const NdrTokenMap &sdrMetadata) const;
396 
399  USDSHADE_API
400  void SetSdrMetadataByKey(
401  const TfToken &key,
402  const std::string &value) const;
403 
406  USDSHADE_API
407  bool HasSdrMetadata() const;
408 
411  USDSHADE_API
412  bool HasSdrMetadataByKey(const TfToken &key) const;
413 
416  USDSHADE_API
417  void ClearSdrMetadata() const;
418 
421  USDSHADE_API
422  void ClearSdrMetadataByKey(const TfToken &key) const;
423 
425 };
426 
427 PXR_NAMESPACE_CLOSE_SCOPE
428 
429 #endif
USDSHADE_API UsdAttribute GetImplementationSourceAttr() const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API bool SetSourceCode(const std::string &sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API void ClearSdrMetadata() const
Clears any "sdrMetadata" value authored on the shader in the current EditTarget.
USDSHADE_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
Inputs are represented by attributes in the "inputs:" namespace.
USDSHADE_API void ClearSdrMetadataByKey(const TfToken &key) const
Clears the entry corresponding to the given key in the "sdrMetadata" dictionary authored in the curre...
Represents a value type name, i.e.
Definition: valueTypeName.h:87
USDSHADE_API SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName)
Create an output which can either have a value or can be connected.
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
Outputs are represented by attributes in the "outputs:" namespace.
USDSHADE_API void SetSdrMetadata(const NdrTokenMap &sdrMetadata) const
Authors the given sdrMetadata on this shader at the current EditTarget.
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
UsdShadeShader(const UsdSchemaBase &schemaObj)
Construct a UsdShadeShader on the prim held by schemaObj .
Definition: shader.h:105
USDSHADE_API bool HasSdrMetadata() const
Returns true if the shader has a non-empty composed "sdrMetadata" dictionary 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 attribute representing a...
Definition: input.h:48
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
USDSHADE_API bool SetSourceAsset(const SdfAssetPath &sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
UsdShadeShader(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeShader on UsdPrim prim .
Definition: shader.h:97
USDSHADE_API UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API TfToken GetImplementationSource() const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API bool GetSourceAsset(SdfAssetPath *sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
UsdShadeConnectableAPI is an API schema that provides a common interface for creating outputs and mak...
Represents a concrete typed schema.
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 "Prim" as ...
Definition: prim.h:135
The base class for all typed schemas (those that can impart a typeName to a UsdPrim),...
Definition: typed.h:61
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
USDSHADE_API UsdShadeConnectableAPI ConnectableAPI() const
Contructs and returns a UsdShadeConnectableAPI object with this shader.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
USDSHADE_API TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.
USDSHADE_API bool SetSourceAssetSubIdentifier(const TfToken &subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API NdrTokenMap GetSdrMetadata() const
Returns this shader's composed "sdrMetadata" dictionary as a NdrTokenMap.
USDSHADE_API UsdShadeOutput GetOutput(const TfToken &name) const
Return the requested output if it exists.
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: shader.h:91
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:47
USDSHADE_API bool GetShaderId(TfToken *id) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API UsdShadeInput GetInput(const TfToken &name) const
Return the requested input if it exists.
Base class for all USD shaders.
Definition: shader.h:85
virtual USDSHADE_API ~UsdShadeShader()
Destructor.
USDSHADE_API std::string GetSdrMetadataByKey(const TfToken &key) const
Returns the value corresponding to key in the composed sdrMetadata dictionary.
TfType represents a dynamic runtime type.
Definition: type.h:64
USDSHADE_API bool SetShaderId(const TfToken &id) const
Forwards to UsdShadeNodeDefAPI(prim).
Singleton registry that provides access to schema type information and the prim definitions for regis...
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...
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:47
USDSHADE_API UsdAttribute GetIdAttr() const
Forwards to UsdShadeNodeDefAPI(prim).
The base class for all schema types in Usd.
Definition: schemaBase.h:56
USDSHADE_API bool GetSourceCode(std::string *sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API bool HasSdrMetadataByKey(const TfToken &key) const
Returns true if there is a value corresponding to the given key in the composed "sdrMetadata" diction...
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's "sdrMetadata" dictiona...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:166
USDSHADE_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
USDSHADE_API bool GetSourceAssetSubIdentifier(TfToken *subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API UsdAttribute CreateIdAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Forwards to UsdShadeNodeDefAPI(prim).