This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
UsdShadeOutput Class Reference

This class encapsulates a shader or node-graph output, which is a connectable attribute representing a typed, externally computed value. More...

#include <output.h>

Public Member Functions

 UsdShadeOutput ()
 Default constructor returns an invalid Output.
 
TfToken const & GetFullName () const
 Get the name of the attribute associated with the output.
 
USDSHADE_API TfToken GetBaseName () const
 Returns the name of the output.
 
UsdPrim GetPrim () const
 Get the prim that the output belongs to.
 
USDSHADE_API SdfValueTypeName GetTypeName () const
 Get the "scene description" value type name of the attribute associated with the output.
 
USDSHADE_API bool Set (const VtValue &value, UsdTimeCode time=UsdTimeCode::Default()) const
 Set a value for the output.
 
template<typename T >
bool Set (const T &value, UsdTimeCode time=UsdTimeCode::Default()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Set the attribute value of the Output at time.
 
 operator bool () const
 Return true if this Output is valid for querying and authoring values and metadata, which is identically equivalent to IsDefined().
 
Configuring the Output's Type
USDSHADE_API bool SetRenderType (TfToken const &renderType) const
 Specify an alternative, renderer-specific type to use when emitting/translating this output, rather than translating based on its GetTypeName()
 
USDSHADE_API TfToken GetRenderType () const
 Return this output's specialized renderType, or an empty token if none was authored.
 
USDSHADE_API bool HasRenderType () const
 Return true if a renderType has been specified for this output.
 
API to author and query an Output's sdrMetadata

This section provides API for authoring and querying shader registry metadata on an Output.

When the owning shader prim is providing a shader definition, the authored "sdrMetadata" dictionary value provides metadata needed to populate the Output correctly in the shader registry.

We expect the keys in sdrMetadata to correspond to the keys in SdrPropertyMetadata. However, this is not strictly enforced by the API. The only allowed value type in the "sdrMetadata" dictionary is a std::string since it needs to be converted into a NdrTokenMap, which Sdr will parse using the utilities available in SdrMetadataHelpers.

USDSHADE_API NdrTokenMap GetSdrMetadata () const
 Returns this Output's composed "sdrMetadata" dictionary as a NdrTokenMap.
 
USDSHADE_API std::string GetSdrMetadataByKey (const TfToken &key) const
 Returns the value corresponding to key in the composed sdrMetadata dictionary.
 
USDSHADE_API void SetSdrMetadata (const NdrTokenMap &sdrMetadata) const
 Authors the given sdrMetadata value on this Output at the current EditTarget.
 
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 Output's "sdrMetadata" dictionary at the current EditTarget.
 
USDSHADE_API bool HasSdrMetadata () const
 Returns true if the Output has a non-empty composed "sdrMetadata" dictionary value.
 
USDSHADE_API bool HasSdrMetadataByKey (const TfToken &key) const
 Returns true if there is a value corresponding to the given key in the composed "sdrMetadata" dictionary.
 
USDSHADE_API void ClearSdrMetadata () const
 Clears any "sdrMetadata" value authored on the Output in the current EditTarget.
 
USDSHADE_API void ClearSdrMetadataByKey (const TfToken &key) const
 Clears the entry corresponding to the given key in the "sdrMetadata" dictionary authored in the current EditTarget.
 
Connected Value API
USDSHADE_API UsdShadeAttributeVector GetValueProducingAttributes (bool shaderOutputsOnly=false) const
 Find what is connected to this Output recursively.
 

Friends

class UsdShadeConnectableAPI
 
bool operator== (const UsdShadeOutput &lhs, const UsdShadeOutput &rhs)
 Equality comparison.
 
bool operator!= (const UsdShadeOutput &lhs, const UsdShadeOutput &rhs)
 Inequality comparison.
 

Connections API

using ConnectionModification = UsdShadeConnectionModification
 
using SourceInfoVector = TfSmallVector< UsdShadeConnectionSourceInfo, 1 >
 
USDSHADE_API bool CanConnect (const UsdAttribute &source) const
 Determines whether this Output can be connected to the given source attribute, which can be an input or an output.
 
USDSHADE_API bool CanConnect (const UsdShadeInput &sourceInput) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
USDSHADE_API bool CanConnect (const UsdShadeOutput &sourceOutput) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
USDSHADE_API bool ConnectToSource (UsdShadeConnectionSourceInfo const &source, ConnectionModification const mod=ConnectionModification::Replace) const
 Authors a connection for this Output.
 
USDSHADE_API bool ConnectToSource (UsdShadeConnectableAPI const &source, TfToken const &sourceName, UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output, SdfValueTypeName typeName=SdfValueTypeName()) const
 
USDSHADE_API bool ConnectToSource (SdfPath const &sourcePath) const
 Authors a connection for this Output to the source at the given path.
 
USDSHADE_API bool ConnectToSource (UsdShadeInput const &sourceInput) const
 Connects this Output to the given input, sourceInput.
 
USDSHADE_API bool ConnectToSource (UsdShadeOutput const &sourceOutput) const
 Connects this Output to the given output, sourceOutput.
 
USDSHADE_API bool SetConnectedSources (std::vector< UsdShadeConnectionSourceInfo > const &sourceInfos) const
 Connects this Output to the given sources, sourceInfos.
 
USDSHADE_API SourceInfoVector GetConnectedSources (SdfPathVector *invalidSourcePaths=nullptr) const
 Finds the valid sources of connections for the Output.
 
USDSHADE_API bool GetConnectedSource (UsdShadeConnectableAPI *source, TfToken *sourceName, UsdShadeAttributeType *sourceType) const
 
USDSHADE_API bool GetRawConnectedSourcePaths (SdfPathVector *sourcePaths) const
 
USDSHADE_API bool HasConnectedSource () const
 Returns true if and only if this Output is currently connected to a valid (defined) source.
 
USDSHADE_API bool IsSourceConnectionFromBaseMaterial () const
 Returns true if the connection to this Output's source, as returned by GetConnectedSource(), is authored across a specializes arc, which is used to denote a base material.
 
USDSHADE_API bool DisconnectSource (UsdAttribute const &sourceAttr=UsdAttribute()) const
 Disconnect source for this Output.
 
USDSHADE_API bool ClearSources () const
 Clears sources for this Output in the current UsdEditTarget.
 
USDSHADE_API bool ClearSource () const
 

UsdAttribute API

USDSHADE_API UsdShadeOutput (const UsdAttribute &attr)
 Speculative constructor that will produce a valid UsdShadeOutput when attr already represents a shade Output, and produces an invalid UsdShadeOutput otherwise (i.e.
 
const UsdAttributeGetAttr () const
 Explicit UsdAttribute extractor.
 
 operator UsdAttribute () const
 Allow UsdShadeOutput to auto-convert to UsdAttribute, so you can pass a UsdShadeOutput to any function that accepts a UsdAttribute or const-ref thereto.
 
bool IsDefined () const
 Return true if the wrapped UsdAttribute is defined, and in addition the attribute is identified as an output.
 
static USDSHADE_API bool IsOutput (const UsdAttribute &attr)
 Test whether a given UsdAttribute represents a valid Output, which implies that creating a UsdShadeOutput from the attribute will succeed.
 

Detailed Description

This class encapsulates a shader or node-graph output, which is a connectable attribute representing a typed, externally computed value.

Definition at line 30 of file output.h.

Member Typedef Documentation

◆ ConnectionModification

using ConnectionModification = UsdShadeConnectionModification

Definition at line 235 of file output.h.

◆ SourceInfoVector

Definition at line 304 of file output.h.

Constructor & Destructor Documentation

◆ UsdShadeOutput() [1/2]

UsdShadeOutput ( )
inline

Default constructor returns an invalid Output.

Exists for container classes

Definition at line 35 of file output.h.

◆ UsdShadeOutput() [2/2]

USDSHADE_API UsdShadeOutput ( const UsdAttribute attr)
explicit

Speculative constructor that will produce a valid UsdShadeOutput when attr already represents a shade Output, and produces an invalid UsdShadeOutput otherwise (i.e.

the explicit bool conversion operator will return false).

Member Function Documentation

◆ CanConnect() [1/3]

USDSHADE_API bool CanConnect ( const UsdAttribute source) const

Determines whether this Output can be connected to the given source attribute, which can be an input or an output.

An output is considered to be connectable only if it belongs to a node-graph. Shader outputs are not connectable.

See also
UsdShadeConnectableAPI::CanConnect

◆ CanConnect() [2/3]

USDSHADE_API bool CanConnect ( const UsdShadeInput sourceInput) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ CanConnect() [3/3]

USDSHADE_API bool CanConnect ( const UsdShadeOutput sourceOutput) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ClearSdrMetadata()

USDSHADE_API void ClearSdrMetadata ( ) const

Clears any "sdrMetadata" value authored on the Output in the current EditTarget.

◆ ClearSdrMetadataByKey()

USDSHADE_API void ClearSdrMetadataByKey ( const TfToken key) const

Clears the entry corresponding to the given key in the "sdrMetadata" dictionary authored in the current EditTarget.

◆ ClearSource()

USDSHADE_API bool ClearSource ( ) const

◆ ClearSources()

USDSHADE_API bool ClearSources ( ) const

Clears sources for this Output in the current UsdEditTarget.

Most of the time, what you probably want is DisconnectSource() rather than this function.

See also
UsdShadeConnectableAPI::ClearSources

◆ ConnectToSource() [1/5]

USDSHADE_API bool ConnectToSource ( SdfPath const &  sourcePath) const

Authors a connection for this Output to the source at the given path.

See also
UsdShadeConnectableAPI::ConnectToSource

◆ ConnectToSource() [2/5]

USDSHADE_API bool ConnectToSource ( UsdShadeConnectableAPI const &  source,
TfToken const &  sourceName,
UsdShadeAttributeType const  sourceType = UsdShadeAttributeType::Output,
SdfValueTypeName  typeName = SdfValueTypeName() 
) const
Deprecated:
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ConnectToSource() [3/5]

USDSHADE_API bool ConnectToSource ( UsdShadeConnectionSourceInfo const &  source,
ConnectionModification const  mod = ConnectionModification::Replace 
) const

Authors a connection for this Output.

source is a struct that describes the upstream source attribute with all the information necessary to make a connection. See the documentation for UsdShadeConnectionSourceInfo. mod describes the operation that should be applied to the list of connections. By default the new connection will replace any existing connections, but it can add to the list of connections to represent multiple input connections.

Returns
true if a connection was created successfully. false if shadingAttr or source is invalid.
Note
This method does not verify the connectability of the shading attribute to the source. Clients must invoke CanConnect() themselves to ensure compatibility.
The source shading attribute is created if it doesn't exist already.
See also
UsdShadeConnectableAPI::ConnectToSource

◆ ConnectToSource() [4/5]

USDSHADE_API bool ConnectToSource ( UsdShadeInput const &  sourceInput) const

Connects this Output to the given input, sourceInput.

See also
UsdShadeConnectableAPI::ConnectToSource

◆ ConnectToSource() [5/5]

USDSHADE_API bool ConnectToSource ( UsdShadeOutput const &  sourceOutput) const

Connects this Output to the given output, sourceOutput.

See also
UsdShadeConnectableAPI::ConnectToSource

◆ DisconnectSource()

USDSHADE_API bool DisconnectSource ( UsdAttribute const &  sourceAttr = UsdAttribute()) const

Disconnect source for this Output.

If sourceAttr is valid, only a connection to the specified attribute is disconnected, otherwise all connections are removed.

See also
UsdShadeConnectableAPI::DisconnectSource

◆ GetAttr()

const UsdAttribute & GetAttr ( ) const
inline

Explicit UsdAttribute extractor.

Definition at line 196 of file output.h.

◆ GetBaseName()

USDSHADE_API TfToken GetBaseName ( ) const

Returns the name of the output.

We call this the base name since it strips off the "outputs:" namespace prefix from the attribute name, and returns it.

◆ GetConnectedSource()

USDSHADE_API bool GetConnectedSource ( UsdShadeConnectableAPI source,
TfToken sourceName,
UsdShadeAttributeType *  sourceType 
) const
Deprecated:
Please use GetConnectedSources instead

◆ GetConnectedSources()

USDSHADE_API SourceInfoVector GetConnectedSources ( SdfPathVector *  invalidSourcePaths = nullptr) const

Finds the valid sources of connections for the Output.

invalidSourcePaths is an optional output parameter to collect the invalid source paths that have not been reported in the returned vector.

Returns a vector of UsdShadeConnectionSourceInfo structs with information about each upsteam attribute. If the vector is empty, there have been no valid connections.

Note
A valid connection requires the existence of the source attribute and also requires that the source prim is UsdShadeConnectableAPI compatible.
The python wrapping returns a tuple with the valid connections first, followed by the invalid source paths.
See also
UsdShadeConnectableAPI::GetConnectedSources

◆ GetFullName()

TfToken const & GetFullName ( ) const
inline

Get the name of the attribute associated with the output.

Definition at line 42 of file output.h.

◆ GetPrim()

UsdPrim GetPrim ( ) const
inline

Get the prim that the output belongs to.

Definition at line 55 of file output.h.

◆ GetRawConnectedSourcePaths()

USDSHADE_API bool GetRawConnectedSourcePaths ( SdfPathVector *  sourcePaths) const
Deprecated:
Returns the "raw" (authored) connected source paths for this Output.
See also
UsdShadeConnectableAPI::GetRawConnectedSourcePaths

◆ GetRenderType()

USDSHADE_API TfToken GetRenderType ( ) const

Return this output's specialized renderType, or an empty token if none was authored.

See also
SetRenderType()

◆ GetSdrMetadata()

USDSHADE_API NdrTokenMap GetSdrMetadata ( ) const

Returns this Output's composed "sdrMetadata" dictionary as a NdrTokenMap.

◆ GetSdrMetadataByKey()

USDSHADE_API std::string GetSdrMetadataByKey ( const TfToken key) const

Returns the value corresponding to key in the composed sdrMetadata dictionary.

◆ GetTypeName()

USDSHADE_API SdfValueTypeName GetTypeName ( ) const

Get the "scene description" value type name of the attribute associated with the output.

◆ GetValueProducingAttributes()

USDSHADE_API UsdShadeAttributeVector GetValueProducingAttributes ( bool  shaderOutputsOnly = false) const

Find what is connected to this Output recursively.

See also
UsdShadeUtils::GetValueProducingAttributes

◆ HasConnectedSource()

USDSHADE_API bool HasConnectedSource ( ) const

Returns true if and only if this Output is currently connected to a valid (defined) source.

See also
UsdShadeConnectableAPI::HasConnectedSource

◆ HasRenderType()

USDSHADE_API bool HasRenderType ( ) const

Return true if a renderType has been specified for this output.

See also
SetRenderType()

◆ HasSdrMetadata()

USDSHADE_API bool HasSdrMetadata ( ) const

Returns true if the Output has a non-empty composed "sdrMetadata" dictionary value.

◆ HasSdrMetadataByKey()

USDSHADE_API bool HasSdrMetadataByKey ( const TfToken key) const

Returns true if there is a value corresponding to the given key in the composed "sdrMetadata" dictionary.

◆ IsDefined()

bool IsDefined ( ) const
inline

Return true if the wrapped UsdAttribute is defined, and in addition the attribute is identified as an output.

Definition at line 206 of file output.h.

◆ IsOutput()

static USDSHADE_API bool IsOutput ( const UsdAttribute attr)
static

Test whether a given UsdAttribute represents a valid Output, which implies that creating a UsdShadeOutput from the attribute will succeed.

Success implies that attr.IsDefined() is true.

◆ IsSourceConnectionFromBaseMaterial()

USDSHADE_API bool IsSourceConnectionFromBaseMaterial ( ) const

Returns true if the connection to this Output's source, as returned by GetConnectedSource(), is authored across a specializes arc, which is used to denote a base material.

See also
UsdShadeConnectableAPI::IsSourceConnectionFromBaseMaterial

◆ operator bool()

operator bool ( ) const
inlineexplicit

Return true if this Output is valid for querying and authoring values and metadata, which is identically equivalent to IsDefined().

Definition at line 399 of file output.h.

◆ operator UsdAttribute()

operator UsdAttribute ( ) const
inline

Allow UsdShadeOutput to auto-convert to UsdAttribute, so you can pass a UsdShadeOutput to any function that accepts a UsdAttribute or const-ref thereto.

Definition at line 201 of file output.h.

◆ Set() [1/2]

bool Set ( const T &  value,
UsdTimeCode  time = UsdTimeCode::Default() 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Set the attribute value of the Output at time.

Definition at line 79 of file output.h.

◆ Set() [2/2]

USDSHADE_API bool Set ( const VtValue value,
UsdTimeCode  time = UsdTimeCode::Default() 
) const

Set a value for the output.

It's unusual to be setting a value on an output since it represents an externally computed value. The Set API is provided here just for the sake of completeness and uniformity with other property schema.

◆ SetConnectedSources()

USDSHADE_API bool SetConnectedSources ( std::vector< UsdShadeConnectionSourceInfo > const &  sourceInfos) const

Connects this Output to the given sources, sourceInfos.

See also
UsdShadeConnectableAPI::SetConnectedSources

◆ SetRenderType()

USDSHADE_API bool SetRenderType ( TfToken const &  renderType) const

Specify an alternative, renderer-specific type to use when emitting/translating this output, rather than translating based on its GetTypeName()

For example, we set the renderType to "struct" for outputs that are of renderman custom struct types.

Returns
true on success

◆ SetSdrMetadata()

USDSHADE_API void SetSdrMetadata ( const NdrTokenMap &  sdrMetadata) const

Authors the given sdrMetadata value on this Output at the current EditTarget.

◆ SetSdrMetadataByKey()

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 Output's "sdrMetadata" dictionary at the current EditTarget.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const UsdShadeOutput lhs,
const UsdShadeOutput rhs 
)
friend

Inequality comparison.

Return false if lhs and rhs represent the same UsdShadeOutput, true otherwise.

Definition at line 411 of file output.h.

◆ operator==

bool operator== ( const UsdShadeOutput lhs,
const UsdShadeOutput rhs 
)
friend

Equality comparison.

Returns true if lhs and rhs represent the same UsdShadeOutput, false otherwise.

Definition at line 405 of file output.h.

◆ UsdShadeConnectableAPI

friend class UsdShadeConnectableAPI
friend

Definition at line 416 of file output.h.


The documentation for this class was generated from the following file: