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;
115 static const uint32_t UNIFORM = 1u << 0;
116 static const uint32_t EMITTED = 1u << 1;
117 static const uint32_t BIND_INPUT = 1u << 2;
131 return shared_from_this();
150 const string&
getName()
const {
return _name; }
153 string getFullName()
const;
162 void setSemantic(
const string& semantic) { _semantic = semantic; }
174 string getValueString()
const;
186 const string&
getUnit()
const {
return _unit; }
190 void setGeomProp(
const string& geomprop) { _geomprop = geomprop; }
199 const string&
getPath()
const {
return _path; }
210 _flags = value ? (_flags | flag) : (_flags & ~flag);
216 return ((_flags & flag) != 0);
280 void breakConnection();
316 void breakConnections();
335 static const uint32_t TEXTURE = 1 << 0;
336 static const uint32_t CLOSURE = 1 << 1;
337 static const uint32_t SHADER = 1 << 2;
340 static const uint32_t FILETEXTURE = 1 << 4;
341 static const uint32_t CONDITIONAL = 1 << 5;
344 static const uint32_t
BSDF = 1 << 7;
345 static const uint32_t BSDF_R = 1 << 8;
346 static const uint32_t BSDF_T = 1 << 9;
347 static const uint32_t
EDF = 1 << 10;
348 static const uint32_t
VDF = 1 << 11;
349 static const uint32_t LAYER = 1 << 12;
350 static const uint32_t THINFILM = 1 << 13;
352 static const uint32_t SURFACE = 1 << 14;
353 static const uint32_t VOLUME = 1 << 15;
354 static const uint32_t LIGHT = 1 << 16;
355 static const uint32_t UNLIT = 1 << 17;
357 static const uint32_t SAMPLE2D = 1 << 18;
358 static const uint32_t SAMPLE3D = 1 << 19;
359 static const uint32_t GEOMETRIC = 1 << 20;
360 static const uint32_t DOT = 1 << 21;
391 unsigned int classification = Classification::TEXTURE);
414 return _classification;
420 _classification |=
c;
426 return (_classification & c) ==
c;
466 const vector<ShaderInput*>&
getInputs()
const {
return _inputOrder; }
467 const vector<ShaderOutput*>&
getOutputs()
const {
return _outputOrder; }
483 return (!_impl || _impl->isEditable(input));
491 return (!_impl || _impl->isEditable(input));
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.
void addClassification(uint32_t c)
Add classification bits to 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.
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
GLsizei const GLfloat * value
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
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.
MX_GENSHADER_API const TypeDesc * MATERIAL
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
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
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.
GLuint const GLchar * name
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 SURFACESHADER
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
MX_GENSHADER_API const TypeDesc * EDF
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
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
static const ShaderNodePtr NONE
void setClassification(uint32_t c)
uint32_t getClassification() const
Get classification bits set for this node.
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.
void setUnit(const string &unit)
Set a unit type for the value on this port.
static const string GEOMETRIC_GROUPNAME
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.