HDK
|
#include <nodeDefAPI.h>
Public Member Functions | |
UsdShadeNodeDefAPI (const UsdPrim &prim=UsdPrim()) | |
UsdShadeNodeDefAPI (const UsdSchemaBase &schemaObj) | |
virtual USDSHADE_API | ~UsdShadeNodeDefAPI () |
Destructor. More... | |
USDSHADE_API UsdAttribute | GetImplementationSourceAttr () const |
USDSHADE_API UsdAttribute | CreateImplementationSourceAttr (VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const |
USDSHADE_API UsdAttribute | GetIdAttr () const |
USDSHADE_API UsdAttribute | CreateIdAttr (VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const |
USDSHADE_API SdrShaderNodeConstPtr | GetShaderNodeForSourceType (const TfToken &sourceType) const |
Shader Source API | |
USDSHADE_API TfToken | GetImplementationSource () const |
USDSHADE_API bool | SetShaderId (const TfToken &id) const |
USDSHADE_API bool | GetShaderId (TfToken *id) const |
USDSHADE_API bool | SetSourceAsset (const SdfAssetPath &sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const |
USDSHADE_API bool | GetSourceAsset (SdfAssetPath *sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const |
USDSHADE_API bool | SetSourceAssetSubIdentifier (const TfToken &subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const |
USDSHADE_API bool | GetSourceAssetSubIdentifier (TfToken *subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const |
USDSHADE_API bool | SetSourceCode (const std::string &sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const |
USDSHADE_API bool | GetSourceCode (std::string *sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const |
Public Member Functions inherited from UsdAPISchemaBase | |
UsdAPISchemaBase (const UsdPrim &prim=UsdPrim()) | |
UsdAPISchemaBase (const UsdSchemaBase &schemaObj) | |
virtual USD_API | ~UsdAPISchemaBase ()=0 |
Destructor. More... | |
Public Member Functions inherited from UsdSchemaBase | |
bool | IsConcrete () const |
bool | IsTyped () const |
bool | IsAPISchema () const |
Returns whether this is an API schema or not. More... | |
bool | IsAppliedAPISchema () const |
bool | IsMultipleApplyAPISchema () const |
UsdSchemaKind | GetSchemaKind () const |
Returns the kind of schema this class is. More... | |
USD_API | UsdSchemaBase (const UsdPrim &prim=UsdPrim()) |
Construct and store prim as the held prim. More... | |
USD_API | UsdSchemaBase (const UsdSchemaBase &otherSchema) |
Construct and store for the same prim held by otherSchema . More... | |
virtual USD_API | ~UsdSchemaBase () |
Destructor. More... | |
USD_API | operator bool () const |
UsdPrim | GetPrim () const |
Return this schema object's held prim. More... | |
SdfPath | GetPath () const |
Shorthand for GetPrim()->GetPath(). More... | |
USD_API const UsdPrimDefinition * | GetSchemaClassPrimDefinition () const |
Static Public Member Functions | |
static USDSHADE_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
static USDSHADE_API UsdShadeNodeDefAPI | Get (const UsdStagePtr &stage, const SdfPath &path) |
static USDSHADE_API bool | CanApply (const UsdPrim &prim, std::string *whyNot=nullptr) |
static USDSHADE_API UsdShadeNodeDefAPI | Apply (const UsdPrim &prim) |
Static Public Member Functions inherited from UsdAPISchemaBase | |
static USD_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
Static Public Member Functions inherited from UsdSchemaBase | |
static const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
Static Public Attributes | |
static const UsdSchemaKind | schemaKind = UsdSchemaKind::SingleApplyAPI |
Static Public Attributes inherited from UsdAPISchemaBase | |
static const UsdSchemaKind | schemaKind = UsdSchemaKind::AbstractBase |
Static Public Attributes inherited from UsdSchemaBase | |
static const UsdSchemaKind | schemaKind = UsdSchemaKind::AbstractBase |
Protected Member Functions | |
USDSHADE_API UsdSchemaKind | _GetSchemaKind () const override |
Protected Member Functions inherited from UsdAPISchemaBase | |
UsdAPISchemaBase (const UsdPrim &prim, const TfToken &instanceName) | |
UsdAPISchemaBase (const UsdSchemaBase &schemaObj, const TfToken &instanceName) | |
const TfToken & | _GetInstanceName () const |
USD_API bool | _IsCompatible () const override |
Protected Member Functions inherited from UsdSchemaBase | |
virtual UsdSchemaKind | _GetSchemaType () const |
const TfType & | _GetType () const |
USD_API UsdAttribute | _CreateAttr (TfToken const &attrName, SdfValueTypeName const &typeName, bool custom, SdfVariability variability, VtValue const &defaultValue, bool writeSparsely) const |
Friends | |
class | UsdSchemaRegistry |
Additional Inherited Members | |
Static Protected Member Functions inherited from UsdAPISchemaBase | |
static USD_API TfTokenVector | _GetMultipleApplyInstanceNames (const UsdPrim &prim, const TfType &schemaType) |
UsdShadeNodeDefAPI is an API schema that provides attributes for a prim to select a corresponding Shader Node Definition ("Sdr Node"), as well as to look up a runtime entry for that shader node in the form of an SdrShaderNode.
UsdShadeNodeDefAPI is intended to be a pre-applied API schema for any prim type that wants to refer to the SdrRegistry for further implementation details about the behavior of that prim. The primary use in UsdShade itself is as UsdShadeShader, which is a basis for material shading networks (UsdShadeMaterial), but this is intended to be used in other domains that also use the Sdr node mechanism.
This schema provides properties that allow a prim to identify an external node definition, either by a direct identifier key into the SdrRegistry (info:id), an asset to be parsed by a suitable NdrParserPlugin (info:sourceAsset), or an inline source code that must also be parsed (info:sourceCode); as well as a selector attribute to determine which specifier is active (info:implementationSource).
For any described attribute Fallback Value or Allowed Values below that are text/tokens, the actual token is published and defined in UsdShadeTokens. So to set an attribute to the value "rightHanded", use UsdShadeTokens->rightHanded as the value.
Definition at line 84 of file nodeDefAPI.h.
Construct a UsdShadeNodeDefAPI on UsdPrim prim
. Equivalent to UsdShadeNodeDefAPI::Get(prim.GetStage(), prim.GetPath()) for a valid prim
, but will not immediately throw an error for an invalid prim
Definition at line 96 of file nodeDefAPI.h.
|
inlineexplicit |
Construct a UsdShadeNodeDefAPI on the prim held by schemaObj
. Should be preferred over UsdShadeNodeDefAPI(schemaObj.GetPrim()), as it preserves SchemaBase state.
Definition at line 104 of file nodeDefAPI.h.
|
virtual |
Destructor.
|
overrideprotectedvirtual |
Returns the kind of schema this class belongs to.
Reimplemented from UsdAPISchemaBase.
|
static |
Applies this single-apply API schema to the given prim
. This information is stored by adding "NodeDefAPI" to the token-valued, listOp metadata apiSchemas on the prim.
|
static |
Returns true if this single-apply API schema can be applied to the given prim
. If this schema can not be a applied to the prim, this returns false and, if provided, populates whyNot
with the reason it can not be applied.
Note that if CanApply returns false, that does not necessarily imply that calling Apply will fail. Callers are expected to call CanApply before calling Apply if they want to ensure that it is valid to apply a schema.
USDSHADE_API UsdAttribute UsdShadeNodeDefAPI::CreateIdAttr | ( | VtValue const & | defaultValue = VtValue() , |
bool | writeSparsely = false |
||
) | const |
See GetIdAttr(), and also Usd_Create_Or_Get_Property for when to use Get vs Create. If specified, author defaultValue
as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely
is true
- the default for writeSparsely
is false
.
USDSHADE_API UsdAttribute UsdShadeNodeDefAPI::CreateImplementationSourceAttr | ( | VtValue const & | defaultValue = VtValue() , |
bool | writeSparsely = false |
||
) | const |
See GetImplementationSourceAttr(), and also Usd_Create_Or_Get_Property for when to use Get vs Create. If specified, author defaultValue
as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely
is true
- the default for writeSparsely
is false
.
|
static |
Return a UsdShadeNodeDefAPI holding the prim adhering to this schema at path
on stage
. If no prim exists at path
on stage
, or if the prim at that path does not adhere to this schema, return an invalid schema object. This is shorthand for the following:
USDSHADE_API UsdAttribute UsdShadeNodeDefAPI::GetIdAttr | ( | ) | const |
The id is an identifier for the type or purpose of the shader. E.g.: Texture or FractalFloat. The use of this id will depend on the render context: some will turn it into an actual shader path, some will use it to generate shader source code dynamically.
Declaration | uniform token info:id |
C++ Type | TfToken |
Usd Type | SdfValueTypeNames->Token |
Variability | SdfVariabilityUniform |
USDSHADE_API TfToken UsdShadeNodeDefAPI::GetImplementationSource | ( | ) | const |
Reads the value of info:implementationSource attribute and returns a token identifying the attribute that must be consulted to identify the shader's source program.
This returns
This issues a warning and returns id if the info:implementationSource attribute has an invalid value.
{sourceType} above is a place holder for a token that identifies the type of shader source or its implementation. For example: osl, glslfx, riCpp etc. This allows a shader to specify different sourceAsset (or sourceCode) values for different sourceTypes. The sourceType tokens usually correspond to the sourceType value of the NdrParserPlugin that's used to parse the shader source (NdrParserPlugin::SourceType).
When sourceType is empty, the corresponding sourceAsset or sourceCode is considered to be "universal" (or fallback), which is represented by the empty-valued token UsdShadeTokens->universalSourceType. When the sourceAsset (or sourceCode) corresponding to a specific, requested sourceType is unavailable, the universal sourceAsset (or sourceCode) is returned by GetSourceAsset (and GetSourceCode} API, if present.
USDSHADE_API UsdAttribute UsdShadeNodeDefAPI::GetImplementationSourceAttr | ( | ) | const |
Specifies the attribute that should be consulted to get the shader's implementation or its source code.
Declaration | uniform token info:implementationSource = "id" |
C++ Type | TfToken |
Usd Type | SdfValueTypeNames->Token |
Variability | SdfVariabilityUniform |
Allowed Values | id, sourceAsset, sourceCode |
|
static |
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes. Does not include attributes that may be authored by custom/extended methods of the schemas involved.
USDSHADE_API bool UsdShadeNodeDefAPI::GetShaderId | ( | TfToken * | id | ) | const |
Fetches the shader's ID value from the info:id attribute, if the shader's info:implementationSource is id.
Returns true if the shader's implementation source is id and the value was fetched properly into id
. Returns false otherwise.
USDSHADE_API SdrShaderNodeConstPtr UsdShadeNodeDefAPI::GetShaderNodeForSourceType | ( | const TfToken & | sourceType | ) | const |
This method attempts to ensure that there is a ShaderNode in the shader registry (i.e. SdrRegistry) representing this shader for the given sourceType
. It may return a null pointer if none could be found or created.
USDSHADE_API bool UsdShadeNodeDefAPI::GetSourceAsset | ( | SdfAssetPath * | sourceAsset, |
const TfToken & | sourceType = UsdShadeTokens->universalSourceType |
||
) | const |
Fetches the shader's source asset value for the specified sourceType
value from the info:sourceType:sourceAsset attribute, if the shader's info:implementationSource is sourceAsset.
If the sourceAsset attribute corresponding to the requested sourceType isn't present on the shader, then the universal fallback sourceAsset attribute, i.e. info:sourceAsset is consulted, if present, to get the source asset path.
Returns true if the shader's implementation source is sourceAsset and the source asset path value was fetched successfully into sourceAsset
. Returns false otherwise.
USDSHADE_API bool UsdShadeNodeDefAPI::GetSourceAssetSubIdentifier | ( | TfToken * | subIdentifier, |
const TfToken & | sourceType = UsdShadeTokens->universalSourceType |
||
) | const |
Fetches the shader's sub-identifier for the source asset with the specified sourceType
value from the info:sourceType: sourceAsset:subIdentifier attribute, if the shader's info: implementationSource is sourceAsset.
If the subIdentifier attribute corresponding to the requested sourceType isn't present on the shader, then the universal fallback sub-identifier attribute, i.e. info:sourceAsset: subIdentifier is consulted, if present, to get the sub-identifier name.
Returns true if the shader's implementation source is sourceAsset and the sub-identifier for the given source type was fetched successfully into subIdentifier
. Returns false otherwise.
USDSHADE_API bool UsdShadeNodeDefAPI::GetSourceCode | ( | std::string * | sourceCode, |
const TfToken & | sourceType = UsdShadeTokens->universalSourceType |
||
) | const |
Fetches the shader's source code for the specified sourceType
value by reading the info:sourceType:sourceCode attribute, if the shader's info:implementationSource is sourceCode.
If the sourceCode attribute corresponding to the requested sourceType isn't present on the shader, then the universal or fallback sourceCode attribute (i.e. info:sourceCode) is consulted, if present, to get the source code.
Returns true if the shader's implementation source is sourceCode and the source code string was fetched successfully into sourceCode
. Returns false otherwise.
USDSHADE_API bool UsdShadeNodeDefAPI::SetShaderId | ( | const TfToken & | id | ) | const |
Sets the shader's ID value. This also sets the info:implementationSource attribute on the shader to UsdShadeTokens->id, if the existing value is different.
USDSHADE_API bool UsdShadeNodeDefAPI::SetSourceAsset | ( | const SdfAssetPath & | sourceAsset, |
const TfToken & | sourceType = UsdShadeTokens->universalSourceType |
||
) | const |
Sets the shader's source-asset path value to sourceAsset
for the given source type, sourceType
.
This also sets the info:implementationSource attribute on the shader to UsdShadeTokens->sourceAsset.
USDSHADE_API bool UsdShadeNodeDefAPI::SetSourceAssetSubIdentifier | ( | const TfToken & | subIdentifier, |
const TfToken & | sourceType = UsdShadeTokens->universalSourceType |
||
) | const |
Set a sub-identifier to be used with a source asset of the given source type. This sets the info:sourceType:sourceAsset:subIdentifier .
This also sets the info:implementationSource attribute on the shader to UsdShadeTokens->sourceAsset
USDSHADE_API bool UsdShadeNodeDefAPI::SetSourceCode | ( | const std::string & | sourceCode, |
const TfToken & | sourceType = UsdShadeTokens->universalSourceType |
||
) | const |
Sets the shader's source-code value to sourceCode
for the given source type, sourceType
.
This also sets the info:implementationSource attribute on the shader to UsdShadeTokens->sourceCode.
|
friend |
Definition at line 182 of file nodeDefAPI.h.
|
static |
Compile time constant representing what kind of schema this class is.
Definition at line 90 of file nodeDefAPI.h.