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 
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 
200  USDSHADE_API
201  UsdShadeShader(const UsdShadeConnectableAPI &connectable);
202 
211  USDSHADE_API
213 
215 
216  // -------------------------------------------------------------------------
226 
232  USDSHADE_API
233  UsdShadeOutput CreateOutput(const TfToken& name,
234  const SdfValueTypeName& typeName);
235 
238  USDSHADE_API
239  UsdShadeOutput GetOutput(const TfToken &name) const;
240 
245  USDSHADE_API
246  std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
247 
249 
250  // -------------------------------------------------------------------------
251 
260 
265  USDSHADE_API
266  UsdShadeInput CreateInput(const TfToken& name,
267  const SdfValueTypeName& typeName);
268 
271  USDSHADE_API
272  UsdShadeInput GetInput(const TfToken &name) const;
273 
278  USDSHADE_API
279  std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
280 
282 
283  // -------------------------------------------------------------------------
287 
289  USDSHADE_API
291 
293  USDSHADE_API
294  UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
295 
297  USDSHADE_API
298  UsdAttribute GetIdAttr() const;
299 
301  USDSHADE_API
302  UsdAttribute CreateIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
303 
305  USDSHADE_API
307 
309  USDSHADE_API
310  bool SetShaderId(const TfToken &id) const;
311 
313  USDSHADE_API
314  bool GetShaderId(TfToken *id) const;
315 
317  USDSHADE_API
318  bool SetSourceAsset(
319  const SdfAssetPath &sourceAsset,
320  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
321 
323  USDSHADE_API
324  bool GetSourceAsset(
325  SdfAssetPath *sourceAsset,
326  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
327 
329  USDSHADE_API
331  const TfToken &subIdentifier,
332  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
333 
335  USDSHADE_API
337  TfToken *subIdentifier,
338  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
339 
341  USDSHADE_API
342  bool SetSourceCode(
343  const std::string &sourceCode,
344  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
345 
347  USDSHADE_API
348  bool GetSourceCode(
349  std::string *sourceCode,
350  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
351 
353  USDSHADE_API
354  SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType)
355  const;
356 
358 
359  // -------------------------------------------------------------------------
360 
378 
381  USDSHADE_API
382  NdrTokenMap GetSdrMetadata() const;
383 
386  USDSHADE_API
387  std::string GetSdrMetadataByKey(const TfToken &key) const;
388 
391  USDSHADE_API
392  void SetSdrMetadata(const NdrTokenMap &sdrMetadata) const;
393 
396  USDSHADE_API
397  void SetSdrMetadataByKey(
398  const TfToken &key,
399  const std::string &value) const;
400 
403  USDSHADE_API
404  bool HasSdrMetadata() const;
405 
408  USDSHADE_API
409  bool HasSdrMetadataByKey(const TfToken &key) const;
410 
413  USDSHADE_API
414  void ClearSdrMetadata() const;
415 
418  USDSHADE_API
419  void ClearSdrMetadataByKey(const TfToken &key) const;
420 
422 };
423 
424 PXR_NAMESPACE_CLOSE_SCOPE
425 
426 #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
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API bool SetSourceAssetSubIdentifier(const TfToken &subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API UsdAttribute GetIdAttr() const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API UsdAttribute GetImplementationSourceAttr() const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API bool SetSourceAsset(const SdfAssetPath &sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
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
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API TfToken GetImplementationSource() const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
Outputs are represented by attributes in the &quot;outputs:&quot; namespace.
Represents a value type name, i.e.
Definition: valueTypeName.h:87
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
UsdShadeShader(const UsdSchemaBase &schemaObj)
Construct a UsdShadeShader on the prim held by schemaObj .
Definition: shader.h:105
USDSHADE_API UsdShadeConnectableAPI ConnectableAPI() const
Contructs and returns a UsdShadeConnectableAPI object with this shader.
USDSHADE_API bool SetShaderId(const TfToken &id) const
Forwards to UsdShadeNodeDefAPI(prim).
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
USDSHADE_API NdrTokenMap GetSdrMetadata() const
Returns this shader&#39;s composed &quot;sdrMetadata&quot; dictionary as a NdrTokenMap.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
USDSHADE_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
Inputs are represented by attributes in the &quot;inputs:&quot; namespace.
USDSHADE_API SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
UsdShadeShader(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeShader on UsdPrim prim .
Definition: shader.h:97
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 &quot;Prim&quot; as ...
Definition: prim.h:132
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:442
USDSHADE_API void ClearSdrMetadata() const
Clears any &quot;sdrMetadata&quot; value authored on the shader in the current EditTarget.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
USDSHADE_API TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.
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
Forwards to UsdShadeNodeDefAPI(prim).
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 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
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.
TfType represents a dynamic runtime type.
Definition: type.h:64
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...
USDSHADE_API bool GetSourceCode(std::string *sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
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 GetSourceAssetSubIdentifier(TfToken *subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API bool GetShaderId(TfToken *id) const
Forwards to UsdShadeNodeDefAPI(prim).
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:168
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...