8#ifndef PXR_USD_SDR_SHADER_NODE_H
9#define PXR_USD_SDR_SHADER_NODE_H
14#include "pxr/usd/sdr/api.h"
17#include "pxr/base/vt/value.h"
21#include <unordered_map>
23PXR_NAMESPACE_OPEN_SCOPE
28#define SDR_NODE_METADATA_TOKENS \
29 ((Category, "category")) \
31 ((Departments, "departments")) \
35 ((OpenPages, "openPages")) \
36 ((Primvars, "primvars")) \
37 ((ImplementationName, "__SDR__implementationName"))\
38 ((Target, "__SDR__target")) \
39 ((SdrUsdEncodingVersion, "sdrUsdEncodingVersion")) \
40 ((SdrDefinitionNameFallbackPrefix, "sdrDefinitionNameFallbackPrefix"))
45#define SDR_NODE_METADATA_PREFIX_TOKENS \
46 ((PageShownIf, "pageShownIf"))
53#define SDR_NODE_CONTEXT_TOKENS \
54 ((Pattern, "pattern")) \
55 ((Surface, "surface")) \
56 ((Volume, "volume")) \
57 ((Displacement, "displacement")) \
59 ((DisplayFilter, "displayFilter")) \
60 ((LightFilter, "lightFilter")) \
61 ((PixelFilter, "pixelFilter")) \
62 ((SampleFilter, "sampleFilter"))
64#define SDR_NODE_ROLE_TOKENS \
65 ((Primvar, "primvar")) \
66 ((Texture, "texture")) \
70#define SDR_NODE_FIELD_KEY_TOKENS \
71 ((Identifier, "_identifier")) \
73 ((Family, "_family")) \
74 ((SourceType, "_sourceType"))
96 const std::string& name,
100 const std::string& definitionURI,
101 const std::string& implementationURI,
102 SdrShaderPropertyUniquePtrVec&& properties,
103 const SdrTokenMap& metadata = SdrTokenMap(),
104 const std::string &sourceCode = std::string());
120 const std::string&
GetName()
const {
return _name; }
167 return _implementationURI;
283 const SdrTokenVec&
GetPages()
const {
return _pages; };
310 return _primvarNamingProperties;
343 using ComplianceResults = std::unordered_map<
TfToken,
344 std::vector<SdrIdentifier>,
360 const std::vector<SdrShaderNodeConstPtr> &shaderNodes);
368 void _PostProcessProperties();
404 std::string _definitionURI;
405 std::string _implementationURI;
406 SdrShaderPropertyUniquePtrVec _properties;
407 SdrTokenMap _metadata;
408 std::string _sourceCode;
410 SdrShaderPropertyMap _inputs;
411 SdrTokenVec _inputNames;
412 SdrShaderPropertyMap _outputs;
413 SdrTokenVec _outputNames;
419 SdrTokenVec _primvars;
420 SdrTokenVec _primvarNamingProperties;
425 SdrTokenVec _departments;
427 SdrTokenVec _openPages;
428 SdrTokenMap _pagesShownIf;
432 void _InitializePrimvars();
435 SdrTokenVec _ComputePages()
const;
438PXR_NAMESPACE_CLOSE_SCOPE
Represents a node that holds shading information.
SDR_API const SdrTokenMap & GetMetadata() const
All metadata that came from the parse process.
SDR_API SdrShaderNode(const SdrIdentifier &identifier, const SdrVersion &version, const std::string &name, const TfToken &family, const TfToken &context, const TfToken &sourceType, const std::string &definitionURI, const std::string &implementationURI, SdrShaderPropertyUniquePtrVec &&properties, const SdrTokenMap &metadata=SdrTokenMap(), const std::string &sourceCode=std::string())
Constructor.
SDR_API const SdrTokenVec & GetPrimvars() const
The list of primvars this node knows it requires / uses.
virtual SDR_API ~SdrShaderNode()
Destructor.
SDR_API SdrTokenVec GetAssetIdentifierInputNames() const
Returns the list of all inputs that are tagged as asset identifier inputs.
SDR_API const SdrTokenVec & GetAdditionalPrimvarProperties() const
The list of string input properties whose values provide the names of additional primvars consumed by...
const SdrIdentifier & GetIdentifier() const
Return the identifier of the node.
SDR_API const TfToken & GetLabel() const
The label assigned to this node, if any.
SDR_API SdrShaderPropertyConstPtr GetShaderInput(const TfToken &inputName) const
Get a shader input property by name.
const TfToken & GetFamily() const
Gets the name of the family that the node belongs to.
static SDR_API ComplianceResults CheckPropertyCompliance(const std::vector< SdrShaderNodeConstPtr > &shaderNodes)
This method checks if same named properties of shaderNodes are compatible with each other.
SDR_API SdrTokenVec GetAllVstructNames() const
Gets all vstructs that are present in the shader.
SDR_API const TfToken & GetCategory() const
The category assigned to this node, if any.
const std::string & GetName() const
Gets the name of the node.
SDR_API SdrTokenVec GetPropertyNamesForPage(const std::string &pageName) const
Gets the names of the properties on a certain page (one that was returned by GetPages()).
SDR_API SdrShaderPropertyConstPtr GetShaderOutput(const TfToken &outputName) const
Get a shader output property by name.
SDR_API VtValue GetDataForKey(const TfToken &key) const
Gets an item of data from this shader node according to the requested key.
SDR_API std::string GetHelp() const
The help message assigned to this node, if any.
SDR_API const SdrTokenVec & GetPages() const
Gets the pages on which the node's properties reside (an aggregate of the unique SdrShaderProperty::G...
const TfToken & GetContext() const
Gets the context of the shader node.
SDR_API const SdrTokenVec & GetDepartments() const
The departments this node is associated with, if any.
SDR_API std::string GetImplementationName() const
Returns the implementation name of this node.
const std::string & GetResolvedImplementationURI() const
Gets the URI to the resource that provides this node's implementation.
SDR_API const SdrTokenVec & GetShaderInputNames() const
Get an ordered list of all the input names on this shader node.
SdrVersion GetShaderVersion() const
Return the version of the node.
SDR_API const SdrTokenMap & GetPagesShownIf() const
Gets the shownIf expressions associated with each page.
SDR_API const SdrTokenVec & GetOpenPages() const
Gets the pages which should be opened or expanded by default.
const std::string & GetSourceCode() const
Returns the source code for this node.
SDR_API SdrShaderPropertyConstPtr GetDefaultInput() const
Returns the first shader input that is tagged as the default input.
const TfToken & GetSourceType() const
Gets the type of source that this shader node originated from.
SDR_API bool IsValid() const
Whether or not this node is valid.
SDR_API std::string GetRole() const
Returns the role of this node.
SDR_API const SdrTokenVec & GetShaderOutputNames() const
Get an ordered list of all the output names on this shader node.
SDR_API std::string GetInfoString() const
Gets a string with basic information about this node.
const std::string & GetResolvedDefinitionURI() const
Gets the URI to the resource that provided this node's definition.
Token for efficient comparison, assignment, and hashing of known strings.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
#define SDR_NODE_METADATA_PREFIX_TOKENS
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Functor to use for hash maps from tokens to other things.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...