Loading...
Searching...
No Matches
SdrShaderProperty Class Reference

Represents a property (input or output) that is part of a SdrShaderNode instance. More...

#include <shaderProperty.h>

Public Member Functions

SDR_API SdrShaderProperty (const TfToken &name, const TfToken &type, const VtValue &defaultValue, bool isOutput, size_t arraySize, const SdrTokenMap &metadata, const SdrTokenMap &hints, const SdrOptionVec &options)
 
virtual SDR_API ~SdrShaderProperty ()
 Destructor.
 
The Basics
SDR_API const TfTokenGetName () const
 Gets the name of the property.
 
SDR_API const TfTokenGetType () const
 Gets the type of the property.
 
SDR_API const VtValueGetDefaultValue () const
 Gets this property's default value associated with the type of the property.
 
SDR_API bool IsOutput () const
 Whether this property is an output.
 
SDR_API bool IsArray () const
 Whether this property's type is an array type.
 
SDR_API bool IsDynamicArray () const
 Whether this property's array type is dynamically-sized.
 
SDR_API int GetArraySize () const
 Gets this property's array size.
 
SDR_API int GetTupleSize () const
 Gets this property's tuple size.
 
SDR_API std::string GetInfoString () const
 Gets a string with basic information about this property.
 
Metadata

The metadata returned here is a direct result of what the parser plugin is able to determine about the property.

See the documentation for a specific parser plugin to get help on what the parser is looking for to populate these values.

SDR_API const SdrTokenMap & GetMetadata () const
 All of the metadata that came from the parse process.
 
SDR_API const TfTokenGetLabel () const
 The label assigned to this property, if any.
 
SDR_API std::string GetHelp () const
 The help message assigned to this property, if any.
 
SDR_API const TfTokenGetPage () const
 The page (group), eg "Advanced", this property appears on, if any.
 
SDR_API const TfTokenGetWidget () const
 The widget "hint" that indicates the widget that can best display the type of data contained in this property, if any.
 
SDR_API const SdrTokenMap & GetHints () const
 Any UI "hints" that are associated with this property.
 
SDR_API const SdrOptionVec & GetOptions () const
 If the property has a set of valid values that are pre-determined, this will return the valid option names and corresponding string values (if the option was specified with a value).
 
SDR_API std::string GetImplementationName () const
 Returns the implementation name of this property.
 
SDR_API std::string GetShownIf () const
 A boolean expression (SdfBooleanExpression) that determines if the property should be shown in the UI based on the state of other properties of the same node.
 
VStruct Information
SDR_API const TfTokenGetVStructMemberOf () const
 If this field is part of a vstruct, this is the name of the struct.
 
SDR_API const TfTokenGetVStructMemberName () const
 If this field is part of a vstruct, this is its name in the struct.
 
SDR_API bool IsVStructMember () const
 Returns true if this field is part of a vstruct.
 
SDR_API bool IsVStruct () const
 Returns true if the field is the head of a vstruct.
 
SDR_API const TfTokenGetVStructConditionalExpr () const
 If this field is part of a vstruct, this is the conditional expression.
 
Connection Information
SDR_API bool IsConnectable () const
 Whether this property can be connected to other properties.
 
SDR_API const SdrTokenVec & GetValidConnectionTypes () const
 Gets the list of valid connection types for this property.
 
SDR_API bool CanConnectTo (const SdrShaderProperty &other) const
 Determines if this property can be connected to the specified property.
 
Utilities
SDR_API SdrSdfTypeIndicator GetTypeAsSdfType () const
 Converts the property's type from GetType() into a SdrSdfTypeIndicator.
 
SDR_API const VtValueGetDefaultValueAsSdfType () const
 Accessor for default value corresponding to the SdfValueTypeName returned by GetTypeAsSdfType.
 
SDR_API bool IsAssetIdentifier () const
 Determines if the value held by this property is an asset identifier (eg, a file path); the logic for this is left up to the parser.
 
SDR_API bool IsDefaultInput () const
 Determines if the value held by this property is the default input for this node.
 

Protected Member Functions

SdrShaderPropertyoperator= (const SdrShaderProperty &)=delete
 
void _SetUsdEncodingVersion (int usdEncodingVersion)
 
void _ConvertToVStruct ()
 
void _ConvertExpressions (const SdrShaderPropertyUniquePtrVec &properties, SdrShaderNodeConstPtr shader)
 
void _FinalizeProperty ()
 

Protected Attributes

TfToken _name
 
TfToken _type
 
VtValue _defaultValue
 
bool _isOutput
 
size_t _arraySize
 
size_t _tupleSize
 
bool _isDynamicArray
 
bool _isConnectable
 
SdrTokenMap _metadata
 
const SdrTokenMap _hints
 
const SdrOptionVec _options
 
SdrTokenVec _validConnectionTypes
 
TfToken _label
 
TfToken _page
 
TfToken _widget
 
TfToken _vstructMemberOf
 
TfToken _vstructMemberName
 
TfToken _vstructConditionalExpr
 
VtValue _sdfTypeDefaultValue
 
int _usdEncodingVersion
 

Friends

void SdrShaderNode::_PostProcessProperties ()
 

Detailed Description

Represents a property (input or output) that is part of a SdrShaderNode instance.

A property must have a name and type, but may also specify a host of additional metadata. Instances can also be queried to determine if another SdrShaderProperty instance can be connected to it.

Definition at line 95 of file shaderProperty.h.

Constructor & Destructor Documentation

◆ ~SdrShaderProperty()

virtual SDR_API ~SdrShaderProperty ( )
virtual

Destructor.

Member Function Documentation

◆ CanConnectTo()

SDR_API bool CanConnectTo ( const SdrShaderProperty other) const

Determines if this property can be connected to the specified property.

◆ GetArraySize()

SDR_API int GetArraySize ( ) const
inline

Gets this property's array size.

If this property is a fixed-size array type, the array size is returned. In the case of a dynamically-sized array, this method returns the array size that the parser reports, and should not be relied upon to be accurate. A parser may report -1 for the array size, for example, to indicate a dynamically-sized array. For types that are not a fixed-size array or dynamic array, this returns 0.

Definition at line 154 of file shaderProperty.h.

◆ GetDefaultValue()

SDR_API const VtValue & GetDefaultValue ( ) const
inline

Gets this property's default value associated with the type of the property.

See also
GetType()

Definition at line 131 of file shaderProperty.h.

◆ GetDefaultValueAsSdfType()

SDR_API const VtValue & GetDefaultValueAsSdfType ( ) const
inline

Accessor for default value corresponding to the SdfValueTypeName returned by GetTypeAsSdfType.

Note that this is different than GetDefaultValue which returns the default value associated with the SdrPropertyType and may differ from the SdfValueTypeName, example when sdrUsdDefinitionType metadata is specified for a sdr property.

See also
GetTypeAsSdfType

Definition at line 327 of file shaderProperty.h.

◆ GetHelp()

SDR_API std::string GetHelp ( ) const

The help message assigned to this property, if any.

◆ GetHints()

SDR_API const SdrTokenMap & GetHints ( ) const
inline

Any UI "hints" that are associated with this property.

"Hints" are simple key/value pairs.

Definition at line 211 of file shaderProperty.h.

◆ GetImplementationName()

SDR_API std::string GetImplementationName ( ) const

Returns the implementation name of this property.

The name of the property is how to refer to the property in shader networks. The label is how to present this property to users. The implementation name is the name of the parameter this property represents in the implementation. Any client using the implementation must call this method to get the correct name; using getName() is not correct.

◆ GetInfoString()

SDR_API std::string GetInfoString ( ) const

Gets a string with basic information about this property.

Helpful for things like adding this property to a log.

◆ GetLabel()

SDR_API const TfToken & GetLabel ( ) const
inline

The label assigned to this property, if any.

Distinct from the name returned from GetName(). In the context of a UI, the label value might be used as the display name for the property instead of the name.

Definition at line 190 of file shaderProperty.h.

◆ GetMetadata()

SDR_API const SdrTokenMap & GetMetadata ( ) const
inline

All of the metadata that came from the parse process.

Definition at line 184 of file shaderProperty.h.

◆ GetName()

SDR_API const TfToken & GetName ( ) const
inline

Gets the name of the property.

Definition at line 120 of file shaderProperty.h.

◆ GetOptions()

SDR_API const SdrOptionVec & GetOptions ( ) const
inline

If the property has a set of valid values that are pre-determined, this will return the valid option names and corresponding string values (if the option was specified with a value).

Definition at line 217 of file shaderProperty.h.

◆ GetPage()

SDR_API const TfToken & GetPage ( ) const
inline

The page (group), eg "Advanced", this property appears on, if any.

Note that the page for a shader property can be nested, delimited by ":", representing the hierarchy of sub-pages a property is defined in.

Definition at line 200 of file shaderProperty.h.

◆ GetShownIf()

SDR_API std::string GetShownIf ( ) const

A boolean expression (SdfBooleanExpression) that determines if the property should be shown in the UI based on the state of other properties of the same node.

If an expression is not provided for SdrPropertyMetadata->ShownIf and the property instead contains conditional visibility metadata expressed in the style of Katana "args" files, an attempt will be made to convert the condition into an SdfBooleanExpression-style boolean expression.

◆ GetTupleSize()

SDR_API int GetTupleSize ( ) const
inline

Gets this property's tuple size.

The tuple size indicates an array's "column count", or how many elements it takes to form a logical row. For non-dynamic arrays, the array size should be a multiple of the tuple size.

If no tuple size is specified, returns 0.

See also
GetArraySize()

Definition at line 166 of file shaderProperty.h.

◆ GetType()

SDR_API const TfToken & GetType ( ) const
inline

Gets the type of the property.

Definition at line 124 of file shaderProperty.h.

◆ GetTypeAsSdfType()

SDR_API SdrSdfTypeIndicator GetTypeAsSdfType ( ) const

Converts the property's type from GetType() into a SdrSdfTypeIndicator.

Two scenarios can result: an exact mapping from property type to Sdf type, and an inexact mapping. In the first scenario, SdrSdfTypeIndicator will contain a cleanly-mapped Sdf type. In the second scenario, the SdrSdfTypeIndicator will contain an Sdf type set to Token to indicate an unclean mapping, and SdrSdfTypeIndicator::GetSdrType will be set to the original type returned by GetType().

See also
GetDefaultValueAsSdfType()

◆ GetValidConnectionTypes()

SDR_API const SdrTokenVec & GetValidConnectionTypes ( ) const
inline

Gets the list of valid connection types for this property.

This value comes from shader metadata, and may not be specified. The value from SdrShaderProperty::GetType() can be used as a fallback, or you can use the connectability test in CanConnectTo().

Definition at line 290 of file shaderProperty.h.

◆ GetVStructConditionalExpr()

SDR_API const TfToken & GetVStructConditionalExpr ( ) const
inline

If this field is part of a vstruct, this is the conditional expression.

Definition at line 269 of file shaderProperty.h.

◆ GetVStructMemberName()

SDR_API const TfToken & GetVStructMemberName ( ) const
inline

If this field is part of a vstruct, this is its name in the struct.

Definition at line 254 of file shaderProperty.h.

◆ GetVStructMemberOf()

SDR_API const TfToken & GetVStructMemberOf ( ) const
inline

If this field is part of a vstruct, this is the name of the struct.

Definition at line 248 of file shaderProperty.h.

◆ GetWidget()

SDR_API const TfToken & GetWidget ( ) const
inline

The widget "hint" that indicates the widget that can best display the type of data contained in this property, if any.

Examples of this value could include "number", "slider", etc.

Definition at line 206 of file shaderProperty.h.

◆ IsArray()

SDR_API bool IsArray ( ) const
inline

Whether this property's type is an array type.

Definition at line 139 of file shaderProperty.h.

◆ IsAssetIdentifier()

SDR_API bool IsAssetIdentifier ( ) const

Determines if the value held by this property is an asset identifier (eg, a file path); the logic for this is left up to the parser.

Note: The type returned from GetTypeAsSdfType() will be Asset if this method returns true (even though its true underlying data type is string).

◆ IsConnectable()

SDR_API bool IsConnectable ( ) const
inline

Whether this property can be connected to other properties.

If this returns true, connectability to a specific property can be tested via CanConnectTo().

Definition at line 283 of file shaderProperty.h.

◆ IsDefaultInput()

SDR_API bool IsDefaultInput ( ) const

Determines if the value held by this property is the default input for this node.

◆ IsDynamicArray()

SDR_API bool IsDynamicArray ( ) const
inline

Whether this property's array type is dynamically-sized.

Definition at line 143 of file shaderProperty.h.

◆ IsOutput()

SDR_API bool IsOutput ( ) const
inline

Whether this property is an output.

Definition at line 135 of file shaderProperty.h.

◆ IsVStruct()

SDR_API bool IsVStruct ( ) const

Returns true if the field is the head of a vstruct.

◆ IsVStructMember()

SDR_API bool IsVStructMember ( ) const

Returns true if this field is part of a vstruct.

Member Data Documentation

◆ _arraySize

size_t _arraySize
protected

Definition at line 378 of file shaderProperty.h.

◆ _defaultValue

VtValue _defaultValue
protected

Definition at line 376 of file shaderProperty.h.

◆ _hints

const SdrTokenMap _hints
protected

Definition at line 386 of file shaderProperty.h.

◆ _isConnectable

bool _isConnectable
protected

Definition at line 381 of file shaderProperty.h.

◆ _isDynamicArray

bool _isDynamicArray
protected

Definition at line 380 of file shaderProperty.h.

◆ _isOutput

bool _isOutput
protected

Definition at line 377 of file shaderProperty.h.

◆ _label

TfToken _label
protected

Definition at line 391 of file shaderProperty.h.

◆ _metadata

SdrTokenMap _metadata
protected

Definition at line 382 of file shaderProperty.h.

◆ _name

TfToken _name
protected

Definition at line 374 of file shaderProperty.h.

◆ _options

const SdrOptionVec _options
protected

Definition at line 387 of file shaderProperty.h.

◆ _page

TfToken _page
protected

Definition at line 392 of file shaderProperty.h.

◆ _sdfTypeDefaultValue

VtValue _sdfTypeDefaultValue
protected

Definition at line 398 of file shaderProperty.h.

◆ _tupleSize

size_t _tupleSize
protected

Definition at line 379 of file shaderProperty.h.

◆ _type

TfToken _type
protected

Definition at line 375 of file shaderProperty.h.

◆ _usdEncodingVersion

int _usdEncodingVersion
protected

Definition at line 402 of file shaderProperty.h.

◆ _validConnectionTypes

SdrTokenVec _validConnectionTypes
protected

Definition at line 390 of file shaderProperty.h.

◆ _vstructConditionalExpr

TfToken _vstructConditionalExpr
protected

Definition at line 396 of file shaderProperty.h.

◆ _vstructMemberName

TfToken _vstructMemberName
protected

Definition at line 395 of file shaderProperty.h.

◆ _vstructMemberOf

TfToken _vstructMemberOf
protected

Definition at line 394 of file shaderProperty.h.

◆ _widget

TfToken _widget
protected

Definition at line 393 of file shaderProperty.h.


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