|
This class encapsulates a shader or node-graph input, which is a connectable attribute representing a typed value. More...
#include <input.h>
Classes | |
struct | Hash |
Hash functor. More... | |
Public Member Functions | |
UsdShadeInput () | |
Default constructor returns an invalid Input. | |
TfToken const & | GetFullName () const |
Get the name of the attribute associated with the Input. | |
USDSHADE_API TfToken | GetBaseName () const |
Returns the name of the input. | |
USDSHADE_API SdfValueTypeName | GetTypeName () const |
Get the "scene description" value type name of the attribute associated with the Input. | |
UsdPrim | GetPrim () const |
Get the prim that the input belongs to. | |
template<typename T > | |
bool | Get (T *value, UsdTimeCode time=UsdTimeCode::Default()) const |
Convenience wrapper for the templated UsdAttribute::Get(). | |
USDSHADE_API bool | Get (VtValue *value, UsdTimeCode time=UsdTimeCode::Default()) const |
Convenience wrapper for VtValue version of UsdAttribute::Get(). | |
USDSHADE_API bool | Set (const VtValue &value, UsdTimeCode time=UsdTimeCode::Default()) const |
Set a value for the Input at time . | |
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 a value of the Input at time . | |
operator bool () const | |
Return true if this Input is valid for querying and authoring values and metadata, which is identically equivalent to IsDefined(). | |
Configuring the Input's Type | |
USDSHADE_API bool | SetRenderType (TfToken const &renderType) const |
Specify an alternative, renderer-specific type to use when emitting/translating this Input, rather than translating based on its GetTypeName() | |
USDSHADE_API TfToken | GetRenderType () const |
Return this Input'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 Input. | |
API to author and query an Input's sdrMetadata | |
This section provides API for authoring and querying shader registry metadata on an Input. When the owning shader prim is providing a shader definition, the authored "sdrMetadata" dictionary value provides metadata needed to populate the Input 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 Input'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 Input 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 Input's "sdrMetadata" dictionary at the current EditTarget. | |
USDSHADE_API bool | HasSdrMetadata () const |
Returns true if the Input 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 Input 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. | |
Connectability API | |
USDSHADE_API bool | SetConnectability (const TfToken &connectability) const |
Set the connectability of the Input. | |
USDSHADE_API TfToken | GetConnectability () const |
Returns the connectability of the Input. | |
USDSHADE_API bool | ClearConnectability () const |
Clears any authored connectability on the Input. | |
Connected Value API | |
USDSHADE_API UsdShadeAttributeVector | GetValueProducingAttributes (bool shaderOutputsOnly=false) const |
Find what is connected to this Input recursively. | |
USDSHADE_API UsdAttribute | GetValueProducingAttribute (UsdShadeAttributeType *attrType) const |
Friends | |
class | UsdShadeConnectableAPI |
bool | operator== (const UsdShadeInput &lhs, const UsdShadeInput &rhs) |
Equality comparison. | |
bool | operator!= (const UsdShadeInput &lhs, const UsdShadeInput &rhs) |
Inequality comparison. | |
Connections API | |
using | ConnectionModification = UsdShadeConnectionModification |
using | SourceInfoVector = TfSmallVector< UsdShadeConnectionSourceInfo, 1 > |
USDSHADE_API bool | CanConnect (const UsdAttribute &source) const |
Determines whether this Input 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 Input. | |
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 Input to the source at the given path. | |
USDSHADE_API bool | ConnectToSource (UsdShadeInput const &sourceInput) const |
Connects this Input to the given input, sourceInput . | |
USDSHADE_API bool | ConnectToSource (UsdShadeOutput const &sourceOutput) const |
Connects this Input to the given output, sourceOutput . | |
USDSHADE_API bool | SetConnectedSources (std::vector< UsdShadeConnectionSourceInfo > const &sourceInfos) const |
Connects this Input to the given sources, sourceInfos . | |
USDSHADE_API SourceInfoVector | GetConnectedSources (SdfPathVector *invalidSourcePaths=nullptr) const |
Finds the valid sources of connections for the Input. | |
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 Input is currently connected to a valid (defined) source. | |
USDSHADE_API bool | IsSourceConnectionFromBaseMaterial () const |
Returns true if the connection to this Input'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 Input. | |
USDSHADE_API bool | ClearSources () const |
Clears sources for this Input in the current UsdEditTarget. | |
USDSHADE_API bool | ClearSource () const |
UsdAttribute API | |
USDSHADE_API | UsdShadeInput (const UsdAttribute &attr) |
Speculative constructor that will produce a valid UsdShadeInput when attr already represents a shade Input, and produces an invalid UsdShadeInput otherwise (i.e. | |
const UsdAttribute & | GetAttr () const |
Explicit UsdAttribute extractor. | |
operator const UsdAttribute & () const | |
Allow UsdShadeInput to auto-convert to UsdAttribute, so you can pass a UsdShadeInput 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 input. | |
USDSHADE_API bool | SetDocumentation (const std::string &docs) const |
Set documentation string for this Input. | |
USDSHADE_API std::string | GetDocumentation () const |
Get documentation string for this Input. | |
USDSHADE_API bool | SetDisplayGroup (const std::string &displayGroup) const |
Set the displayGroup metadata for this Input, i.e. | |
USDSHADE_API std::string | GetDisplayGroup () const |
Get the displayGroup metadata for this Input, i.e. | |
static USDSHADE_API bool | IsInput (const UsdAttribute &attr) |
Test whether a given UsdAttribute represents a valid Input, which implies that creating a UsdShadeInput from the attribute will succeed. | |
static USDSHADE_API bool | IsInterfaceInputName (const std::string &name) |
Test if this name has a namespace that indicates it could be an input. | |
This class encapsulates a shader or node-graph input, which is a connectable attribute representing a typed value.
using ConnectionModification = UsdShadeConnectionModification |
|
inline |
|
explicit |
Speculative constructor that will produce a valid UsdShadeInput when attr
already represents a shade Input, and produces an invalid UsdShadeInput otherwise (i.e.
the explicit bool conversion operator will return false).
USDSHADE_API bool CanConnect | ( | const UsdAttribute & | source | ) | const |
Determines whether this Input 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 ClearConnectability | ( | ) | const |
Clears any authored connectability on the Input.
USDSHADE_API void ClearSdrMetadata | ( | ) | const |
Clears any "sdrMetadata" value authored on the Input 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 Input 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 Input 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 Input.
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 this input or source
is invalid.USDSHADE_API bool ConnectToSource | ( | UsdShadeInput const & | sourceInput | ) | const |
Connects this Input to the given input, sourceInput
.
USDSHADE_API bool ConnectToSource | ( | UsdShadeOutput const & | sourceOutput | ) | const |
Connects this Input to the given output, sourceOutput
.
USDSHADE_API bool DisconnectSource | ( | UsdAttribute const & | sourceAttr = UsdAttribute() | ) | const |
Disconnect source for this Input.
If sourceAttr
is valid, only a connection to the specified attribute is disconnected, otherwise all connections are removed.
|
inline |
Convenience wrapper for the templated UsdAttribute::Get().
USDSHADE_API bool Get | ( | VtValue * | value, |
UsdTimeCode | time = UsdTimeCode::Default() |
||
) | const |
Convenience wrapper for VtValue version of UsdAttribute::Get().
|
inline |
Explicit UsdAttribute extractor.
USDSHADE_API TfToken GetBaseName | ( | ) | const |
Returns the name of the input.
We call this the base name since it strips off the "inputs:" namespace prefix from the attribute name, and returns it.
USDSHADE_API TfToken GetConnectability | ( | ) | const |
Returns the connectability of the Input.
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 Input.
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.
USDSHADE_API std::string GetDisplayGroup | ( | ) | const |
Get the displayGroup metadata for this Input, i.e.
hint for the location and nesting of the attribute.
USDSHADE_API std::string GetDocumentation | ( | ) | const |
Get documentation string for this Input.
|
inline |
|
inline |
USDSHADE_API bool GetRawConnectedSourcePaths | ( | SdfPathVector * | sourcePaths | ) | const |
USDSHADE_API TfToken GetRenderType | ( | ) | const |
Return this Input's specialized renderType, or an empty token if none was authored.
USDSHADE_API NdrTokenMap GetSdrMetadata | ( | ) | const |
Returns this Input'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 Input.
USDSHADE_API UsdAttribute GetValueProducingAttribute | ( | UsdShadeAttributeType * | attrType | ) | const |
USDSHADE_API UsdShadeAttributeVector GetValueProducingAttributes | ( | bool | shaderOutputsOnly = false | ) | const |
Find what is connected to this Input recursively.
USDSHADE_API bool HasConnectedSource | ( | ) | const |
Returns true if and only if this Input is currently connected to a valid (defined) source.
USDSHADE_API bool HasRenderType | ( | ) | const |
Return true if a renderType has been specified for this Input.
USDSHADE_API bool HasSdrMetadata | ( | ) | const |
Returns true if the Input 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 input.
|
static |
Test whether a given UsdAttribute represents a valid Input, which implies that creating a UsdShadeInput from the attribute will succeed.
Success implies that attr.IsDefined()
is true.
|
static |
Test if this name has a namespace that indicates it could be an input.
USDSHADE_API bool IsSourceConnectionFromBaseMaterial | ( | ) | const |
Returns true if the connection to this Input'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 Input is valid for querying and authoring values and metadata, which is identically equivalent to IsDefined().
|
inline |
Allow UsdShadeInput to auto-convert to UsdAttribute, so you can pass a UsdShadeInput 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 Input at time
.
USDSHADE_API bool SetConnectability | ( | const TfToken & | connectability | ) | const |
Set the connectability of the Input.
In certain shading data models, there is a need to distinguish which inputs can vary over a surface from those that must be uniform. This is accomplished in UsdShade by limiting the connectability of the input. This is done by setting the "connectability" metadata on the associated attribute.
Connectability of an Input can be set to UsdShadeTokens->full or UsdShadeTokens->interfaceOnly.
The default connectability of an input is UsdShadeTokens->full.
USDSHADE_API bool SetConnectedSources | ( | std::vector< UsdShadeConnectionSourceInfo > const & | sourceInfos | ) | const |
Connects this Input to the given sources, sourceInfos
.
USDSHADE_API bool SetDisplayGroup | ( | const std::string & | displayGroup | ) | const |
Set the displayGroup metadata for this Input, i.e.
hinting for the location and nesting of the attribute.
Note for an input representing a nested SdrShaderProperty, its expected to have the scope delimited by a ":".
USDSHADE_API bool SetDocumentation | ( | const std::string & | docs | ) | const |
Set documentation string for this Input.
USDSHADE_API bool SetRenderType | ( | TfToken const & | renderType | ) | const |
Specify an alternative, renderer-specific type to use when emitting/translating this Input, rather than translating based on its GetTypeName()
For example, we set the renderType to "struct" for Inputs that are of renderman custom struct types.
USDSHADE_API void SetSdrMetadata | ( | const NdrTokenMap & | sdrMetadata | ) | const |
Authors the given sdrMetadata
value on this Input 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 Input's "sdrMetadata" dictionary at the current EditTarget.
|
friend |
Inequality comparison.
Return false if lhs and rhs represent the same UsdShadeInput, true otherwise.
|
friend |
Equality comparison.
Returns true if lhs and rhs represent the same UsdShadeInput, false otherwise.
|
friend |