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 SdrShaderPropertyMetadata &metadata, const SdrTokenMap &hints, const SdrOptionVec &options)
 Constructor.
 
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.

const SdrTokenMap & GetMetadata () const
 All of the metadata that came from the parse process.
 
const SdrShaderPropertyMetadataGetMetadataObject () 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 _legacyMetadata
 
SdrShaderPropertyMetadata _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.

Note
SdrTokenMap metadata is deprecated in favor of SdrShaderPropertyMetadata.

Definition at line 56 of file shaderProperty.h.

Constructor & Destructor Documentation

◆ SdrShaderProperty()

SDR_API SdrShaderProperty ( const TfToken name,
const TfToken type,
const VtValue defaultValue,
bool  isOutput,
size_t  arraySize,
const SdrShaderPropertyMetadata metadata,
const SdrTokenMap &  hints,
const SdrOptionVec &  options 
)

Constructor.

Deprecated:
The version of the SdrShaderProperty constructor that takes a SdrTokenMap as metadata is deprecated in favor of the constructor taking SdrShaderPropertyMetadata. Note that SdrShaderPropertyMetadata has an implicit constructor from the legacy SdrTokenMap metadata.
See also
SdrShaderPropertyMetadata::SdrShaderPropertyMetadata(const SdrTokenMap&)

◆ ~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 123 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 100 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 312 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 192 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 171 of file shaderProperty.h.

◆ GetMetadata()

const SdrTokenMap & GetMetadata ( ) const
inline

All of the metadata that came from the parse process.

Deprecated:
in favor of GetMetadataObject

If this property was initialized with the upgraded SdrShaderPropertyMetadata class, the legacy metadata returned by this function will contain only string representations of named metadata, and any other metadata items whose value holds a string type in SdrShaderNodeMetadata. Other metadata items may be omitted.

Definition at line 160 of file shaderProperty.h.

◆ GetMetadataObject()

const SdrShaderPropertyMetadata & GetMetadataObject ( ) const
inline

All of the metadata that came from the parse process.

Definition at line 163 of file shaderProperty.h.

◆ GetName()

SDR_API const TfToken & GetName ( ) const
inline

Gets the name of the property.

Definition at line 89 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 198 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 181 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 135 of file shaderProperty.h.

◆ GetType()

SDR_API const TfToken & GetType ( ) const
inline

Gets the type of the property.

Definition at line 93 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 275 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 250 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 235 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 229 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 187 of file shaderProperty.h.

◆ IsArray()

SDR_API bool IsArray ( ) const
inline

Whether this property's type is an array type.

Definition at line 108 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().

Properties are by default connectable – note that when SdrShaderPropertyMetadata::HasConnectable is false, this method SdrShaderProperty::IsConnectable will return true.

Definition at line 268 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 112 of file shaderProperty.h.

◆ IsOutput()

SDR_API bool IsOutput ( ) const
inline

Whether this property is an output.

Definition at line 104 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 363 of file shaderProperty.h.

◆ _defaultValue

VtValue _defaultValue
protected

Definition at line 361 of file shaderProperty.h.

◆ _hints

const SdrTokenMap _hints
protected

Definition at line 372 of file shaderProperty.h.

◆ _isConnectable

bool _isConnectable
protected

Definition at line 366 of file shaderProperty.h.

◆ _isDynamicArray

bool _isDynamicArray
protected

Definition at line 365 of file shaderProperty.h.

◆ _isOutput

bool _isOutput
protected

Definition at line 362 of file shaderProperty.h.

◆ _label

TfToken _label
protected

Definition at line 377 of file shaderProperty.h.

◆ _legacyMetadata

SdrTokenMap _legacyMetadata
protected

Definition at line 367 of file shaderProperty.h.

◆ _metadata

SdrShaderPropertyMetadata _metadata
protected

Definition at line 368 of file shaderProperty.h.

◆ _name

TfToken _name
protected

Definition at line 359 of file shaderProperty.h.

◆ _options

const SdrOptionVec _options
protected

Definition at line 373 of file shaderProperty.h.

◆ _page

TfToken _page
protected

Definition at line 378 of file shaderProperty.h.

◆ _sdfTypeDefaultValue

VtValue _sdfTypeDefaultValue
protected

Definition at line 384 of file shaderProperty.h.

◆ _tupleSize

size_t _tupleSize
protected

Definition at line 364 of file shaderProperty.h.

◆ _type

TfToken _type
protected

Definition at line 360 of file shaderProperty.h.

◆ _usdEncodingVersion

int _usdEncodingVersion
protected

Definition at line 388 of file shaderProperty.h.

◆ _validConnectionTypes

SdrTokenVec _validConnectionTypes
protected

Definition at line 376 of file shaderProperty.h.

◆ _vstructConditionalExpr

TfToken _vstructConditionalExpr
protected

Definition at line 382 of file shaderProperty.h.

◆ _vstructMemberName

TfToken _vstructMemberName
protected

Definition at line 381 of file shaderProperty.h.

◆ _vstructMemberOf

TfToken _vstructMemberOf
protected

Definition at line 380 of file shaderProperty.h.

◆ _widget

TfToken _widget
protected

Definition at line 379 of file shaderProperty.h.


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