HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsdShadeOutput Class Reference

#include <output.h>

Public Member Functions

 UsdShadeOutput ()
 
TfToken const & GetFullName () const
 
USDSHADE_API TfToken GetBaseName () const
 
UsdPrim GetPrim () const
 Get the prim that the output belongs to. More...
 
USDSHADE_API SdfValueTypeName GetTypeName () const
 
USDSHADE_API bool Set (const VtValue &value, UsdTimeCode time=UsdTimeCode::Default()) const
 
template<typename T >
bool Set (const T &value, UsdTimeCode time=UsdTimeCode::Default()) const
 
 operator bool () const
 
Configuring the Output's Type
USDSHADE_API bool SetRenderType (TfToken const &renderType) const
 
USDSHADE_API TfToken GetRenderType () const
 
USDSHADE_API bool HasRenderType () const
 
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
 
USDSHADE_API std::string GetSdrMetadataByKey (const TfToken &key) const
 
USDSHADE_API void SetSdrMetadata (const NdrTokenMap &sdrMetadata) const
 
USDSHADE_API void SetSdrMetadataByKey (const TfToken &key, const std::string &value) const
 
USDSHADE_API bool HasSdrMetadata () const
 
USDSHADE_API bool HasSdrMetadataByKey (const TfToken &key) const
 
USDSHADE_API void ClearSdrMetadata () const
 
USDSHADE_API void ClearSdrMetadataByKey (const TfToken &key) const
 
Connected Value API
USDSHADE_API
UsdShadeAttributeVector 
GetValueProducingAttributes (bool shaderOutputsOnly=false) const
 Find what is connected to this Output recursively. More...
 

Friends

class UsdShadeConnectableAPI
 
bool operator== (const UsdShadeOutput &lhs, const UsdShadeOutput &rhs)
 
bool operator!= (const UsdShadeOutput &lhs, const UsdShadeOutput &rhs)
 

UsdAttribute API

USDSHADE_API UsdShadeOutput (const UsdAttribute &attr)
 
const UsdAttributeGetAttr () const
 Explicit UsdAttribute extractor. More...
 
 operator UsdAttribute () const
 
bool IsDefined () const
 
static USDSHADE_API bool IsOutput (const UsdAttribute &attr)
 

Connections API

using ConnectionModification = UsdShadeConnectionModification
 
using SourceInfoVector = TfSmallVector< UsdShadeConnectionSourceInfo, 1 >
 
USDSHADE_API bool CanConnect (const UsdAttribute &source) const
 
USDSHADE_API bool CanConnect (const UsdShadeInput &sourceInput) const
 
USDSHADE_API bool CanConnect (const UsdShadeOutput &sourceOutput) const
 
USDSHADE_API bool ConnectToSource (UsdShadeConnectionSourceInfo const &source, ConnectionModification const mod=ConnectionModification::Replace) const
 
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
 
USDSHADE_API bool ConnectToSource (UsdShadeInput const &sourceInput) const
 
USDSHADE_API bool ConnectToSource (UsdShadeOutput const &sourceOutput) const
 
USDSHADE_API bool SetConnectedSources (std::vector< UsdShadeConnectionSourceInfo > const &sourceInfos) const
 
USDSHADE_API SourceInfoVector GetConnectedSources (SdfPathVector *invalidSourcePaths=nullptr) const
 
USDSHADE_API bool GetConnectedSource (UsdShadeConnectableAPI *source, TfToken *sourceName, UsdShadeAttributeType *sourceType) const
 
USDSHADE_API bool GetRawConnectedSourcePaths (SdfPathVector *sourcePaths) const
 
USDSHADE_API bool HasConnectedSource () const
 
USDSHADE_API bool IsSourceConnectionFromBaseMaterial () const
 
USDSHADE_API bool DisconnectSource (UsdAttribute const &sourceAttr=UsdAttribute()) const
 
USDSHADE_API bool ClearSources () const
 
USDSHADE_API bool ClearSource () const
 

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 47 of file output.h.

Member Typedef Documentation

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

Definition at line 252 of file output.h.

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

Definition at line 321 of file output.h.

Constructor & Destructor Documentation

UsdShadeOutput::UsdShadeOutput ( )
inline

Default constructor returns an invalid Output. Exists for container classes

Definition at line 52 of file output.h.

USDSHADE_API UsdShadeOutput::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

USDSHADE_API bool UsdShadeOutput::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
USDSHADE_API bool UsdShadeOutput::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 UsdShadeOutput::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 void UsdShadeOutput::ClearSdrMetadata ( ) const

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

USDSHADE_API void UsdShadeOutput::ClearSdrMetadataByKey ( const TfToken key) const

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

USDSHADE_API bool UsdShadeOutput::ClearSource ( ) const
USDSHADE_API bool UsdShadeOutput::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
USDSHADE_API bool UsdShadeOutput::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
USDSHADE_API bool UsdShadeOutput::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.

USDSHADE_API bool UsdShadeOutput::ConnectToSource ( SdfPath const &  sourcePath) const

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

See Also
UsdShadeConnectableAPI::ConnectToSource
USDSHADE_API bool UsdShadeOutput::ConnectToSource ( UsdShadeInput const &  sourceInput) const

Connects this Output to the given input, sourceInput.

See Also
UsdShadeConnectableAPI::ConnectToSource
USDSHADE_API bool UsdShadeOutput::ConnectToSource ( UsdShadeOutput const &  sourceOutput) const

Connects this Output to the given output, sourceOutput.

See Also
UsdShadeConnectableAPI::ConnectToSource
USDSHADE_API bool UsdShadeOutput::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
const UsdAttribute& UsdShadeOutput::GetAttr ( ) const
inline

Explicit UsdAttribute extractor.

Definition at line 213 of file output.h.

USDSHADE_API TfToken UsdShadeOutput::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.

USDSHADE_API bool UsdShadeOutput::GetConnectedSource ( UsdShadeConnectableAPI source,
TfToken sourceName,
UsdShadeAttributeType sourceType 
) const
Deprecated:
Please use GetConnectedSources instead
USDSHADE_API SourceInfoVector UsdShadeOutput::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
TfToken const& UsdShadeOutput::GetFullName ( ) const
inline

Get the name of the attribute associated with the output.

Definition at line 59 of file output.h.

UsdPrim UsdShadeOutput::GetPrim ( ) const
inline

Get the prim that the output belongs to.

Definition at line 72 of file output.h.

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

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

See Also
SetRenderType()
USDSHADE_API NdrTokenMap UsdShadeOutput::GetSdrMetadata ( ) const

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

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

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

USDSHADE_API SdfValueTypeName UsdShadeOutput::GetTypeName ( ) const

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

USDSHADE_API UsdShadeAttributeVector UsdShadeOutput::GetValueProducingAttributes ( bool  shaderOutputsOnly = false) const

Find what is connected to this Output recursively.

See Also
UsdShadeUtils::GetValueProducingAttributes
USDSHADE_API bool UsdShadeOutput::HasConnectedSource ( ) const

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

See Also
UsdShadeConnectableAPI::HasConnectedSource
USDSHADE_API bool UsdShadeOutput::HasRenderType ( ) const

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

See Also
SetRenderType()
USDSHADE_API bool UsdShadeOutput::HasSdrMetadata ( ) const

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

USDSHADE_API bool UsdShadeOutput::HasSdrMetadataByKey ( const TfToken key) const

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

bool UsdShadeOutput::IsDefined ( ) const
inline

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

Definition at line 223 of file output.h.

static USDSHADE_API bool UsdShadeOutput::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.

USDSHADE_API bool UsdShadeOutput::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
UsdShadeOutput::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 416 of file output.h.

UsdShadeOutput::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 218 of file output.h.

USDSHADE_API bool UsdShadeOutput::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.

template<typename T >
bool UsdShadeOutput::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 96 of file output.h.

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

Connects this Output to the given sources, sourceInfos

See Also
UsdShadeConnectableAPI::SetConnectedSources
USDSHADE_API bool UsdShadeOutput::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
USDSHADE_API void UsdShadeOutput::SetSdrMetadata ( const NdrTokenMap sdrMetadata) const

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

USDSHADE_API void UsdShadeOutput::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

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 428 of file output.h.

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 422 of file output.h.

Definition at line 433 of file output.h.


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