8#ifndef PXR_USD_SDR_SHADER_NODE_H
9#define PXR_USD_SDR_SHADER_NODE_H
14#include "pxr/usd/sdr/api.h"
20#include <unordered_map>
22PXR_NAMESPACE_OPEN_SCOPE
27#define SDR_NODE_METADATA_TOKENS \
28 ((Category, "category")) \
30 ((Departments, "departments")) \
34 ((OpenPages, "openPages")) \
35 ((Primvars, "primvars")) \
36 ((ImplementationName, "__SDR__implementationName"))\
37 ((Target, "__SDR__target")) \
38 ((SdrUsdEncodingVersion, "sdrUsdEncodingVersion")) \
39 ((SdrDefinitionNameFallbackPrefix, "sdrDefinitionNameFallbackPrefix"))
46#define SDR_NODE_CONTEXT_TOKENS \
47 ((Pattern, "pattern")) \
48 ((Surface, "surface")) \
49 ((Volume, "volume")) \
50 ((Displacement, "displacement")) \
52 ((DisplayFilter, "displayFilter")) \
53 ((LightFilter, "lightFilter")) \
54 ((PixelFilter, "pixelFilter")) \
55 ((SampleFilter, "sampleFilter"))
57#define SDR_NODE_ROLE_TOKENS \
58 ((Primvar, "primvar")) \
59 ((Texture, "texture")) \
80 const std::string& name,
84 const std::string& definitionURI,
85 const std::string& implementationURI,
86 SdrShaderPropertyUniquePtrVec&& properties,
87 const SdrTokenMap& metadata = SdrTokenMap(),
88 const std::string &sourceCode = std::string());
104 const std::string&
GetName()
const {
return _name; }
151 return _implementationURI;
267 const SdrTokenVec&
GetPages()
const {
return _pages; };
290 return _primvarNamingProperties;
323 using ComplianceResults = std::unordered_map<
TfToken,
324 std::vector<SdrIdentifier>,
340 const std::vector<SdrShaderNodeConstPtr> &shaderNodes);
348 void _PostProcessProperties();
362 std::string _definitionURI;
363 std::string _implementationURI;
364 SdrShaderPropertyUniquePtrVec _properties;
365 SdrTokenMap _metadata;
366 std::string _sourceCode;
368 SdrShaderPropertyMap _inputs;
369 SdrTokenVec _inputNames;
370 SdrShaderPropertyMap _outputs;
371 SdrTokenVec _outputNames;
377 SdrTokenVec _primvars;
378 SdrTokenVec _primvarNamingProperties;
383 SdrTokenVec _departments;
385 SdrTokenVec _openPages;
389 void _InitializePrimvars();
392 SdrTokenVec _ComputePages()
const;
395PXR_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 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 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.
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...