6#ifndef MATERIALX_SHADERGRAPH_H
7#define MATERIALX_SHADERGRAPH_H
28class ShaderGraphEdgeIterator;
63 bool isAGraph()
const override {
return true; }
69 const ShaderNode* getNode(
const string& name)
const;
72 const vector<ShaderNode*>&
getNodes()
const {
return _nodeOrder; }
83 const ShaderGraphInputSocket* getInputSocket(
size_t index)
const {
return getOutput(index); }
89 const ShaderGraphInputSocket* getInputSocket(
const string& name)
const {
return getOutput(name); }
93 const vector<ShaderGraphInputSocket*>&
getInputSockets()
const {
return _outputOrder; }
94 const vector<ShaderGraphOutputSocket*>& getOutputSockets()
const {
return _inputOrder; }
97 ShaderNode* createNode(
const Node& node, GenContext& context);
100 ShaderGraphInputSocket* addInputSocket(
const string& name,
const TypeDesc* type);
101 ShaderGraphOutputSocket* addOutputSocket(
const string& name,
const TypeDesc* type);
104 static ShaderGraphEdgeIterator traverseUpstream(ShaderOutput* output);
122 void createConnectedNodes(
const ElementPtr& downstreamElement,
169 void topologicalSort();
172 void calculateScopes();
191 std::unordered_map<string, ShaderNodePtr> _nodeMap;
192 std::vector<ShaderNode*> _nodeOrder;
196 std::unordered_map<ShaderInput*, ColorSpaceTransform> _inputColorTransformMap;
198 std::unordered_map<ShaderInput*, UnitTransform> _inputUnitTransformMap;
201 std::unordered_map<ShaderOutput*, ColorSpaceTransform> _outputColorTransformMap;
203 std::unordered_map<ShaderOutput*, UnitTransform> _outputUnitTransformMap;
229 return _upstream == rhs._upstream &&
230 _downstream == rhs._downstream &&
231 _stack == rhs._stack;
235 return !(*
this == rhs);
263 using StackFrame = std::pair<ShaderOutput*, size_t>;
264 std::vector<StackFrame> _stack;
265 std::set<ShaderOutput*> _path;
Color management system classes.
shared_ptr< class ColorManagementSystem > ColorManagementSystemPtr
A shared pointer to a ColorManagementSystem.
Definition: ColorManagementSystem.h:26
The top-level Document class.
shared_ptr< const Document > ConstDocumentPtr
A shared pointer to a const Document.
Definition: Document.h:25
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition: Element.h:31
shared_ptr< ValueElement > ValueElementPtr
A shared pointer to a ValueElement.
Definition: Element.h:41
std::set< string > StringSet
A set of strings.
Definition: Library.h:60
Macros for declaring imported and exported symbols.
shared_ptr< Node > NodePtr
A shared pointer to a Node.
Definition: Node.h:25
ShaderInput ShaderGraphOutputSocket
An internal output socket in a shader graph, used for connecting internal nodes to the outside.
Definition: ShaderGraph.h:37
shared_ptr< class ShaderGraph > ShaderGraphPtr
A shared pointer to a shader graph.
Definition: ShaderGraph.h:40
Classes for nodes created during shader generation.
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
Definition: ShaderNode.h:36
Base class for syntax handling for shader generators.
std::unordered_map< string, size_t > IdentifierMap
Map holding identifier names and a counter for creating unique names from them.
Definition: Syntax.h:34
Type descriptor for a MaterialX data type.
shared_ptr< class UnitSystem > UnitSystemPtr
A shared pointer to a UnitSystem.
Definition: UnitSystem.h:27
The base class for MaterialX elements.
Definition: Element.h:75
A context class for shader generation.
Definition: GenContext.h:27
An element representing a declaration of geometric property data.
Definition: Geom.h:361
The base class for interface elements such as Node, NodeDef, and NodeGraph.
Definition: Interface.h:317
A node graph element within a Document.
Definition: Node.h:316
An edge returned during shader graph traversal.
Definition: ShaderGraph.h:209
Iterator class for traversing edges between nodes in a shader graph.
Definition: ShaderGraph.h:222
ShaderGraphEdge operator*() const
Dereference this iterator, returning the current output in the traversal.
Definition: ShaderGraph.h:239
ShaderGraphEdgeIterator & begin()
Return a reference to this iterator to begin traversal.
Definition: ShaderGraph.h:249
Class representing a graph (DAG) for shader generation.
Definition: ShaderGraph.h:45
virtual ~ShaderGraph()
Desctructor.
Definition: ShaderGraph.h:51
bool isAGraph() const override
Return true if this node is a graph.
Definition: ShaderGraph.h:63
size_t numInputSockets() const
Get number of input sockets.
Definition: ShaderGraph.h:75
const vector< ShaderGraphInputSocket * > & getInputSockets() const
Get vector of sockets.
Definition: ShaderGraph.h:93
ShaderGraphInputSocket * getInputSocket(size_t index)
Get socket by index.
Definition: ShaderGraph.h:81
IdentifierMap & getIdentifierMap()
Return the map of unique identifiers used in the scope of this graph.
Definition: ShaderGraph.h:107
size_t numOutputSockets() const
Get number of output sockets.
Definition: ShaderGraph.h:78
const vector< ShaderNode * > & getNodes() const
Get a vector of all nodes in order.
Definition: ShaderGraph.h:72
ShaderGraphInputSocket * getInputSocket(const string &name)
Get socket by name.
Definition: ShaderGraph.h:87
Class representing a node in the shader generation DAG.
Definition: ShaderNode.h:326
An output on a ShaderNode.
Definition: ShaderNode.h:289
An input or output port on a ShaderNode.
Definition: ShaderNode.h:125