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

#include <shaderNode.h>

Public Types

using ComplianceResults = std::unordered_map< TfToken, std::vector< SdrIdentifier >, TfToken::HashFunctor >
 

Public Member Functions

virtual SDR_API ~SdrShaderNode ()
 Destructor. More...
 
SDR_API VtValue GetDataForKey (const TfToken &key) const
 
Constructors

Constructors for SdrShaderNode

Deprecated:
The versions of the SdrShaderNode constructors that take SdrTokenMap as metadata are deprecated in favor of the constructor taking an explicit SdrShaderNodeMetadata. Note that SdrShaderNodeMetadata has an implicit constructor from the legacy SdrTokenMap metadata.
See Also
SdrShaderNodeMetadata::SdrShaderNodeMetadata(const SdrTokenMap&) {@
SDR_API SdrShaderNode (const SdrIdentifier &identifier, const SdrVersion &version, const std::string &name, const TfToken &function, const TfToken &shadingSystem, const std::string &definitionURI, const std::string &implementationURI, SdrShaderPropertyUniquePtrVec &&properties, const SdrShaderNodeMetadata &metadata=SdrShaderNodeMetadata(), const std::string &sourceCode=std::string())
 Constructor. More...
 
SDR_API SdrShaderNode (const SdrIdentifier &identifier, const SdrVersion &version, const std::string &name, const TfToken &function, const TfToken &context, const TfToken &shadingSystem, const std::string &definitionURI, const std::string &implementationURI, SdrShaderPropertyUniquePtrVec &&properties, const SdrShaderNodeMetadata &metadata=SdrShaderNodeMetadata(), const std::string &sourceCode=std::string())
 
The Basics
const SdrIdentifierGetIdentifier () const
 Return the identifier of the node. More...
 
SdrVersion GetShaderVersion () const
 Return the version of the node. More...
 
const std::string & GetName () const
 Gets the name of the node. More...
 
const TfTokenGetFamily () const
 
const TfTokenGetFunction () const
 
const TfTokenGetShadingSystem () const
 
const TfTokenGetSourceType () const
 
const std::string & GetResolvedDefinitionURI () const
 
const std::string & GetResolvedImplementationURI () const
 
const std::string & GetSourceCode () const
 
SDR_API bool IsValid () const
 
SDR_API std::string GetInfoString () const
 
Inputs and Outputs

An input or output is also generically referred to as a "property".

SDR_API const SdrTokenVecGetShaderInputNames () const
 Get an ordered list of all the input names on this shader node. More...
 
SDR_API const SdrTokenVecGetShaderOutputNames () const
 Get an ordered list of all the output names on this shader node. More...
 
SDR_API SdrShaderPropertyConstPtr GetShaderInput (const TfToken &inputName) const
 
SDR_API SdrShaderPropertyConstPtr GetShaderOutput (const TfToken &outputName) const
 
SDR_API SdrTokenVec GetAssetIdentifierInputNames () const
 
SDR_API SdrShaderPropertyConstPtr GetDefaultInput () const
 
Metadata

The metadata returned here is a direct result of what the parser plugin is able to determine about the node. 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 SdrTokenMapGetMetadata () const
 
SDR_API const
SdrShaderNodeMetadata
GetMetadataObject () const
 All metadata that came from the parse process. More...
 
const TfTokenGetDomain () const
 
const TfTokenGetSubdomain () const
 
const TfTokenGetContext () const
 
SDR_API TfToken GetRole () const
 
SDR_API const TfTokenGetLabel () const
 
SDR_API const TfTokenGetCategory () const
 
SDR_API std::string GetHelp () const
 
SDR_API const SdrTokenVecGetDepartments () const
 
SDR_API const SdrTokenVecGetOpenPages () const
 Gets the pages which should be opened or expanded by default. More...
 
SDR_API const SdrTokenMapGetPagesShownIf () const
 Gets the shownIf expressions associated with each page. More...
 
SDR_API const SdrTokenVecGetPrimvars () const
 
SDR_API const SdrTokenVecGetAdditionalPrimvarProperties () const
 
SDR_API std::string GetImplementationName () const
 
Aggregate Information
SDR_API const SdrTokenVecGetPages () const
 
SDR_API SdrTokenVec GetPropertyNamesForPage (const std::string &pageName) const
 
SDR_API SdrTokenVec GetAllVstructNames () const
 Gets all vstructs that are present in the shader. More...
 

Static Public Member Functions

static SDR_API ComplianceResults CheckPropertyCompliance (const std::vector< SdrShaderNodeConstPtr > &shaderNodes)
 

Protected Member Functions

SdrShaderNodeoperator= (const SdrShaderNode &)=delete
 

Protected Attributes

bool _isValid
 
SdrIdentifier _identifier
 
SdrVersion _version
 
std::string _name
 
TfToken _function
 
TfToken _context
 
TfToken _shadingSystem
 
std::string _definitionURI
 
std::string _implementationURI
 
SdrShaderPropertyUniquePtrVec _properties
 
SdrTokenMap _legacyMetadata
 
SdrShaderNodeMetadata _metadata
 
std::string _sourceCode
 
SdrShaderPropertyMap _inputs
 
SdrTokenVec _inputNames
 
SdrShaderPropertyMap _outputs
 
SdrTokenVec _outputNames
 
TfToken _domain
 
TfToken _subdomain
 
TfToken _label
 
TfToken _category
 
SdrTokenVec _departments
 
SdrTokenVec _openPages
 
SdrTokenMap _pagesShownIf
 
SdrTokenVec _primvars
 
SdrTokenVec _primvarNamingProperties
 
SdrTokenVec _pages
 

Detailed Description

Represents a node that holds shading information. Describes information like the name of the node, what its inputs and outputs are, and any associated metadata.

Definition at line 44 of file shaderNode.h.

Member Typedef Documentation

using SdrShaderNode::ComplianceResults = std::unordered_map<TfToken, std::vector<SdrIdentifier>, TfToken::HashFunctor>

Definition at line 390 of file shaderNode.h.

Constructor & Destructor Documentation

SDR_API SdrShaderNode::SdrShaderNode ( const SdrIdentifier identifier,
const SdrVersion version,
const std::string &  name,
const TfToken function,
const TfToken shadingSystem,
const std::string &  definitionURI,
const std::string &  implementationURI,
SdrShaderPropertyUniquePtrVec &&  properties,
const SdrShaderNodeMetadata metadata = SdrShaderNodeMetadata(),
const std::string &  sourceCode = std::string() 
)
inline

Constructor.

Definition at line 63 of file shaderNode.h.

SDR_API SdrShaderNode::SdrShaderNode ( const SdrIdentifier identifier,
const SdrVersion version,
const std::string &  name,
const TfToken function,
const TfToken context,
const TfToken shadingSystem,
const std::string &  definitionURI,
const std::string &  implementationURI,
SdrShaderPropertyUniquePtrVec &&  properties,
const SdrShaderNodeMetadata metadata = SdrShaderNodeMetadata(),
const std::string &  sourceCode = std::string() 
)
Deprecated:
Deprecated in favor of the above constructor that expects the "context" concept to be specified in metadata instead of as a direct constructor argument.
virtual SDR_API SdrShaderNode::~SdrShaderNode ( )
virtual

Destructor.

Member Function Documentation

static SDR_API ComplianceResults SdrShaderNode::CheckPropertyCompliance ( const std::vector< SdrShaderNodeConstPtr > &  shaderNodes)
static

This method checks if same named properties of shaderNodes are compatible with each other.

Checks if the same name properties have matching types and default values. In order to determine if same name properties from different shader nodes are compliant, we assume that the first shaderNode in the list providing this property is authoritative, and other nodes differing wrt this property are non-compliant. A map of property names and their respective shaderNodes are stored in the map. An empty map returned represents no compliance issues.

SDR_API const SdrTokenVec& SdrShaderNode::GetAdditionalPrimvarProperties ( ) const
inline

The list of string input properties whose values provide the names of additional primvars consumed by this node. For example, this may return a token named varname. This indicates that the client should query the value of a (presumed to be string-valued) input attribute named varname from its scene description to determine the name of a primvar the node will consume. See GetPrimvars() for additional information.

Definition at line 346 of file shaderNode.h.

SDR_API SdrTokenVec SdrShaderNode::GetAllVstructNames ( ) const

Gets all vstructs that are present in the shader.

SDR_API SdrTokenVec SdrShaderNode::GetAssetIdentifierInputNames ( ) const

Returns the list of all inputs that are tagged as asset identifier inputs.

SDR_API const TfToken& SdrShaderNode::GetCategory ( ) const
inline

The category assigned to this node, if any. Distinct from the family returned from GetFamily().

Deprecated:

Returns an empty TfToken if no category is present.

Definition at line 304 of file shaderNode.h.

const TfToken& SdrShaderNode::GetContext ( ) const
inline

Gets the context of the node.

Context describes a node's usage group within its subdomain.

See Also
SdrShaderNodeMetadata::GetContext.

If the context metadatda doesn't exist, returns an empty TfToken.

Definition at line 278 of file shaderNode.h.

SDR_API VtValue SdrShaderNode::GetDataForKey ( const TfToken key) const

Gets an item of data from this shader node according to the requested key. Special keys indicate class fields and are identified by the SdrNodeFieldKey enum. The return type of GetDataForKey for these special keys is the return type of their getters. GetDataForKey(SdrNodeFieldKey->Identifier) results in VtValue holding a TfToken because GetIdentifier returns TfToken. The return types for these special keys is as follows:

Any requested data item that isn't a SdrNodeFieldKey will be looked for in this shader node's metadata.

Returns an empty VtValue if no data is found to be associated with the requested key.

SDR_API SdrShaderPropertyConstPtr SdrShaderNode::GetDefaultInput ( ) const

Returns the first shader input that is tagged as the default input. A default input and its value can be used to acquire a fallback value for a node when the node is considered 'disabled' or otherwise incapable of producing an output value.

SDR_API const SdrTokenVec& SdrShaderNode::GetDepartments ( ) const
inline

The departments this node is associated with, if any.

Deprecated:

Definition at line 316 of file shaderNode.h.

const TfToken& SdrShaderNode::GetDomain ( ) const
inline

Gets the domain of the node.

See Also
SdrShaderNodeMetadata::GetDomain

Definition at line 263 of file shaderNode.h.

const TfToken& SdrShaderNode::GetFamily ( ) const
inline

Gets the name of the family that the node belongs to. An empty token will be returned if the node does not belong to a family.

Deprecated:
in favor of SdrShaderNode::GetFunction

Definition at line 127 of file shaderNode.h.

const TfToken& SdrShaderNode::GetFunction ( ) const
inline

Gets the function that the node belongs to.

One example of a function would be "add" – multiple specializations on argument types and version may be registered under the same function but on different nodes.

Definition at line 134 of file shaderNode.h.

SDR_API std::string SdrShaderNode::GetHelp ( ) const

The help message assigned to this node, if any.

Returns an empty string if no help message is present.

const SdrIdentifier& SdrShaderNode::GetIdentifier ( ) const
inline

Return the identifier of the node.

Definition at line 115 of file shaderNode.h.

SDR_API std::string SdrShaderNode::GetImplementationName ( ) const

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

SDR_API std::string SdrShaderNode::GetInfoString ( ) const

Gets a string with basic information about this node. Helpful for things like adding this node to a log.

SDR_API const TfToken& SdrShaderNode::GetLabel ( ) const
inline

The label assigned to this node, 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 node instead of the name.

Returns an empty TfToken if no label is present.

Definition at line 295 of file shaderNode.h.

SDR_API const SdrTokenMap& SdrShaderNode::GetMetadata ( ) const

All metadata that came from the parse process.

Deprecated:
in favor of GetMetadataObject

If this node was initialized with the upgraded SdrShaderNodeMetadata 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.

SDR_API const SdrShaderNodeMetadata& SdrShaderNode::GetMetadataObject ( ) const

All metadata that came from the parse process.

const std::string& SdrShaderNode::GetName ( ) const
inline

Gets the name of the node.

Definition at line 121 of file shaderNode.h.

SDR_API const SdrTokenVec& SdrShaderNode::GetOpenPages ( ) const
inline

Gets the pages which should be opened or expanded by default.

Definition at line 320 of file shaderNode.h.

SDR_API const SdrTokenVec& SdrShaderNode::GetPages ( ) const
inline

Gets the pages on which the node's properties reside (an aggregate of the unique SdrShaderProperty::GetPage() values for all of the node's properties). Nodes themselves do not reside on pages. In an example scenario, properties might be divided into two pages, 'Simple' and 'Advanced'.

Definition at line 372 of file shaderNode.h.

SDR_API const SdrTokenMap& SdrShaderNode::GetPagesShownIf ( ) const
inline

Gets the shownIf expressions associated with each page.

Definition at line 324 of file shaderNode.h.

SDR_API const SdrTokenVec& SdrShaderNode::GetPrimvars ( ) const
inline

The list of primvars this node knows it requires / uses. For example, a shader node may require the 'normals' primvar to function correctly. Additional, user specified primvars may have been authored on the node. These can be queried via GetAdditionalPrimvarProperties(). Together, GetPrimvars() and GetAdditionalPrimvarProperties(), provide the complete list of primvar requirements for the node.

Note that SdrShaderNode::GetPrimvars isn't equivalent to SdrShaderNodeMetadata::GetPrimvars. The former returns primvars processed with access to SdrShaderProperty information.

Definition at line 337 of file shaderNode.h.

SDR_API SdrTokenVec SdrShaderNode::GetPropertyNamesForPage ( const std::string &  pageName) const

Gets the names of the properties on a certain page (one that was returned by GetPages()). To get properties that are not assigned to a page, an empty string can be used for pageName.

const std::string& SdrShaderNode::GetResolvedDefinitionURI ( ) const
inline

Gets the URI to the resource that provided this node's definition. Could be a path to a file, or some other resource identifier. This URI should be fully resolved.

See Also
SdrShaderNode::GetResolvedImplementationURI()

Definition at line 158 of file shaderNode.h.

const std::string& SdrShaderNode::GetResolvedImplementationURI ( ) const
inline

Gets the URI to the resource that provides this node's implementation. Could be a path to a file, or some other resource identifier. This URI should be fully resolved.

See Also
SdrShaderNode::GetResolvedDefinitionURI()

Definition at line 165 of file shaderNode.h.

SDR_API TfToken SdrShaderNode::GetRole ( ) const

Returns the role of this node.

Role provides finer granularity for contexts that contain many nodes.

See Also
SdrShaderNodeMetadata::GetRole

If no role exists, returns the name of this node.

SDR_API SdrShaderPropertyConstPtr SdrShaderNode::GetShaderInput ( const TfToken inputName) const

Get a shader input property by name. nullptr is returned if an input with the given name does not exist.

SDR_API const SdrTokenVec& SdrShaderNode::GetShaderInputNames ( ) const

Get an ordered list of all the input names on this shader node.

SDR_API SdrShaderPropertyConstPtr SdrShaderNode::GetShaderOutput ( const TfToken outputName) const

Get a shader output property by name. nullptr is returned if an output with the given name does not exist.

SDR_API const SdrTokenVec& SdrShaderNode::GetShaderOutputNames ( ) const

Get an ordered list of all the output names on this shader node.

SdrVersion SdrShaderNode::GetShaderVersion ( ) const
inline

Return the version of the node.

Definition at line 118 of file shaderNode.h.

const TfToken& SdrShaderNode::GetShadingSystem ( ) const
inline

Gets the shading system that this shader node originated from.

"Shading system" describes a system that usually has its own standard and shading language

As a concrete example from the Sdr library, several shader parsers exist and operate on shaders from different shading systems. In this scenario, each distinct type of shader (OSL, Args, etc) is considered a different shading system, even though they are all shaders.

Definition at line 145 of file shaderNode.h.

const std::string& SdrShaderNode::GetSourceCode ( ) const
inline

Returns the source code for this node. This will be empty for most nodes. It will be non-empty only for the nodes that are constructed using SdrRegistry::GetShaderNodeFromSourceCode(), in which case, the source code has not been parsed (or even compiled) yet.

An unparsed node with non-empty source-code but no properties is considered to be invalid. Once the node is parsed and the relevant properties and metadata are extracted from the source code, the node becomes valid.

See Also
SdrShaderNode::IsValid

Definition at line 180 of file shaderNode.h.

const TfToken& SdrShaderNode::GetSourceType ( ) const
inline

Gets the type of source that this shader node originated from.

Deprecated:
Deprecated in favor of GetShadingSystem

Definition at line 151 of file shaderNode.h.

const TfToken& SdrShaderNode::GetSubdomain ( ) const
inline

Gets the subdomain of the node if the subdomain metadata item exists.

If the subdomain metadata doesn't exist, returns an empty TfToken.

See Also
SdrShaderNodeMetadata::GetSubdomain

Definition at line 270 of file shaderNode.h.

SDR_API bool SdrShaderNode::IsValid ( ) const
inline

Whether or not this node is valid. A node that is valid indicates that the parser plugin was able to successfully parse the contents of this node.

Note that if a node is not valid, some data like its name, URI, source code etc. could still be available (data that was obtained during the discovery process). However, other data that must be gathered from the parsing process will NOT be available (eg, inputs and outputs).

Definition at line 191 of file shaderNode.h.

SdrShaderNode& SdrShaderNode::operator= ( const SdrShaderNode )
protecteddelete

Member Data Documentation

TfToken SdrShaderNode::_category
protected

Definition at line 467 of file shaderNode.h.

TfToken SdrShaderNode::_context
protected

Definition at line 448 of file shaderNode.h.

std::string SdrShaderNode::_definitionURI
protected

Definition at line 450 of file shaderNode.h.

SdrTokenVec SdrShaderNode::_departments
protected

Definition at line 468 of file shaderNode.h.

TfToken SdrShaderNode::_domain
protected

Definition at line 464 of file shaderNode.h.

TfToken SdrShaderNode::_function
protected

Definition at line 447 of file shaderNode.h.

SdrIdentifier SdrShaderNode::_identifier
protected

Definition at line 444 of file shaderNode.h.

std::string SdrShaderNode::_implementationURI
protected

Definition at line 451 of file shaderNode.h.

SdrTokenVec SdrShaderNode::_inputNames
protected

Definition at line 458 of file shaderNode.h.

SdrShaderPropertyMap SdrShaderNode::_inputs
protected

Definition at line 457 of file shaderNode.h.

bool SdrShaderNode::_isValid
protected

Definition at line 443 of file shaderNode.h.

TfToken SdrShaderNode::_label
protected

Definition at line 466 of file shaderNode.h.

SdrTokenMap SdrShaderNode::_legacyMetadata
protected

Definition at line 453 of file shaderNode.h.

SdrShaderNodeMetadata SdrShaderNode::_metadata
protected

Definition at line 454 of file shaderNode.h.

std::string SdrShaderNode::_name
protected

Definition at line 446 of file shaderNode.h.

SdrTokenVec SdrShaderNode::_openPages
protected

Definition at line 469 of file shaderNode.h.

SdrTokenVec SdrShaderNode::_outputNames
protected

Definition at line 460 of file shaderNode.h.

SdrShaderPropertyMap SdrShaderNode::_outputs
protected

Definition at line 459 of file shaderNode.h.

SdrTokenVec SdrShaderNode::_pages
protected

Definition at line 480 of file shaderNode.h.

SdrTokenMap SdrShaderNode::_pagesShownIf
protected

Definition at line 470 of file shaderNode.h.

SdrTokenVec SdrShaderNode::_primvarNamingProperties
protected

Definition at line 477 of file shaderNode.h.

SdrTokenVec SdrShaderNode::_primvars
protected

Definition at line 476 of file shaderNode.h.

SdrShaderPropertyUniquePtrVec SdrShaderNode::_properties
protected

Definition at line 452 of file shaderNode.h.

TfToken SdrShaderNode::_shadingSystem
protected

Definition at line 449 of file shaderNode.h.

std::string SdrShaderNode::_sourceCode
protected

Definition at line 455 of file shaderNode.h.

TfToken SdrShaderNode::_subdomain
protected

Definition at line 465 of file shaderNode.h.

SdrVersion SdrShaderNode::_version
protected

Definition at line 445 of file shaderNode.h.


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