Loading...
Searching...
No Matches
UsdShadeInput Class Reference

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 UsdAttributeGetAttr () 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.
 

Detailed Description

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

Definition at line 48 of file input.h.

Member Typedef Documentation

◆ ConnectionModification

using ConnectionModification = UsdShadeConnectionModification

Definition at line 308 of file input.h.

◆ SourceInfoVector

Definition at line 376 of file input.h.

Constructor & Destructor Documentation

◆ UsdShadeInput() [1/2]

UsdShadeInput ( )
inline

Default constructor returns an invalid Input.

Exists for the sake of container classes

Definition at line 53 of file input.h.

◆ UsdShadeInput() [2/2]

USDSHADE_API UsdShadeInput ( const UsdAttribute attr)
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).

Member Function Documentation

◆ CanConnect() [1/3]

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.

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.

◆ ClearConnectability()

USDSHADE_API bool ClearConnectability ( ) const

Clears any authored connectability on the Input.

◆ ClearSdrMetadata()

USDSHADE_API void ClearSdrMetadata ( ) const

Clears any "sdrMetadata" value authored on the Input 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 Input 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 Input 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 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.

Returns
true if a connection was created successfully. false if this input 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 Input to the given input, sourceInput.

See also
UsdShadeConnectableAPI::ConnectToSource

◆ ConnectToSource() [5/5]

USDSHADE_API bool ConnectToSource ( UsdShadeOutput const &  sourceOutput) const

Connects this Input to the given output, sourceOutput.

See also
UsdShadeConnectableAPI::ConnectToSource

◆ DisconnectSource()

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.

See also
UsdShadeConnectableAPI::DisconnectSource

◆ Get() [1/2]

bool Get ( T *  value,
UsdTimeCode  time = UsdTimeCode::Default() 
) const
inline

Convenience wrapper for the templated UsdAttribute::Get().

Definition at line 85 of file input.h.

◆ Get() [2/2]

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

Convenience wrapper for VtValue version of UsdAttribute::Get().

◆ GetAttr()

const UsdAttribute & GetAttr ( ) const
inline

Explicit UsdAttribute extractor.

Definition at line 229 of file input.h.

◆ GetBaseName()

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.

◆ GetConnectability()

USDSHADE_API TfToken GetConnectability ( ) const

Returns the connectability of the Input.

See also
SetConnectability()

◆ GetConnectedSource()

USDSHADE_API bool GetConnectedSource ( UsdShadeConnectableAPI source,
TfToken sourceName,
UsdShadeAttributeType *  sourceType 
) const

◆ GetConnectedSources()

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.

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

◆ GetDisplayGroup()

USDSHADE_API std::string GetDisplayGroup ( ) const

Get the displayGroup metadata for this Input, i.e.

hint for the location and nesting of the attribute.

See also
UsdProperty::GetDisplayGroup(), UsdProperty::GetNestedDisplayGroup()

◆ GetDocumentation()

USDSHADE_API std::string GetDocumentation ( ) const

Get documentation string for this Input.

See also
UsdObject::GetDocumentation()

◆ GetFullName()

TfToken const & GetFullName ( ) const
inline

Get the name of the attribute associated with the Input.

Definition at line 60 of file input.h.

◆ GetPrim()

UsdPrim GetPrim ( ) const
inline

Get the prim that the input belongs to.

Definition at line 79 of file input.h.

◆ GetRawConnectedSourcePaths()

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

◆ GetRenderType()

USDSHADE_API TfToken GetRenderType ( ) const

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

See also
SetRenderType()

◆ GetSdrMetadata()

USDSHADE_API NdrTokenMap GetSdrMetadata ( ) const

Returns this Input'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 Input.

◆ GetValueProducingAttribute()

USDSHADE_API UsdAttribute GetValueProducingAttribute ( UsdShadeAttributeType *  attrType) const
Deprecated:
in favor of calling GetValueProducingAttributes

◆ GetValueProducingAttributes()

USDSHADE_API UsdShadeAttributeVector GetValueProducingAttributes ( bool  shaderOutputsOnly = false) const

Find what is connected to this Input recursively.

See also
UsdShadeUtils::GetValueProducingAttributes

◆ HasConnectedSource()

USDSHADE_API bool HasConnectedSource ( ) const

Returns true if and only if this Input 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 Input.

See also
SetRenderType()

◆ HasSdrMetadata()

USDSHADE_API bool HasSdrMetadata ( ) const

Returns true if the Input 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 input.

Definition at line 238 of file input.h.

◆ IsInput()

static USDSHADE_API bool IsInput ( const UsdAttribute attr)
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.

◆ IsInterfaceInputName()

static USDSHADE_API bool IsInterfaceInputName ( const std::string &  name)
static

Test if this name has a namespace that indicates it could be an input.

◆ IsSourceConnectionFromBaseMaterial()

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.

See also
UsdShadeConnectableAPI::IsSourceConnectionFromBaseMaterial

◆ operator bool()

operator bool ( ) const
inlineexplicit

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

Definition at line 272 of file input.h.

◆ operator const UsdAttribute &()

operator const UsdAttribute & ( ) const
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.

Definition at line 234 of file input.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 a value of the Input at time.

Definition at line 103 of file input.h.

◆ Set() [2/2]

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

Set a value for the Input at time.

◆ SetConnectability()

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.

  • full implies that the Input can be connected to any other Input or Output.
  • interfaceOnly implies that the Input can only be connected to a NodeGraph Input (which represents an interface override, not a render-time dataflow connection), or another Input whose connectability is also "interfaceOnly".

The default connectability of an input is UsdShadeTokens->full.

See also
SetConnectability()

◆ SetConnectedSources()

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

Connects this Input to the given sources, sourceInfos.

See also
UsdShadeConnectableAPI::SetConnectedSources

◆ SetDisplayGroup()

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 ":".

See also
UsdProperty::SetDisplayGroup(), UsdProperty::SetNestedDisplayGroup()
SdrShaderProperty::GetPage()

◆ SetDocumentation()

USDSHADE_API bool SetDocumentation ( const std::string &  docs) const

Set documentation string for this Input.

See also
UsdObject::SetDocumentation()

◆ SetRenderType()

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.

Returns
true on success.

◆ SetSdrMetadata()

USDSHADE_API void SetSdrMetadata ( const NdrTokenMap &  sdrMetadata) const

Authors the given sdrMetadata value on this Input 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 Input's "sdrMetadata" dictionary at the current EditTarget.

Friends And Related Function Documentation

◆ operator!=

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

Inequality comparison.

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

Definition at line 284 of file input.h.

◆ operator==

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

Equality comparison.

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

Definition at line 278 of file input.h.

◆ UsdShadeConnectableAPI

friend class UsdShadeConnectableAPI
friend

Definition at line 517 of file input.h.


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