|
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 UsdAttribute & | GetAttr () 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. | |
This class encapsulates a shader or node-graph output, which is a connectable attribute representing a typed, externally computed value.
using ConnectionModification = UsdShadeConnectionModification |
|
inline |
|
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).
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.
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 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.
USDSHADE_API bool ClearSource | ( | ) | const |
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.
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 | ( | UsdShadeConnectableAPI const & | source, |
TfToken const & | sourceName, | ||
UsdShadeAttributeType const | sourceType = UsdShadeAttributeType::Output , |
||
SdfValueTypeName | typeName = SdfValueTypeName() |
||
) | const |
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.
true
if a connection was created successfully. false
if shadingAttr
or source
is invalid.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 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.
|
inline |
Explicit UsdAttribute extractor.
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.
USDSHADE_API bool GetConnectedSource | ( | UsdShadeConnectableAPI * | source, |
TfToken * | sourceName, | ||
UsdShadeAttributeType * | sourceType | ||
) | const |
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.
|
inline |
|
inline |
USDSHADE_API bool GetRawConnectedSourcePaths | ( | SdfPathVector * | sourcePaths | ) | const |
USDSHADE_API TfToken GetRenderType | ( | ) | const |
Return this output's specialized renderType, or an empty token if none was authored.
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 SdfValueTypeName GetTypeName | ( | ) | const |
Get the "scene description" value type name of the attribute associated with the output.
USDSHADE_API UsdShadeAttributeVector GetValueProducingAttributes | ( | bool | shaderOutputsOnly = false | ) | const |
Find what is connected to this Output recursively.
USDSHADE_API bool HasConnectedSource | ( | ) | const |
Returns true if and only if this Output is currently connected to a valid (defined) source.
USDSHADE_API bool HasRenderType | ( | ) | const |
Return true if a renderType has been specified for this output.
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.
|
inline |
Return true if the wrapped UsdAttribute is defined, and in addition the attribute is identified as an output.
|
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 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.
|
inlineexplicit |
Return true if this Output is valid for querying and authoring values and metadata, which is identically equivalent to IsDefined().
|
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.
|
inline |
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.
USDSHADE_API bool SetConnectedSources | ( | std::vector< UsdShadeConnectionSourceInfo > const & | sourceInfos | ) | const |
Connects this Output to the given sources, sourceInfos
.
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.
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.
|
friend |
Inequality comparison.
Return false if lhs and rhs represent the same UsdShadeOutput, true otherwise.
|
friend |
Equality comparison.
Returns true if lhs and rhs represent the same UsdShadeOutput, false otherwise.
|
friend |