8#ifndef PXR_USD_SDR_SHADER_NODE_H
9#define PXR_USD_SDR_SHADER_NODE_H
19#include "pxr/usd/sdr/api.h"
26#include <unordered_map>
28PXR_NAMESPACE_OPEN_SCOPE
33#define SDR_NODE_METADATA_TOKENS \
34 ((Category, "category")) \
36 ((Departments, "departments")) \
40 ((Primvars, "primvars")) \
41 ((ImplementationName, "__SDR__implementationName"))\
42 ((Target, "__SDR__target")) \
43 ((SdrUsdEncodingVersion, "sdrUsdEncodingVersion")) \
44 ((SdrDefinitionNameFallbackPrefix, "sdrDefinitionNameFallbackPrefix"))
51#define SDR_NODE_CONTEXT_TOKENS \
52 ((Pattern, "pattern")) \
53 ((Surface, "surface")) \
54 ((Volume, "volume")) \
55 ((Displacement, "displacement")) \
57 ((DisplayFilter, "displayFilter")) \
58 ((LightFilter, "lightFilter")) \
59 ((PixelFilter, "pixelFilter")) \
60 ((SampleFilter, "sampleFilter"))
62#define SDR_NODE_ROLE_TOKENS \
63 ((Primvar, "primvar")) \
64 ((Texture, "texture")) \
89 const std::string& name,
93 const std::string& definitionURI,
94 const std::string& implementationURI,
95 NdrPropertyUniquePtrVec&& properties,
96 const NdrTokenMap& metadata = NdrTokenMap(),
97 const std::string &sourceCode = std::string());
104 const std::string& name,
108 const std::string& definitionURI,
109 const std::string& implementationURI,
110 SdrShaderPropertyUniquePtrVec&& properties,
111 const SdrTokenMap& metadata = SdrTokenMap(),
112 const std::string &sourceCode = std::string());
195 const SdrTokenVec&
GetPages()
const {
return _pages; };
214 return _primvarNamingProperties;
247 using ComplianceResults = std::unordered_map<
TfToken,
248 std::vector<SdrIdentifier>,
264 const std::vector<SdrShaderNodeConstPtr> &shaderNodes);
272 void _PostProcessProperties();
281 SdrTokenVec _primvars;
282 SdrTokenVec _primvarNamingProperties;
287 SdrTokenVec _departments;
290 SdrPropertyMap _shaderInputs;
291 SdrPropertyMap _shaderOutputs;
295 void _InitializePrimvars();
298 SdrTokenVec _ComputePages()
const;
301PXR_NAMESPACE_CLOSE_SCOPE
Represents an abstract node.
Represents a node that holds shading information.
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.
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...
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.
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.
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 SdrShaderNode(const NdrIdentifier &identifier, const NdrVersion &version, const std::string &name, const TfToken &family, const TfToken &context, const TfToken &sourceType, const std::string &definitionURI, const std::string &implementationURI, NdrPropertyUniquePtrVec &&properties, const NdrTokenMap &metadata=NdrTokenMap(), const std::string &sourceCode=std::string())
Constructor.
SDR_API SdrShaderPropertyConstPtr GetShaderOutput(const TfToken &outputName) const
Get a shader output property by name.
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...
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.
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 SdrShaderPropertyConstPtr GetDefaultInput() const
Returns the first shader input that is tagged as the default input.
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.
Token for efficient comparison, assignment, and hashing of known strings.
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...
SDR_API SdrVersion NdrToSdrVersion(NdrVersion version)
Helper function to translate NdrVersion to SdrVersion.