All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
shader.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef USDSHADE_GENERATED_SHADER_H
8#define USDSHADE_GENERATED_SHADER_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usdShade/api.h"
14#include "pxr/usd/usd/typed.h"
15#include "pxr/usd/usd/prim.h"
16#include "pxr/usd/usd/stage.h"
17
18#include "pxr/usd/usdShade/input.h"
19#include "pxr/usd/usdShade/output.h"
21#include "pxr/usd/ndr/declare.h"
23
24#include "pxr/base/vt/value.h"
25
26#include "pxr/base/gf/vec3d.h"
27#include "pxr/base/gf/vec3f.h"
29
30#include "pxr/base/tf/token.h"
31#include "pxr/base/tf/type.h"
32
33PXR_NAMESPACE_OPEN_SCOPE
34
35class SdfAssetPath;
36
37// -------------------------------------------------------------------------- //
38// SHADER //
39// -------------------------------------------------------------------------- //
40
69{
70public:
74 static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
75
80 explicit UsdShadeShader(const UsdPrim& prim=UsdPrim())
81 : UsdTyped(prim)
82 {
83 }
84
88 explicit UsdShadeShader(const UsdSchemaBase& schemaObj)
89 : UsdTyped(schemaObj)
90 {
91 }
92
94 USDSHADE_API
95 virtual ~UsdShadeShader();
96
100 USDSHADE_API
101 static const TfTokenVector &
102 GetSchemaAttributeNames(bool includeInherited=true);
103
113 USDSHADE_API
114 static UsdShadeShader
115 Get(const UsdStagePtr &stage, const SdfPath &path);
116
139 USDSHADE_API
140 static UsdShadeShader
141 Define(const UsdStagePtr &stage, const SdfPath &path);
142
143protected:
147 USDSHADE_API
149
150private:
151 // needs to invoke _GetStaticTfType.
152 friend class UsdSchemaRegistry;
153 USDSHADE_API
154 static const TfType &_GetStaticTfType();
155
156 static bool _IsTypedSchema();
157
158 // override SchemaBase virtuals.
159 USDSHADE_API
160 const TfType &_GetTfType() const override;
161
162public:
163 // ===================================================================== //
164 // Feel free to add custom code below this line, it will be preserved by
165 // the code generator.
166 //
167 // Just remember to:
168 // - Close the class declaration with };
169 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
170 // - Close the include guard with #endif
171 // ===================================================================== //
172 // --(BEGIN CUSTOM CODE)--
173
174 // -------------------------------------------------------------------------
178
186 USDSHADE_API
188
197 USDSHADE_API
199
201
202 // -------------------------------------------------------------------------
212
218 USDSHADE_API
220 const SdfValueTypeName& typeName);
221
224 USDSHADE_API
225 UsdShadeOutput GetOutput(const TfToken &name) const;
226
231 USDSHADE_API
232 std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
233
235
236 // -------------------------------------------------------------------------
237
246
251 USDSHADE_API
253 const SdfValueTypeName& typeName);
254
257 USDSHADE_API
258 UsdShadeInput GetInput(const TfToken &name) const;
259
264 USDSHADE_API
265 std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
266
268
269 // -------------------------------------------------------------------------
273
275 USDSHADE_API
277
279 USDSHADE_API
280 UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
281
283 USDSHADE_API
285
287 USDSHADE_API
288 UsdAttribute CreateIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
289
291 USDSHADE_API
293
295 USDSHADE_API
296 bool SetShaderId(const TfToken &id) const;
297
299 USDSHADE_API
300 bool GetShaderId(TfToken *id) const;
301
303 USDSHADE_API
305 const SdfAssetPath &sourceAsset,
306 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
307
309 USDSHADE_API
311 SdfAssetPath *sourceAsset,
312 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
313
315 USDSHADE_API
317 const TfToken &subIdentifier,
318 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
319
321 USDSHADE_API
323 TfToken *subIdentifier,
324 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
325
327 USDSHADE_API
329 const std::string &sourceCode,
330 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
331
333 USDSHADE_API
335 std::string *sourceCode,
336 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
337
339 USDSHADE_API
340 std::vector<std::string> GetSourceTypes() const;
341
343 USDSHADE_API
344 SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType)
345 const;
346
348
349 // -------------------------------------------------------------------------
350
368
371 USDSHADE_API
372 NdrTokenMap GetSdrMetadata() const;
373
376 USDSHADE_API
377 std::string GetSdrMetadataByKey(const TfToken &key) const;
378
381 USDSHADE_API
382 void SetSdrMetadata(const NdrTokenMap &sdrMetadata) const;
383
386 USDSHADE_API
388 const TfToken &key,
389 const std::string &value) const;
390
393 USDSHADE_API
394 bool HasSdrMetadata() const;
395
398 USDSHADE_API
399 bool HasSdrMetadataByKey(const TfToken &key) const;
400
403 USDSHADE_API
404 void ClearSdrMetadata() const;
405
408 USDSHADE_API
409 void ClearSdrMetadataByKey(const TfToken &key) const;
410
412};
413
414PXR_NAMESPACE_CLOSE_SCOPE
415
416#endif
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Represents a value type name, i.e.
Definition: valueTypeName.h:71
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
TfType represents a dynamic runtime type.
Definition: type.h:48
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:160
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
The base class for all schema types in Usd.
Definition: schemaBase.h:39
Singleton registry that provides access to schema type information and the prim definitions for regis...
UsdShadeConnectableAPI is an API schema that provides a common interface for creating outputs and mak...
This class encapsulates a shader or node-graph input, which is a connectable attribute representing a...
Definition: input.h:32
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:31
Base class for all USD shaders.
Definition: shader.h:69
USDSHADE_API bool GetSourceCode(std::string *sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API bool GetSourceAsset(SdfAssetPath *sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API std::string GetSdrMetadataByKey(const TfToken &key) const
Returns the value corresponding to key in the composed sdrMetadata dictionary.
USDSHADE_API UsdShadeConnectableAPI ConnectableAPI() const
Contructs and returns a UsdShadeConnectableAPI object with this shader.
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).
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.
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: shader.h:74
virtual USDSHADE_API ~UsdShadeShader()
Destructor.
USDSHADE_API UsdShadeInput GetInput(const TfToken &name) const
Return the requested input if it exists.
USDSHADE_API bool SetShaderId(const TfToken &id) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API std::vector< std::string > GetSourceTypes() const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API NdrTokenMap GetSdrMetadata() const
Returns this shader's composed "sdrMetadata" dictionary as a NdrTokenMap.
UsdShadeShader(const UsdSchemaBase &schemaObj)
Construct a UsdShadeShader on the prim held by schemaObj .
Definition: shader.h:88
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 UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
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...
USDSHADE_API void SetSdrMetadata(const NdrTokenMap &sdrMetadata) const
Authors the given sdrMetadata on this shader at the current EditTarget.
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 void ClearSdrMetadata() const
Clears any "sdrMetadata" value authored on the shader in the current EditTarget.
USDSHADE_API bool GetSourceAssetSubIdentifier(TfToken *subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API bool HasSdrMetadata() const
Returns true if the shader has a non-empty composed "sdrMetadata" dictionary value.
USDSHADE_API bool SetSourceAssetSubIdentifier(const TfToken &subIdentifier, 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 UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName)
Create an output which can either have a value or can be connected.
USDSHADE_API UsdShadeOutput GetOutput(const TfToken &name) const
Return the requested output if it exists.
USDSHADE_API bool GetShaderId(TfToken *id) const
Forwards to UsdShadeNodeDefAPI(prim).
UsdShadeShader(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeShader on UsdPrim prim .
Definition: shader.h:80
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...
USDSHADE_API void ClearSdrMetadataByKey(const TfToken &key) const
Clears the entry corresponding to the given key in the "sdrMetadata" dictionary authored in the curre...
USDSHADE_API UsdShadeShader(const UsdShadeConnectableAPI &connectable)
Constructor that takes a ConnectableAPI object.
USDSHADE_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName)
Create an input which can either have a value or can be connected.
USDSHADE_API UsdAttribute GetIdAttr() const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API UsdAttribute CreateIdAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Forwards to UsdShadeNodeDefAPI(prim).
USDSHADE_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
Inputs are represented by attributes in the "inputs:" namespace.
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
Outputs are represented by attributes in the "outputs:" namespace.
The base class for all typed schemas (those that can impart a typeName to a UsdPrim),...
Definition: typed.h:45
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:112
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Common typedefs that are used throughout the NDR library.
USDSHADE_API TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.