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"
37 #include "pxr/usd/usdShade/tokens.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  UsdSchemaType _GetSchemaType() 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 
243  USDSHADE_API
244  std::vector<UsdShadeOutput> GetOutputs() const;
245 
247 
248  // -------------------------------------------------------------------------
249 
258 
263  USDSHADE_API
264  UsdShadeInput CreateInput(const TfToken& name,
265  const SdfValueTypeName& typeName);
266 
269  USDSHADE_API
270  UsdShadeInput GetInput(const TfToken &name) const;
271 
274  USDSHADE_API
275  std::vector<UsdShadeInput> GetInputs() const;
276 
278 
279  // -------------------------------------------------------------------------
283 
285  USDSHADE_API
287 
289  USDSHADE_API
290  UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
291 
293  USDSHADE_API
294  UsdAttribute GetIdAttr() const;
295 
297  USDSHADE_API
298  UsdAttribute CreateIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
299 
301  USDSHADE_API
303 
305  USDSHADE_API
306  bool SetShaderId(const TfToken &id) const;
307 
309  USDSHADE_API
310  bool GetShaderId(TfToken *id) const;
311 
313  USDSHADE_API
314  bool SetSourceAsset(
315  const SdfAssetPath &sourceAsset,
316  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
317 
319  USDSHADE_API
320  bool GetSourceAsset(
321  SdfAssetPath *sourceAsset,
322  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
323 
325  USDSHADE_API
327  const TfToken &subIdentifier,
328  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
329 
331  USDSHADE_API
333  TfToken *subIdentifier,
334  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
335 
337  USDSHADE_API
338  bool SetSourceCode(
339  const std::string &sourceCode,
340  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
341 
343  USDSHADE_API
344  bool GetSourceCode(
345  std::string *sourceCode,
346  const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
347 
349  USDSHADE_API
350  SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType)
351  const;
352 
354 
355  // -------------------------------------------------------------------------
356 
374 
377  USDSHADE_API
378  NdrTokenMap GetSdrMetadata() const;
379 
382  USDSHADE_API
383  std::string GetSdrMetadataByKey(const TfToken &key) const;
384 
387  USDSHADE_API
388  void SetSdrMetadata(const NdrTokenMap &sdrMetadata) const;
389 
392  USDSHADE_API
393  void SetSdrMetadataByKey(
394  const TfToken &key,
395  const std::string &value) const;
396 
399  USDSHADE_API
400  bool HasSdrMetadata() const;
401 
404  USDSHADE_API
405  bool HasSdrMetadataByKey(const TfToken &key) const;
406 
409  USDSHADE_API
410  void ClearSdrMetadata() const;
411 
414  USDSHADE_API
415  void ClearSdrMetadataByKey(const TfToken &key) const;
416 
418 };
419 
420 PXR_NAMESPACE_CLOSE_SCOPE
421 
422 #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 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
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API TfToken GetImplementationSource() const
Forwards to UsdShadeNodeDefAPI(prim).
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: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: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:91
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
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
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...
UsdSchemaType
An enum representing which type of schema a given schema class belongs to.
Definition: common.h:127
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.
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:288
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).
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
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:45
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