usdrt::UsdShadeNodeDefAPI

Defined in usdrt/scenegraph/usd/usdShade/nodeDefAPI.h

Functions

Variables

class UsdShadeNodeDefAPI : public usdrt::UsdAPISchemaBase

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.

Public Functions

inline explicit UsdShadeNodeDefAPI(const UsdPrim &prim = UsdPrim())

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.

inline explicit UsdShadeNodeDefAPI(const UsdSchemaBase &schemaObj)

Construct a UsdShadeNodeDefAPI on the prim held by schemaObj . Should be preferred over UsdShadeNodeDefAPI(schemaObj.GetPrim()), as it preserves SchemaBase state.

inline virtual ~UsdShadeNodeDefAPI()

Destructor.

inline operator bool() const

Boolean operator.

Returns

Return true if the contained prim is has this api schema applied using HasAPI, and false otherwise.

inline UsdAttribute GetImplementationSourceAttr() const

Specifies the attribute that should be consulted to get the shader’s implementation or its source code.

  • If set to “id”, the “info:id” attribute’s value is used to determine the shader source from the shader registry.

  • If set to “sourceAsset”, the resolved value of the “info:sourceAsset” attribute corresponding to the desired implementation (or source-type) is used to locate the shader source. A source asset file may also specify multiple shader definitions, so there is an optional attribute “info:sourceAsset:subIdentifier” whose value should be used to indicate a particular shader definition from a source asset file.

  • If set to “sourceCode”, the value of “info:sourceCode” attribute corresponding to the desired implementation (or source type) is used as the shader source.

Declaration

uniform token info:implementationSource = "id"

C++ Type

TfToken

Usd Type

SdfValueTypeNames->Token

Variability

SdfVariabilityUniform

Allowed Values

id, sourceAsset, sourceCode

inline UsdAttribute CreateImplementationSourceAttr() const

See GetImplementationSourceAttr(), and also Create vs Get Property Methods 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.

inline UsdAttribute 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 target: 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

See also

SetShaderId()

inline UsdAttribute CreateIdAttr() const

See GetIdAttr(), and also Create vs Get Property Methods 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.

UsdPrim GetPrim() const

Return this schema object’s held prim.

SdfPath GetPath() const

Return the SdfPath to this schema object’s held prim.

Public Static Functions

static inline UsdShadeNodeDefAPI Apply(const UsdPrim &prim)

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.

See also

UsdPrim::GetAppliedSchemas()

See also

UsdPrim::HasAPI()

See also

UsdPrim::ApplyAPI()

See also

UsdPrim::RemoveAPI()

Returns

A valid UsdShadeNodeDefAPI object is returned upon success. An invalid (or empty) UsdShadeNodeDefAPI object is returned upon failure. See UsdPrim::ApplyAPI() for conditions resulting in failure.

Public Static Attributes

static const UsdSchemaType schemaType = UsdSchemaType::SingleApplyAPI

Compile time constant representing what kind of schema this class is.

See also

UsdSchemaType

Protected Functions

inline const TfToken &_GetInstanceName() const

Returns the instance name of the API schema object belonging to a multiple-apply API schema.

The returned instance name will be empty for non-applied and single-apply API schemas.