HDK
|
#include <ShaderGraph.h>
Public Member Functions | |
ShaderGraph (const ShaderGraph *parent, const string &name, ConstDocumentPtr document, const StringSet &reservedWords) | |
Constructor. More... | |
virtual | ~ShaderGraph () |
Desctructor. More... | |
bool | isAGraph () const override |
Return true if this node is a graph. More... | |
ShaderNode * | getNode (const string &name) |
Get an internal node by name. More... | |
const ShaderNode * | getNode (const string &name) const |
Get an internal node by name. 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, ShaderNodePtr 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... | |
ShaderGraphInputSocket * | addInputSocket (const string &name, const TypeDesc *type) |
Add input/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... | |
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 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, const TypeDesc *type) |
Add inputs/outputs. More... | |
ShaderOutput * | addOutput (const string &name, const 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. 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) |
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 | optimize (GenContext &context) |
Optimize the graph, removing redundant paths. More... | |
void | bypass (GenContext &context, ShaderNode *node, size_t inputIndex, size_t outputIndex=0) |
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::unordered_map < ShaderInput *, ColorSpaceTransform > | _inputColorTransformMap |
std::unordered_map < ShaderInput *, UnitTransform > | _inputUnitTransformMap |
std::unordered_map < ShaderOutput *, ColorSpaceTransform > | _outputColorTransformMap |
std::unordered_map < ShaderOutput *, UnitTransform > | _outputUnitTransformMap |
Protected Attributes inherited from ShaderNode | |
const ShaderGraph * | _parent |
string | _name |
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 | SCATTER_MODE |
static const string | BSDF_R |
static const string | BSDF_T |
static const string | TRANSFORM_POINT |
static const string | TRANSFORM_VECTOR |
static const string | TRANSFORM_NORMAL |
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 43 of file ShaderGraph.h.
ShaderGraph::ShaderGraph | ( | const ShaderGraph * | parent, |
const string & | name, | ||
ConstDocumentPtr | document, | ||
const StringSet & | reservedWords | ||
) |
Constructor.
|
inlinevirtual |
Desctructor.
Definition at line 50 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, |
const TypeDesc * | type | ||
) |
Add input/output sockets.
|
protected |
Add input sockets from an interface element (nodedef, nodegraph or node)
|
protected |
Add a node to the graph.
ShaderGraphOutputSocket* ShaderGraph::addOutputSocket | ( | const string & | name, |
const TypeDesc * | type | ||
) |
|
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, |
ShaderNodePtr | shaderNode, | ||
GenContext & | context | ||
) |
Apply color and unit transforms to each input of a node.
|
protected |
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.
|
protected |
Break all connections on a node.
|
protected |
Perform all post-build operations on the graph.
|
inline |
Return the map of unique identifiers used in the scope of this graph.
Definition at line 115 of file ShaderGraph.h.
|
inline |
Get socket by index.
Definition at line 80 of file ShaderGraph.h.
|
inline |
Definition at line 82 of file ShaderGraph.h.
|
inline |
Get socket by name.
Definition at line 86 of file ShaderGraph.h.
|
inline |
Definition at line 88 of file ShaderGraph.h.
|
inline |
Get vector of sockets.
Definition at line 92 of file ShaderGraph.h.
ShaderNode* ShaderGraph::getNode | ( | const string & | name | ) |
Get an internal node by name.
const ShaderNode* ShaderGraph::getNode | ( | const string & | name | ) | const |
Get an internal node by name.
|
inline |
Get a vector of all nodes in order.
Definition at line 71 of file ShaderGraph.h.
|
inline |
Definition at line 81 of file ShaderGraph.h.
|
inline |
Definition at line 83 of file ShaderGraph.h.
|
inline |
Definition at line 87 of file ShaderGraph.h.
|
inline |
Definition at line 89 of file ShaderGraph.h.
|
inline |
Definition at line 93 of file ShaderGraph.h.
|
inlineoverridevirtual |
Return true if this node is a graph.
Reimplemented from ShaderNode.
Definition at line 62 of file ShaderGraph.h.
|
inline |
Get number of input sockets.
Definition at line 74 of file ShaderGraph.h.
|
inline |
Get number of output sockets.
Definition at line 77 of file ShaderGraph.h.
|
protected |
Optimize the graph, removing redundant paths.
|
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
|
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 182 of file ShaderGraph.h.
|
protected |
Definition at line 185 of file ShaderGraph.h.
|
protected |
Definition at line 188 of file ShaderGraph.h.
|
protected |
Definition at line 190 of file ShaderGraph.h.
|
protected |
Definition at line 183 of file ShaderGraph.h.
|
protected |
Definition at line 184 of file ShaderGraph.h.
|
protected |
Definition at line 193 of file ShaderGraph.h.
|
protected |
Definition at line 195 of file ShaderGraph.h.