MaterialX 1.38.2
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
ShaderNode Class Reference

Class representing a node in the shader generation DAG. More...

#include <ShaderNode.h>

Inheritance diagram for ShaderNode:
ShaderGraph

Classes

class  Classification
 Flags for classifying nodes into different categories. More...
 
struct  ScopeInfo
 Information on source code scope for the node. More...
 

Public Member Functions

 ShaderNode (const ShaderGraph *parent, const string &name)
 Constructor.
 
virtual bool isAGraph () const
 Return true if this node is a graph. More...
 
const ShaderGraph * getParent () const
 Return the parent graph that owns this node. More...
 
bool hasClassification (uint32_t c) const
 Return true if this node matches the given classification.
 
const string & getName () const
 Return the name of this node.
 
const ShaderNodeImpl & getImplementation () const
 Return the implementation used for this node.
 
ScopeInfo & getScopeInfo ()
 Return the scope info for this node.
 
const ScopeInfo & getScopeInfo () const
 Return the scope info for this node.
 
bool referencedConditionally () const
 Returns true if this node is only referenced by a conditional.
 
bool isUsedClosure (const ShaderNode *node) const
 Returns true if the given node is a closure used by this node.
 
void initialize (const Node &node, const NodeDef &nodeDef, GenContext &context)
 Initialize this shader node with all required data from the given node and nodedef.
 
ShaderInput * addInput (const string &name, const TypeDesc *type)
 Add inputs/outputs.
 
ShaderOutput * addOutput (const string &name, const TypeDesc *type)
 
size_t numInputs () const
 Get number of inputs/outputs.
 
size_t numOutputs () const
 
ShaderInput * getInput (size_t index)
 Get inputs/outputs by index.
 
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.
 
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.
 
const vector< ShaderOutput * > & getOutputs () const
 
void setMetadata (ShaderMetadataVecPtr metadata)
 Set the metadata vector.
 
ShaderMetadataVecPtr getMetadata ()
 Get the metadata vector.
 
const ShaderMetadataVecPtr & getMetadata () const
 Get the metadata vector.
 
bool isEditable (const ShaderInput &input) const
 Returns true if an input is editable by users. More...
 
bool isEditable (const ShaderGraphInputSocket &input) const
 Returns true if a graph input is accessible by users. More...
 
void setFlag (ShaderNodeFlag flag, bool value)
 Set the on|off state of a given flag.
 
bool getFlag (ShaderNodeFlag flag) const
 Return the on|off state of a given flag.
 

Static Public Member Functions

static ShaderNodePtr create (const ShaderGraph *parent, const string &name, const NodeDef &nodeDef, GenContext &context)
 Create a new node from a nodedef.
 
static ShaderNodePtr create (const ShaderGraph *parent, const string &name, ShaderNodeImplPtr impl, unsigned int classification=Classification::TEXTURE)
 Create a new node from a node implementation.
 

Static Public Attributes

static const ShaderNodePtr NONE = createEmptyNode()
 
static const string CONSTANT = "constant"
 
static const string IMAGE = "image"
 
static const string COMPARE = "compare"
 
static const string SWITCH = "switch"
 
static const string SCATTER_MODE = "scatter_mode"
 
static const string BSDF_R = "R"
 
static const string BSDF_T = "T"
 
static const string TRANSFORM_POINT
 
static const string TRANSFORM_VECTOR
 
static const string TRANSFORM_NORMAL
 
static const string TEXTURE2D_GROUPNAME = "texture2d"
 
static const string TEXTURE3D_GROUPNAME = "texture3d"
 
static const string PROCEDURAL2D_GROUPNAME = "procedural2d"
 
static const string PROCEDURAL3D_GROUPNAME = "procedural3d"
 

Protected Member Functions

void createMetadata (const NodeDef &nodeDef, GenContext &context)
 Create metadata from the nodedef according to registered metadata.
 

Protected Attributes

const ShaderGraph * _parent
 
string _name
 
uint32_t _classification
 
uint32_t _flags
 
std::unordered_map< string, ShaderInputPtr > _inputMap
 
vector< ShaderInput * > _inputOrder
 
std::unordered_map< string, ShaderOutputPtr > _outputMap
 
vector< ShaderOutput * > _outputOrder
 
ShaderNodeImplPtr _impl
 
ShaderMetadataVecPtr _metadata
 
ScopeInfo _scopeInfo
 
std::set< const ShaderNode * > _usedClosures
 

Friends

class ShaderGraph
 

Detailed Description

Class representing a node in the shader generation DAG.

Member Function Documentation

◆ getParent()

const ShaderGraph * getParent ( ) const
inline

Return the parent graph that owns this node.

If this node is a root graph it has no parent and nullptr will be returned.

◆ isAGraph()

virtual bool isAGraph ( ) const
inlinevirtual

Return true if this node is a graph.

Reimplemented in ShaderGraph.

◆ isEditable() [1/2]

bool isEditable ( const ShaderGraphInputSocket &  input) const
inline

Returns true if a graph input is accessible by users.

Editable inputs are allowed to be published as shader uniforms and hence must be presentable in a user interface.

◆ isEditable() [2/2]

bool isEditable ( const ShaderInput &  input) const
inline

Returns true if an input is editable by users.

Editable inputs are allowed to be published as shader uniforms and hence must be presentable in a user interface.


The documentation for this class was generated from the following files: