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

This class contains a set of utility functions used when authoring and querying shading networks. More...

Static Public Member Functions

static USDSHADE_API std::string GetPrefixForAttributeType (UsdShadeAttributeType sourceType)
 Returns the namespace prefix of the USD attribute associated with the given shading attribute type. More...
 
static USDSHADE_API std::pair
< TfToken,
UsdShadeAttributeType > 
GetBaseNameAndType (const TfToken &fullName)
 Given the full name of a shading attribute, returns it's base name and shading attribute type. More...
 
static USDSHADE_API
UsdShadeAttributeType 
GetType (const TfToken &fullName)
 Given the full name of a shading attribute, returns its shading attribute type. More...
 
static USDSHADE_API TfToken GetFullName (const TfToken &baseName, const UsdShadeAttributeType type)
 Returns the full shading attribute name given the basename and the shading attribute type. More...
 
static USDSHADE_API
UsdShadeAttributeVector 
GetValueProducingAttributes (UsdShadeInput const &input, bool shaderOutputsOnly=false)
 Find what is connected to an Input or Output recursively. More...
 
static USDSHADE_API
UsdShadeAttributeVector 
GetValueProducingAttributes (UsdShadeOutput const &output, bool shaderOutputsOnly=false)
 

Detailed Description

This class contains a set of utility functions used when authoring and querying shading networks.

Definition at line 48 of file utils.h.

Member Function Documentation

static USDSHADE_API std::pair<TfToken, UsdShadeAttributeType> GetBaseNameAndType ( const TfToken fullName)
static

Given the full name of a shading attribute, returns it's base name and shading attribute type.

static USDSHADE_API TfToken GetFullName ( const TfToken baseName,
const UsdShadeAttributeType  type 
)
static

Returns the full shading attribute name given the basename and the shading attribute type.

baseName is the name of the input or output on the shading node. type is the UsdShadeAttributeType of the shading attribute.

static USDSHADE_API std::string GetPrefixForAttributeType ( UsdShadeAttributeType  sourceType)
static

Returns the namespace prefix of the USD attribute associated with the given shading attribute type.

static USDSHADE_API UsdShadeAttributeType GetType ( const TfToken fullName)
static

Given the full name of a shading attribute, returns its shading attribute type.

static USDSHADE_API UsdShadeAttributeVector GetValueProducingAttributes ( UsdShadeInput const &  input,
bool  shaderOutputsOnly = false 
)
static

Find what is connected to an Input or Output recursively.

GetValueProducingAttributes implements the UsdShade connectivity rules described in Connection Resolution Utilities .

When tracing connections within networks that contain containers like UsdShadeNodeGraph nodes, the actual output(s) or value(s) at the end of an input or output might be multiple connections removed. The methods below resolves this across multiple physical connections.

An UsdShadeInput is getting its value from one of these sources:

  • If the input is not connected the UsdAttribute for this input is returned, but only if it has an authored value. The input attribute itself carries the value for this input.
  • If the input is connected we follow the connection(s) until we reach a valid output of a UsdShadeShader node or if we reach a valid UsdShadeInput attribute of a UsdShadeNodeGraph or UsdShadeMaterial that has an authored value.

An UsdShadeOutput on a container can get its value from the same type of sources as a UsdShadeInput on either a UsdShadeShader or UsdShadeNodeGraph. Outputs on non-containers (UsdShadeShaders) cannot be connected.

This function returns a vector of UsdAttributes. The vector is empty if no valid attribute was found. The type of each attribute can be determined with the UsdShadeUtils::GetType function.

If shaderOutputsOnly is true, it will only report attributes that are outputs of non-containers (UsdShadeShaders). This is a bit faster and what is need when determining the connections for Material terminals.

Note
This will return the last attribute along the connection chain that has an authored value, which might not be the last attribute in the chain itself.
When the network contains multi-connections, this function can return multiple attributes for a single input or output. The list of attributes is build by a depth-first search, following the underlying connection paths in order. The list can contain both UsdShadeOutput and UsdShadeInput attributes. It is up to the caller to decide how to process such a mixture.
static USDSHADE_API UsdShadeAttributeVector GetValueProducingAttributes ( UsdShadeOutput const &  output,
bool  shaderOutputsOnly = false 
)
static

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


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