6#ifndef MATERIALX_SHADERGRAPH_H
7#define MATERIALX_SHADERGRAPH_H
23MATERIALX_NAMESPACE_BEGIN
62 bool isAGraph()
const override {
return true; }
68 const ShaderNode* getNode(
const string& name)
const;
71 const vector<ShaderNode*>&
getNodes()
const {
return _nodeOrder; }
92 const vector<ShaderGraphInputSocket*>&
getInputSockets()
const {
return _outputOrder; }
93 const vector<ShaderGraphOutputSocket*>& getOutputSockets()
const {
return _inputOrder; }
109 void topologicalSort();
123 void createConnectedNodes(
const ElementPtr& downstreamElement,
173 const string& sourceColorSpace,
const string& targetColorSpace,
bool asInput);
183 std::unordered_map<string, ShaderNodePtr> _nodeMap;
184 std::vector<ShaderNode*> _nodeOrder;
188 std::unordered_map<ShaderInput*, ColorSpaceTransform> _inputColorTransformMap;
190 std::unordered_map<ShaderInput*, UnitTransform> _inputUnitTransformMap;
193 std::unordered_map<ShaderOutput*, ColorSpaceTransform> _outputColorTransformMap;
195 std::unordered_map<ShaderOutput*, UnitTransform> _outputUnitTransformMap;
222 return _upstream == rhs._upstream &&
223 _downstream == rhs._downstream &&
224 _stack == rhs._stack;
228 return !(*
this == rhs);
256 using StackFrame = std::pair<ShaderOutput*, size_t>;
257 std::vector<StackFrame> _stack;
258 std::set<ShaderOutput*> _path;
261MATERIALX_NAMESPACE_END
Color management system classes.
shared_ptr< class ColorManagementSystem > ColorManagementSystemPtr
A shared pointer to a ColorManagementSystem.
Definition: ColorManagementSystem.h:25
The top-level Document class.
shared_ptr< const Document > ConstDocumentPtr
A shared pointer to a const Document.
Definition: Document.h:24
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:61
Macros for declaring imported and exported symbols.
shared_ptr< const Node > ConstNodePtr
A shared pointer to a const Node.
Definition: Node.h:26
shared_ptr< class ShaderGraph > ShaderGraphPtr
A shared pointer to a shader graph.
Definition: ShaderGraph.h:39
Classes for nodes created during shader generation.
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
Definition: ShaderNode.h:35
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:26
The base class for MaterialX elements.
Definition: Element.h:80
A context class for shader generation.
Definition: GenContext.h:31
Class holding options to configure shader generation.
Definition: GenOptions.h:76
An element representing a declaration of geometric property data.
Definition: Geom.h:352
The base class for interface elements such as Node, NodeDef, and NodeGraph.
Definition: Interface.h:318
A node graph element within a Document.
Definition: Node.h:331
An edge returned during shader graph traversal.
Definition: ShaderGraph.h:201
Iterator class for traversing edges between nodes in a shader graph.
Definition: ShaderGraph.h:215
ShaderGraphEdge operator*() const
Dereference this iterator, returning the current output in the traversal.
Definition: ShaderGraph.h:232
ShaderGraphEdgeIterator & begin()
Return a reference to this iterator to begin traversal.
Definition: ShaderGraph.h:242
Class representing a graph (DAG) for shader generation.
Definition: ShaderGraph.h:44
virtual ~ShaderGraph()
Desctructor.
Definition: ShaderGraph.h:50
bool isAGraph() const override
Return true if this node is a graph.
Definition: ShaderGraph.h:62
size_t numInputSockets() const
Get number of input sockets.
Definition: ShaderGraph.h:74
const vector< ShaderGraphInputSocket * > & getInputSockets() const
Get vector of sockets.
Definition: ShaderGraph.h:92
ShaderGraphInputSocket * getInputSocket(size_t index)
Get socket by index.
Definition: ShaderGraph.h:80
IdentifierMap & getIdentifierMap()
Return the map of unique identifiers used in the scope of this graph.
Definition: ShaderGraph.h:115
size_t numOutputSockets() const
Get number of output sockets.
Definition: ShaderGraph.h:77
const vector< ShaderNode * > & getNodes() const
Get a vector of all nodes in order.
Definition: ShaderGraph.h:71
ShaderGraphInputSocket * getInputSocket(const string &name)
Get socket by name.
Definition: ShaderGraph.h:86
Class representing a node in the shader generation DAG.
Definition: ShaderNode.h:326
static ShaderNodePtr create(const ShaderGraph *parent, const string &name, const NodeDef &nodeDef, GenContext &context)
Create a new node from a nodedef.
Definition: ShaderNode.cpp:165
ShaderInput * getInput(size_t index)
Get inputs/outputs by index.
Definition: ShaderNode.h:454
size_t numInputs() const
Get number of inputs/outputs.
Definition: ShaderNode.h:450
An output on a ShaderNode.
Definition: ShaderNode.h:301
An input or output port on a ShaderNode.
Definition: ShaderNode.h:123
Base class for syntax objects used by shader generators to emit code with correct syntax for each lan...
Definition: Syntax.h:40
A type descriptor for MaterialX data types.
Definition: TypeDesc.h:28