|
HDK
|
#include <ShaderGraph.h>
Inheritance diagram for ShaderGraph:Public Member Functions | |
| ShaderGraph (const ShaderGraph *parent, const string &name, ConstDocumentPtr document, GenContext &context) | |
| Constructor. More... | |
| virtual | ~ShaderGraph () |
| Destructor. More... | |
| bool | isAGraph () const override |
| Return true if this node is a graph. More... | |
| ShaderNode * | getNode (const string &uniqueId) |
| Get an internal node by its unique identifier. More... | |
| const ShaderNode * | getNode (const string &uniqueId) const |
| Get an internal node by its unique identifier. More... | |
| const vector< ShaderNode * > & | getNodes () const |
| Get a vector of all nodes in order. More... | |
| size_t | numInputSockets () const |
| Get number of input sockets. More... | |
| size_t | numOutputSockets () const |
| Get number of output sockets. More... | |
| ShaderGraphInputSocket * | getInputSocket (size_t index) |
| Get socket by index. More... | |
| ShaderGraphOutputSocket * | getOutputSocket (size_t index=0) |
| const ShaderGraphInputSocket * | getInputSocket (size_t index) const |
| const ShaderGraphOutputSocket * | getOutputSocket (size_t index=0) const |
| ShaderGraphInputSocket * | getInputSocket (const string &name) |
| Get socket by name. More... | |
| ShaderGraphOutputSocket * | getOutputSocket (const string &name) |
| const ShaderGraphInputSocket * | getInputSocket (const string &name) const |
| const ShaderGraphOutputSocket * | getOutputSocket (const string &name) const |
| const vector < ShaderGraphInputSocket * > & | getInputSockets () const |
| Get vector of sockets. More... | |
| const vector < ShaderGraphOutputSocket * > & | getOutputSockets () const |
| void | applyInputTransforms (ConstNodePtr node, ShaderNode *shaderNode, GenContext &context) |
| Apply color and unit transforms to each input of a node. More... | |
| ShaderNode * | createNode (ConstNodePtr node, GenContext &context) |
| Create a new node in the graph. More... | |
| ShaderNode * | inlineNodeBeforeOutput (ShaderGraphOutputSocket *output, const std::string &newNodeName, const std::string &nodeDefName, const std::string &inputName, const std::string &outputName, GenContext &context) |
| ShaderGraphInputSocket * | addInputSocket (const string &name, TypeDesc type) |
| Add input sockets. More... | |
| ShaderGraphInputSocket * | addInputSocket (const string &name, const TypeDesc *type) |
| ShaderGraphOutputSocket * | addOutputSocket (const string &name, TypeDesc type) |
| Add output sockets. More... | |
| ShaderGraphOutputSocket * | addOutputSocket (const string &name, const TypeDesc *type) |
| void | addDefaultGeomNode (ShaderInput *input, const GeomPropDef &geomprop, GenContext &context) |
| Add a default geometric node and connect to the given input. More... | |
| void | topologicalSort () |
| Sort the nodes in topological order. More... | |
| IdentifierMap & | getIdentifierMap () |
| Return the map of unique identifiers used in the scope of this graph. More... | |
| ConstDocumentPtr | getDocument () const |
| Return the document associated with this graph. More... | |
| ShaderNode * | createNode (const string &name, const string &uniqueId, ConstNodeDefPtr nodeDef, GenContext &context) |
| Create a new node in the graph from a node definition. More... | |
| void | bypass (ShaderNode *node, size_t inputIndex, size_t outputIndex=0) |
| void | removeUnusedNodes () |
| Remove nodes that are no longer connected to any output. More... | |
| void | replaceOutput (ShaderOutput *oldOutput, ShaderOutput *newOutput) |
| Rewire all downstream connections from one output to another. More... | |
Public Member Functions inherited from ShaderNode | |
| virtual | ~ShaderNode () |
| ShaderNode (const ShaderGraph *parent, const string &name) | |
| Constructor. More... | |
| const ShaderGraph * | getParent () const |
| void | setClassification (uint32_t c) |
| uint32_t | getClassification () const |
| Get classification bits set for this node. More... | |
| void | addClassification (uint32_t c) |
| Add classification bits to this node. More... | |
| bool | hasClassification (uint32_t c) const |
| Return true if this node matches the given classification. More... | |
| const string & | getName () const |
| Return the name of this node. More... | |
| const string & | getUniqueId () const |
| const ShaderNodeImpl & | getImplementation () const |
| Return the implementation used for this node. More... | |
| void | initialize (const Node &node, const NodeDef &nodeDef, GenContext &context) |
| ShaderInput * | addInput (const string &name, TypeDesc type) |
| Add inputs/outputs. More... | |
| ShaderOutput * | addOutput (const string &name, TypeDesc type) |
| size_t | numInputs () const |
| Get number of inputs/outputs. More... | |
| size_t | numOutputs () const |
| ShaderInput * | getInput (size_t index) |
| Get inputs/outputs by index. More... | |
| ShaderOutput * | getOutput (size_t index=0) |
| const ShaderInput * | getInput (size_t index) const |
| const ShaderOutput * | getOutput (size_t index=0) const |
| ShaderInput * | getInput (const string &name) |
| Get inputs/outputs by name. More... | |
| ShaderOutput * | getOutput (const string &name) |
| const ShaderInput * | getInput (const string &name) const |
| const ShaderOutput * | getOutput (const string &name) const |
| const vector< ShaderInput * > & | getInputs () const |
| Get vector of inputs/outputs. More... | |
| const vector< ShaderOutput * > & | getOutputs () const |
| void | setMetadata (ShaderMetadataVecPtr metadata) |
| Set the metadata vector. More... | |
| ShaderMetadataVecPtr | getMetadata () |
| Get the metadata vector. More... | |
| const ShaderMetadataVecPtr & | getMetadata () const |
| Get the metadata vector. More... | |
| bool | isEditable (const ShaderInput &input) const |
| bool | isEditable (const ShaderGraphInputSocket &input) const |
Static Public Member Functions | |
| static ShaderGraphPtr | create (const ShaderGraph *parent, const string &name, ElementPtr element, GenContext &context) |
| static ShaderGraphPtr | create (const ShaderGraph *parent, const NodeGraph &nodeGraph, GenContext &context) |
| Create a new shader graph from a nodegraph. More... | |
| static ShaderGraphEdgeIterator | traverseUpstream (ShaderOutput *output) |
| Return an iterator for traversal upstream from the given output. More... | |
Static Public Member Functions inherited from ShaderNode | |
| static ShaderNodePtr | create (const ShaderGraph *parent, const string &name, const NodeDef &nodeDef, GenContext &context) |
| Create a new node from a nodedef. More... | |
| static ShaderNodePtr | create (const ShaderGraph *parent, const string &name, ShaderNodeImplPtr impl, unsigned int classification=Classification::TEXTURE) |
| Create a new node from a node implementation. More... | |
Protected Member Functions | |
| void | createConnectedNodes (const ElementPtr &downstreamElement, const ElementPtr &upstreamElement, ElementPtr connectingElement, GenContext &context) |
| void | addNode (ShaderNodePtr node) |
| Add a node to the graph, keyed by the node's unique identifier. More... | |
| void | addInputSockets (const InterfaceElement &elem, GenContext &context) |
| Add input sockets from an interface element (nodedef, nodegraph or node) More... | |
| void | addOutputSockets (const InterfaceElement &elem, GenContext &context) |
| Add output sockets from an interface element (nodedef, nodegraph or node) More... | |
| void | addUpstreamDependencies (const Element &root, GenContext &context) |
| void | addColorTransformNode (ShaderInput *input, const ColorSpaceTransform &transform, GenContext &context) |
| Add a color transform node and connect to the given input. More... | |
| void | addColorTransformNode (ShaderOutput *output, const ColorSpaceTransform &transform, GenContext &context) |
| Add a color transform node and connect to the given output. More... | |
| void | addUnitTransformNode (ShaderInput *input, const UnitTransform &transform, GenContext &context) |
| Add a unit transform node and connect to the given input. More... | |
| void | addUnitTransformNode (ShaderOutput *output, const UnitTransform &transform, GenContext &context) |
| Add a unit transform node and connect to the given output. More... | |
| void | finalize (GenContext &context) |
| Perform all post-build operations on the graph. More... | |
| void | setVariableNames (GenContext &context) |
| void | populateColorTransformMap (ColorManagementSystemPtr colorManagementSystem, ShaderPort *shaderPort, const string &sourceColorSpace, const string &targetColorSpace, bool asInput) |
| void | populateUnitTransformMap (UnitSystemPtr unitSystem, ShaderPort *shaderPort, ValueElementPtr element, const string &targetUnitSpace, bool asInput) |
| void | disconnect (ShaderNode *node) const |
| Break all connections on a node. More... | |
Protected Member Functions inherited from ShaderNode | |
| void | createMetadata (const NodeDef &nodeDef, GenContext &context) |
| Create metadata from the nodedef according to registered metadata. More... | |
Protected Attributes | |
| ConstDocumentPtr | _document |
| std::unordered_map< string, ShaderNodePtr > | _nodeMap |
| std::vector< ShaderNode * > | _nodeOrder |
| IdentifierMap | _identifiers |
| std::vector< std::pair < ShaderInput *, ColorSpaceTransform > > | _inputColorTransformMap |
| std::vector< std::pair < ShaderInput *, UnitTransform > > | _inputUnitTransformMap |
| std::vector< std::pair < ShaderOutput *, ColorSpaceTransform > > | _outputColorTransformMap |
| std::vector< std::pair < ShaderOutput *, UnitTransform > > | _outputUnitTransformMap |
Protected Attributes inherited from ShaderNode | |
| const ShaderGraph * | _parent |
| string | _name |
| string | _uniqueId |
| uint32_t | _classification |
| std::unordered_map< string, ShaderInputPtr > | _inputMap |
| vector< ShaderInput * > | _inputOrder |
| std::unordered_map< string, ShaderOutputPtr > | _outputMap |
| vector< ShaderOutput * > | _outputOrder |
| ShaderNodeImplPtr | _impl |
| ShaderMetadataVecPtr | _metadata |
Additional Inherited Members | |
Static Public Attributes inherited from ShaderNode | |
| static const ShaderNodePtr | NONE |
| static const string | CONSTANT |
| static const string | DOT |
| static const string | IMAGE |
| static const string | SURFACESHADER |
| static const string | BACKSURFACESHADER |
| static const string | BSDF_R |
| static const string | BSDF_T |
| static const string | TEXTURE2D_GROUPNAME |
| static const string | TEXTURE3D_GROUPNAME |
| static const string | PROCEDURAL2D_GROUPNAME |
| static const string | PROCEDURAL3D_GROUPNAME |
| static const string | GEOMETRIC_GROUPNAME |
Class representing a graph (DAG) for shader generation
Definition at line 44 of file ShaderGraph.h.
| ShaderGraph::ShaderGraph | ( | const ShaderGraph * | parent, |
| const string & | name, | ||
| ConstDocumentPtr | document, | ||
| GenContext & | context | ||
| ) |
Constructor.
|
inlinevirtual |
Destructor.
Definition at line 52 of file ShaderGraph.h.
|
protected |
Add a color transform node and connect to the given input.
|
protected |
Add a color transform node and connect to the given output.
| void ShaderGraph::addDefaultGeomNode | ( | ShaderInput * | input, |
| const GeomPropDef & | geomprop, | ||
| GenContext & | context | ||
| ) |
Add a default geometric node and connect to the given input.
| ShaderGraphInputSocket* ShaderGraph::addInputSocket | ( | const string & | name, |
| TypeDesc | type | ||
| ) |
Add input sockets.
|
inline |
Definition at line 112 of file ShaderGraph.h.
|
protected |
Add input sockets from an interface element (nodedef, nodegraph or node)
|
protected |
Add a node to the graph, keyed by the node's unique identifier.
| ShaderGraphOutputSocket* ShaderGraph::addOutputSocket | ( | const string & | name, |
| TypeDesc | type | ||
| ) |
Add output sockets.
|
inline |
Definition at line 116 of file ShaderGraph.h.
|
protected |
Add output sockets from an interface element (nodedef, nodegraph or node)
|
protected |
Add a unit transform node and connect to the given input.
|
protected |
Add a unit transform node and connect to the given output.
|
protected |
Traverse from the given root element and add all dependencies upstream. The traversal is done in the context of a material, if given, to include bind input elements in the traversal.
| void ShaderGraph::applyInputTransforms | ( | ConstNodePtr | node, |
| ShaderNode * | shaderNode, | ||
| GenContext & | context | ||
| ) |
Apply color and unit transforms to each input of a node.
| void ShaderGraph::bypass | ( | ShaderNode * | node, |
| size_t | inputIndex, | ||
| size_t | outputIndex = 0 |
||
| ) |
Bypass a node for a particular input and output, effectively connecting the input's upstream connection with the output's downstream connections.
|
static |
Create a new shader graph from an element. Supported elements are outputs and shader nodes.
|
static |
Create a new shader graph from a nodegraph.
|
protected |
Create node connections corresponding to the connection between a pair of elements.
| ShaderNode* ShaderGraph::createNode | ( | ConstNodePtr | node, |
| GenContext & | context | ||
| ) |
Create a new node in the graph.
| ShaderNode* ShaderGraph::createNode | ( | const string & | name, |
| const string & | uniqueId, | ||
| ConstNodeDefPtr | nodeDef, | ||
| GenContext & | context | ||
| ) |
Create a new node in the graph from a node definition.
|
protected |
Break all connections on a node.
|
protected |
Perform all post-build operations on the graph.
|
inline |
Return the document associated with this graph.
Definition at line 131 of file ShaderGraph.h.
|
inline |
Return the map of unique identifiers used in the scope of this graph.
Definition at line 128 of file ShaderGraph.h.
|
inline |
Get socket by index.
Definition at line 82 of file ShaderGraph.h.
|
inline |
Definition at line 84 of file ShaderGraph.h.
|
inline |
Get socket by name.
Definition at line 88 of file ShaderGraph.h.
|
inline |
Definition at line 90 of file ShaderGraph.h.
|
inline |
Get vector of sockets.
Definition at line 94 of file ShaderGraph.h.
| ShaderNode* ShaderGraph::getNode | ( | const string & | uniqueId | ) |
Get an internal node by its unique identifier.
| const ShaderNode* ShaderGraph::getNode | ( | const string & | uniqueId | ) | const |
Get an internal node by its unique identifier.
|
inline |
Get a vector of all nodes in order.
Definition at line 73 of file ShaderGraph.h.
|
inline |
Definition at line 83 of file ShaderGraph.h.
|
inline |
Definition at line 85 of file ShaderGraph.h.
|
inline |
Definition at line 89 of file ShaderGraph.h.
|
inline |
Definition at line 91 of file ShaderGraph.h.
|
inline |
Definition at line 95 of file ShaderGraph.h.
| ShaderNode* ShaderGraph::inlineNodeBeforeOutput | ( | ShaderGraphOutputSocket * | output, |
| const std::string & | newNodeName, | ||
| const std::string & | nodeDefName, | ||
| const std::string & | inputName, | ||
| const std::string & | outputName, | ||
| GenContext & | context | ||
| ) |
|
inlineoverridevirtual |
Return true if this node is a graph.
Reimplemented from ShaderNode.
Definition at line 64 of file ShaderGraph.h.
|
inline |
Get number of input sockets.
Definition at line 76 of file ShaderGraph.h.
|
inline |
Get number of output sockets.
Definition at line 79 of file ShaderGraph.h.
|
protected |
Populate the color transform map for the given shader port, if the provided combination of source and target color spaces are supported for its data type.
|
protected |
Populates the appropriate unit transform map if the provided input/parameter or output has a unit attribute and is of the supported type
| void ShaderGraph::removeUnusedNodes | ( | ) |
Remove nodes that are no longer connected to any output.
| void ShaderGraph::replaceOutput | ( | ShaderOutput * | oldOutput, |
| ShaderOutput * | newOutput | ||
| ) |
Rewire all downstream connections from one output to another.
|
protected |
For inputs and outputs in the graph set the variable names to be used in generated code. Making sure variable names are valid and unique to avoid name conflicts during shader generation.
| void ShaderGraph::topologicalSort | ( | ) |
Sort the nodes in topological order.
|
static |
Return an iterator for traversal upstream from the given output.
|
protected |
Definition at line 204 of file ShaderGraph.h.
|
protected |
Definition at line 207 of file ShaderGraph.h.
|
protected |
Definition at line 210 of file ShaderGraph.h.
|
protected |
Definition at line 212 of file ShaderGraph.h.
|
protected |
Definition at line 205 of file ShaderGraph.h.
|
protected |
Definition at line 206 of file ShaderGraph.h.
|
protected |
Definition at line 215 of file ShaderGraph.h.
|
protected |
Definition at line 217 of file ShaderGraph.h.