6 #ifndef MATERIALX_SHADERNODE_H
7 #define MATERIALX_SHADERNODE_H
68 if (_entryIndex.count(name) == 0)
70 _entryIndex[
name] = _entries.size();
71 _entries.emplace_back(name, type,
value);
79 auto it = _entryIndex.find(name);
80 return it != _entryIndex.end() ? &_entries[it->second] :
nullptr;
87 auto it = _entryIndex.find(name);
88 return it != _entryIndex.end() ? &_entries[it->second] :
nullptr;
116 static const uint32_t UNIFORM = 1u << 0;
117 static const uint32_t EMITTED = 1u << 1;
118 static const uint32_t BIND_INPUT = 1u << 2;
132 return shared_from_this();
151 const string&
getName()
const {
return _name; }
154 string getFullName()
const;
163 void setSemantic(
const string& semantic) { _semantic = semantic; }
184 const string&
getUnit()
const {
return _unit; }
188 void setGeomProp(
const string& geomprop) { _geomprop = geomprop; }
197 const string&
getPath()
const {
return _path; }
208 _flags = value ? (_flags | flag) : (_flags & ~flag);
214 return ((_flags & flag) != 0);
278 void breakConnection();
314 void breakConnections();
333 static const uint32_t TEXTURE = 1 << 0;
334 static const uint32_t CLOSURE = 1 << 1;
335 static const uint32_t SHADER = 1 << 2;
337 static const uint32_t FILETEXTURE = 1 << 3;
338 static const uint32_t CONDITIONAL = 1 << 4;
341 static const uint32_t
BSDF = 1 << 6;
342 static const uint32_t BSDF_R = 1 << 7;
343 static const uint32_t BSDF_T = 1 << 8;
344 static const uint32_t
EDF = 1 << 9;
345 static const uint32_t
VDF = 1 << 10;
346 static const uint32_t LAYER = 1 << 11;
347 static const uint32_t THINFILM = 1 << 12;
349 static const uint32_t SURFACE = 1 << 13;
350 static const uint32_t VOLUME = 1 << 14;
351 static const uint32_t LIGHT = 1 << 15;
352 static const uint32_t UNLIT = 1 << 16;
354 static const uint32_t IFELSE = 1 << 17;
355 static const uint32_t SWITCH = 1 << 18;
357 static const uint32_t SAMPLE2D = 1 << 19;
358 static const uint32_t SAMPLE3D = 1 << 20;
376 ScopeInfo() :
type(UNKNOWN), conditionalNode(nullptr), conditionBitmask(0), fullConditionMask(0) {}
379 void adjustAtConditionalInput(
ShaderNode* condNode,
int branch, uint32_t fullMask);
380 bool usedByBranch(
int branchIndex)
const {
return (conditionBitmask & (1 << branchIndex)) != 0; }
415 unsigned int classification = Classification::TEXTURE);
431 return (_classification & c) ==
c;
459 bool referencedConditionally()
const;
486 const vector<ShaderInput*>&
getInputs()
const {
return _inputOrder; }
487 const vector<ShaderOutput*>&
getOutputs()
const {
return _outputOrder; }
503 return (!_impl || _impl->isEditable(input));
511 return (!_impl || _impl->isEditable(input));
const ScopeInfo & getScopeInfo() const
Return the scope info for this node.
const ShaderGraph * _parent
Flags for classifying nodes into different categories.
shared_ptr< class ShaderInput > ShaderInputPtr
Shared pointer to a ShaderInput.
const string & getColorSpace() const
Return the source color space for the value on this port.
ShaderPortPtr getSelf()
Return a shared pointer instance of this object.
static const string TRANSFORM_POINT
const ShaderNodeImpl & getImplementation() const
Return the implementation used for this node.
const string & getName() const
Return the name of this port.
vector< ShaderInput * > _inputOrder
static const string TRANSFORM_NORMAL
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
bool usedByBranch(int branchIndex) const
void setColorSpace(const string &colorspace)
Set a source color space for the value on this port.
#define MATERIALX_NAMESPACE_BEGIN
std::unordered_map< string, ShaderInputPtr > _inputMap
ShaderMetadataVecPtr _metadata
ShaderOutput * getOutput(size_t index=0)
const ShaderInput * getInput(size_t index) const
const ShaderOutput * getOutput(size_t index=0) const
ShaderInput * getInput(size_t index)
Get inputs/outputs by index.
void setBindInput()
Set the bind input state on this port to true.
GLsizei const GLchar *const * path
GLenum GLenum GLenum input
static const string IMAGE
const ShaderGraph * getParent() const
vector< ShaderOutput * > _outputOrder
MX_GENSHADER_API const TypeDesc * BSDF
bool hasClassification(uint32_t c) const
Return true if this node matches the given classification.
virtual bool isAGraph() const
Return true if this node is a graph.
size_t numOutputs() const
void setMetadata(ShaderMetadataVecPtr metadata)
Set the metadata vector.
void setUniform()
Set the uniform flag this port to true.
static const string PROCEDURAL3D_GROUPNAME
void setFlag(uint32_t flag, bool value)
Set the on|off state of a given flag.
GLuint const GLchar * name
const string & getVariable() const
Return the variable name of this port.
bool getFlag(uint32_t flag) const
Return the on|off state of a given flag.
static const string TRANSFORM_VECTOR
bool isEditable(const ShaderGraphInputSocket &input) const
uint32_t conditionBitmask
bool isUniform() const
Return the uniform flag on this port.
ShaderMetadataVecPtr getMetadata()
Get the metadata vector.
const string & getPath() const
Return the path to this port.
vector< ShaderInput * > ShaderInputVec
A vector of ShaderInput pointers.
void setName(const string &name)
Set the name of this port.
void setType(const TypeDesc *type)
Set the data type for this port.
const vector< ShaderInput * > & getInputs() const
Get vector of inputs/outputs.
vector< ShaderMetadata > ShaderMetadataVec
static const uint32_t BIND_INPUT
static const uint32_t UNIFORM
const ShaderMetadataVecPtr & getMetadata() const
Get the metadata vector.
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
const ShaderInputVec & getConnections() const
void setGeomProp(const string &geomprop)
static const string TEXTURE2D_GROUPNAME
MX_GENSHADER_API const TypeDesc * VDF
static const string PROCEDURAL2D_GROUPNAME
ShaderNode * conditionalNode
static const string BSDF_R
void setEmitted()
Set the emitted state on this port to true.
void setPath(const string &path)
Set the path to this port.
static const uint32_t EMITTED
void setMetadata(ShaderMetadataVecPtr metadata)
Set the metadata vector.
png_const_structrp png_const_inforp int * unit
const string & getSemantic() const
Return the variable semantic of this port.
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
static const string BSDF_T
void setFlags(uint32_t flags)
Set flags on this port.
ShaderInputVec _connections
shared_ptr< ShaderMetadataRegistry > ShaderMetadataRegistryPtr
shared_ptr< ShaderMetadataVec > ShaderMetadataVecPtr
Flags set on shader ports.
static const string SWITCH
shared_ptr< class ShaderOutput > ShaderOutputPtr
Shared pointer to a ShaderOutput.
const vector< ShaderOutput * > & getOutputs() const
const ShaderNode * getNode() const
Return the node this port belongs to.
ShaderNode * getNode()
Return the node this port belongs to.
void setVariable(const string &name)
Set the variable name of this port.
std::unordered_map< string, ShaderOutputPtr > _outputMap
static const string TEXTURE3D_GROUPNAME
ShaderMetadataVecPtr getMetadata()
Get the metadata vector.
shared_ptr< class ShaderPort > ShaderPortPtr
Shared pointer to a ShaderPort.
static const string SCATTER_MODE
static const string COMPARE
MX_GENSHADER_API const TypeDesc * EDF
GLsizei const GLfloat * value
static const string CONSTANT
const string & getGeomProp() const
Get geomprop name.
ShaderMetadataVecPtr _metadata
ValuePtr getValue() const
Return the value set on this port.
const ShaderMetadataVecPtr & getMetadata() const
Get the metadata vector.
#define MATERIALX_NAMESPACE_END
uint32_t getFlags() const
Return flags set on this port.
size_t numInputs() const
Get number of inputs/outputs.
bool isEmitted() const
Return the emitted state of this port.
const TypeDesc * getType() const
Return the data type for this port.
void setSemantic(const string &semantic)
Set the variable semantic of this port.
bool isEditable(const ShaderInput &input) const
uint32_t fullConditionMask
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
static const ShaderNodePtr NONE
void setValue(ValuePtr value)
Set a value on this port.
const string & getName() const
Return the name of this node.
const string & getUnit() const
Return the unit type for the value on this port.
ScopeInfo & getScopeInfo()
Return the scope info for this node.
void setUnit(const string &unit)
Set a unit type for the value on this port.
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
bool isBindInput() const
Return the emitted state of this port.