HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShaderNode.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_SHADERNODE_H
7 #define MATERIALX_SHADERNODE_H
8 
9 /// @file
10 /// Classes for nodes created during shader generation
11 
13 
17 
18 #include <MaterialXCore/Node.h>
19 
21 
22 class ShaderNode;
23 class ShaderPort;
24 class ShaderInput;
25 class ShaderOutput;
26 class ShaderGraph;
27 
28 /// Shared pointer to a ShaderPort
29 using ShaderPortPtr = shared_ptr<class ShaderPort>;
30 /// Shared pointer to a ShaderInput
31 using ShaderInputPtr = shared_ptr<class ShaderInput>;
32 /// Shared pointer to a ShaderOutput
33 using ShaderOutputPtr = shared_ptr<class ShaderOutput>;
34 /// Shared pointer to a ShaderNode
35 using ShaderNodePtr = shared_ptr<class ShaderNode>;
36 /// A vector of ShaderInput pointers
37 using ShaderInputVec = vector<ShaderInput*>;
38 
39 /// Metadata to be exported to generated shader.
41 {
42  string name;
45  ShaderMetadata(const string& n, TypeDesc t, ValuePtr v = nullptr) :
46  name(n),
47  type(t),
48  value(v)
49  {
50  }
51 };
52 using ShaderMetadataVec = vector<ShaderMetadata>;
53 using ShaderMetadataVecPtr = shared_ptr<ShaderMetadataVec>;
54 
55 /// @class ShaderMetadataRegistry
56 /// A registry for metadata that will be exported to the generated shader
57 /// if found on nodes and inputs during shader generation.
59 {
60  public:
61  static const string USER_DATA_NAME;
62 
63  /// Add a new metadata entry to the registry.
64  /// The entry contains the name and data type
65  /// for the metadata.
66  void addMetadata(const string& name, TypeDesc type, ValuePtr value = nullptr)
67  {
68  if (_entryIndex.count(name) == 0)
69  {
70  _entryIndex[name] = _entries.size();
71  _entries.emplace_back(name, type, value);
72  }
73  }
74 
75  /// Return the metadata registered for the given name, or nullptr
76  /// if no such entry is found.
77  const ShaderMetadata* findMetadata(const string& name) const
78  {
79  auto it = _entryIndex.find(name);
80  return it != _entryIndex.end() ? &_entries[it->second] : nullptr;
81  }
82 
83  /// Return the metadata registered for the given name, or nullptr
84  /// if no such entry is found.
86  {
87  auto it = _entryIndex.find(name);
88  return it != _entryIndex.end() ? &_entries[it->second] : nullptr;
89  }
90 
91  /// Return all entries in the registry.
93  {
94  return _entries;
95  }
96 
97  /// Clear all entries in the registry.
98  void clear()
99  {
100  _entryIndex.clear();
101  _entries.clear();
102  }
103 
104  protected:
105  vector<ShaderMetadata> _entries;
106  std::unordered_map<string, size_t> _entryIndex;
107 };
108 
109 using ShaderMetadataRegistryPtr = shared_ptr<ShaderMetadataRegistry>;
110 
111 /// Flags set on shader ports.
113 {
114  public:
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;
118 };
119 
120 /// @class ShaderPort
121 /// An input or output port on a ShaderNode
122 class MX_GENSHADER_API ShaderPort : public std::enable_shared_from_this<ShaderPort>
123 {
124  public:
125  /// Constructor.
126  ShaderPort(ShaderNode* node, TypeDesc type, const string& name, ValuePtr value = nullptr);
127 
128  /// Return a shared pointer instance of this object.
130  {
131  return shared_from_this();
132  }
133 
134  /// Return the node this port belongs to.
135  ShaderNode* getNode() { return _node; }
136 
137  /// Return the node this port belongs to.
138  const ShaderNode* getNode() const { return _node; }
139 
140  /// Set the data type for this port.
141  void setType(TypeDesc type) { _type = type; }
142 
143  /// Return the data type for this port.
144  TypeDesc getType() const { return _type; }
145 
146  /// Set the name of this port.
147  void setName(const string& name) { _name = name; }
148 
149  /// Return the name of this port.
150  const string& getName() const { return _name; }
151 
152  /// Return the name of this port.
153  string getFullName() const;
154 
155  /// Set the variable name of this port.
156  void setVariable(const string& name) { _variable = name; }
157 
158  /// Return the variable name of this port.
159  const string& getVariable() const { return _variable; }
160 
161  /// Set the variable semantic of this port.
162  void setSemantic(const string& semantic) { _semantic = semantic; }
163 
164  /// Return the variable semantic of this port.
165  const string& getSemantic() const { return _semantic; }
166 
167  /// Set a value on this port.
168  void setValue(ValuePtr value) { _value = value; }
169 
170  /// Return the value set on this port.
171  ValuePtr getValue() const { return _value; }
172 
173  /// Return the value set on this port as a string, or an empty string if there is no value.
174  string getValueString() const;
175 
176  /// Set a source color space for the value on this port.
177  void setColorSpace(const string& colorspace) { _colorspace = colorspace; }
178 
179  /// Return the source color space for the value on this port.
180  const string& getColorSpace() const { return _colorspace; }
181 
182  /// Set a unit type for the value on this port.
183  void setUnit(const string& unit) { _unit = unit; }
184 
185  /// Return the unit type for the value on this port.
186  const string& getUnit() const { return _unit; }
187 
188  /// Set geomprop name if the input has a default
189  /// geomprop to be assigned when it is unconnected.
190  void setGeomProp(const string& geomprop) { _geomprop = geomprop; }
191 
192  /// Get geomprop name.
193  const string& getGeomProp() const { return _geomprop; }
194 
195  /// Set the path to this port.
196  void setPath(const string& path) { _path = path; }
197 
198  /// Return the path to this port.
199  const string& getPath() const { return _path; }
200 
201  /// Set flags on this port.
202  void setFlags(uint32_t flags) { _flags = flags; }
203 
204  /// Return flags set on this port.
205  uint32_t getFlags() const { return _flags; }
206 
207  /// Set the on|off state of a given flag.
208  void setFlag(uint32_t flag, bool value)
209  {
210  _flags = value ? (_flags | flag) : (_flags & ~flag);
211  }
212 
213  /// Return the on|off state of a given flag.
214  bool getFlag(uint32_t flag) const
215  {
216  return ((_flags & flag) != 0);
217  }
218 
219  /// Set the uniform flag this port to true.
220  void setUniform() { _flags |= ShaderPortFlag::UNIFORM; }
221 
222  /// Return the uniform flag on this port.
223  bool isUniform() const { return (_flags & ShaderPortFlag::UNIFORM) != 0; }
224 
225  /// Set the emitted state on this port to true.
226  void setEmitted() { _flags |= ShaderPortFlag::EMITTED; }
227 
228  /// Return the emitted state of this port.
229  bool isEmitted() const { return (_flags & ShaderPortFlag::EMITTED) != 0; }
230 
231  /// Set the bind input state on this port to true.
233 
234  /// Return the emitted state of this port.
235  bool isBindInput() const { return (_flags & ShaderPortFlag::BIND_INPUT) != 0; }
236 
237  /// Set the metadata vector.
238  void setMetadata(ShaderMetadataVecPtr metadata) { _metadata = metadata; }
239 
240  /// Get the metadata vector.
241  ShaderMetadataVecPtr getMetadata() { return _metadata; }
242 
243  /// Get the metadata vector.
244  const ShaderMetadataVecPtr& getMetadata() const { return _metadata; }
245 
246  protected:
249  string _name;
250  string _path;
251  string _semantic;
252  string _variable;
254  string _unit;
255  string _colorspace;
256  string _geomprop;
258  uint32_t _flags;
259 };
260 
261 /// @class ShaderInput
262 /// An input on a ShaderNode
264 {
265  public:
266  ShaderInput(ShaderNode* node, TypeDesc type, const string& name);
267 
268  /// Return a connection to an upstream node output,
269  /// or nullptr if not connected.
270  ShaderOutput* getConnection() { return _connection; }
271 
272  /// Return a connection to an upstream node output,
273  /// or nullptr if not connected.
274  const ShaderOutput* getConnection() const { return _connection; }
275 
276  /// Make a connection from the given source output to this input.
277  void makeConnection(ShaderOutput* src);
278 
279  /// Break the connection to this input.
280  void breakConnection();
281 
282  /// Return the sibling node connected upstream,
283  /// or nullptr if there is no sibling upstream.
284  ShaderNode* getConnectedSibling() const;
285 
286  protected:
288  string _channels;
289  friend class ShaderOutput;
290 };
291 
292 /// @class ShaderOutput
293 /// An output on a ShaderNode
295 {
296  public:
297  ShaderOutput(ShaderNode* node, TypeDesc type, const string& name);
298 
299  /// Return a set of connections to downstream node inputs,
300  /// empty if not connected.
301  const ShaderInputVec& getConnections() const { return _connections; }
302 
303  /// Make a connection from this output to the given input
304  void makeConnection(ShaderInput* dst);
305 
306  /// Break a connection from this output to the given input
307  void breakConnection(ShaderInput* dst);
308 
309  /// Break all connections from this output
310  void breakConnections();
311 
312  protected:
314  friend class ShaderInput;
315 };
316 
317 /// @class ShaderNode
318 /// Class representing a node in the shader generation DAG
320 {
321  public:
322  virtual ~ShaderNode() { }
323 
324  /// Flags for classifying nodes into different categories.
326  {
327  public:
328  // Node classes
329  static const uint32_t TEXTURE = 1 << 0; /// Any node that outputs floats, colors, vectors, etc.
330  static const uint32_t CLOSURE = 1 << 1; /// Any node that represents light integration
331  static const uint32_t SHADER = 1 << 2; /// Any node that outputs a shader
332  static const uint32_t MATERIAL = 1 << 3; /// Any node that outputs a material
333  // Specific texture node types
334  static const uint32_t FILETEXTURE = 1 << 4; /// A file texture node
335  static const uint32_t CONDITIONAL = 1 << 5; /// A conditional node
336  static const uint32_t CONSTANT = 1 << 6; /// A constant node
337  // Specific closure types
338  static const uint32_t BSDF = 1 << 7; /// A BSDF node
339  static const uint32_t BSDF_R = 1 << 8; /// A reflection BSDF node
340  static const uint32_t BSDF_T = 1 << 9; /// A transmission BSDF node
341  static const uint32_t EDF = 1 << 10; /// A EDF node
342  static const uint32_t VDF = 1 << 11; /// A VDF node
343  static const uint32_t LAYER = 1 << 12; /// A node for vertical layering of other closure nodes
344  // Specific shader types
345  static const uint32_t SURFACE = 1 << 13; /// A surface shader node
346  static const uint32_t VOLUME = 1 << 14; /// A volume shader node
347  static const uint32_t LIGHT = 1 << 15; /// A light shader node
348  static const uint32_t UNLIT = 1 << 16; /// An unlit surface shader node
349  // Types based on nodegroup
350  static const uint32_t SAMPLE2D = 1 << 17; /// Can be sampled in 2D (uv space)
351  static const uint32_t SAMPLE3D = 1 << 18; /// Can be sampled in 3D (position)
352  static const uint32_t GEOMETRIC = 1 << 19; /// Geometric input
353  static const uint32_t DOT = 1 << 20; /// A dot node
354  };
355 
356  static const ShaderNodePtr NONE;
357 
358  static const string CONSTANT;
359  static const string DOT;
360  static const string IMAGE;
361  static const string SURFACESHADER;
362  static const string BSDF_R;
363  static const string BSDF_T;
364  static const string TRANSFORM_POINT;
365  static const string TRANSFORM_VECTOR;
366  static const string TRANSFORM_NORMAL;
367  static const string TEXTURE2D_GROUPNAME;
368  static const string TEXTURE3D_GROUPNAME;
369  static const string PROCEDURAL2D_GROUPNAME;
370  static const string PROCEDURAL3D_GROUPNAME;
371  static const string GEOMETRIC_GROUPNAME;
372 
373  public:
374  /// Constructor.
375  ShaderNode(const ShaderGraph* parent, const string& name);
376 
377  /// Create a new node from a nodedef.
378  static ShaderNodePtr create(const ShaderGraph* parent, const string& name, const NodeDef& nodeDef,
379  GenContext& context);
380 
381  /// Create a new node from a node implementation.
382  static ShaderNodePtr create(const ShaderGraph* parent, const string& name, ShaderNodeImplPtr impl,
383  unsigned int classification = Classification::TEXTURE);
384 
385  /// Return true if this node is a graph.
386  virtual bool isAGraph() const { return false; }
387 
388  /// Return the parent graph that owns this node.
389  /// If this node is a root graph it has no parent
390  /// and nullptr will be returned.
391  const ShaderGraph* getParent() const
392  {
393  return _parent;
394  }
395 
396  /// Set classification bits for this node,
397  /// replacing any previous set bits.
398  void setClassification(uint32_t c)
399  {
400  _classification = c;
401  }
402 
403  /// Get classification bits set for this node.
404  uint32_t getClassification() const
405  {
406  return _classification;
407  }
408 
409  /// Add classification bits to this node.
410  void addClassification(uint32_t c)
411  {
412  _classification |= c;
413  }
414 
415  /// Return true if this node matches the given classification.
416  bool hasClassification(uint32_t c) const
417  {
418  return (_classification & c) == c;
419  }
420 
421  /// Return the name of this node.
422  const string& getName() const
423  {
424  return _name;
425  }
426 
427  /// Return the implementation used for this node.
429  {
430  return *_impl;
431  }
432 
433  /// Initialize this shader node with all required data
434  /// from the given node and nodedef.
435  void initialize(const Node& node, const NodeDef& nodeDef, GenContext& context);
436 
437  /// Add inputs/outputs
438  ShaderInput* addInput(const string& name, TypeDesc type);
439  ShaderOutput* addOutput(const string& name, TypeDesc type);
440 
441  /// Get number of inputs/outputs
442  size_t numInputs() const { return _inputOrder.size(); }
443  size_t numOutputs() const { return _outputOrder.size(); }
444 
445  /// Get inputs/outputs by index
446  ShaderInput* getInput(size_t index) { return _inputOrder[index]; }
447  ShaderOutput* getOutput(size_t index = 0) { return _outputOrder[index]; }
448  const ShaderInput* getInput(size_t index) const { return _inputOrder[index]; }
449  const ShaderOutput* getOutput(size_t index = 0) const { return _outputOrder[index]; }
450 
451  /// Get inputs/outputs by name
452  ShaderInput* getInput(const string& name);
453  ShaderOutput* getOutput(const string& name);
454  const ShaderInput* getInput(const string& name) const;
455  const ShaderOutput* getOutput(const string& name) const;
456 
457  /// Get vector of inputs/outputs
458  const vector<ShaderInput*>& getInputs() const { return _inputOrder; }
459  const vector<ShaderOutput*>& getOutputs() const { return _outputOrder; }
460 
461  /// Set the metadata vector.
462  void setMetadata(ShaderMetadataVecPtr metadata) { _metadata = metadata; }
463 
464  /// Get the metadata vector.
465  ShaderMetadataVecPtr getMetadata() { return _metadata; }
466 
467  /// Get the metadata vector.
468  const ShaderMetadataVecPtr& getMetadata() const { return _metadata; }
469 
470  /// Returns true if an input is editable by users.
471  /// Editable inputs are allowed to be published as shader uniforms
472  /// and hence must be presentable in a user interface.
473  bool isEditable(const ShaderInput& input) const
474  {
475  return (!_impl || _impl->isEditable(input));
476  }
477 
478  /// Returns true if a graph input is accessible by users.
479  /// Editable inputs are allowed to be published as shader uniforms
480  /// and hence must be presentable in a user interface.
481  bool isEditable(const ShaderGraphInputSocket& input) const
482  {
483  return (!_impl || _impl->isEditable(input));
484  }
485 
486  protected:
487  /// Create metadata from the nodedef according to registered metadata.
488  void createMetadata(const NodeDef& nodeDef, GenContext& context);
489 
491  string _name;
492  uint32_t _classification;
493 
494  std::unordered_map<string, ShaderInputPtr> _inputMap;
495  vector<ShaderInput*> _inputOrder;
496 
497  std::unordered_map<string, ShaderOutputPtr> _outputMap;
498  vector<ShaderOutput*> _outputOrder;
499 
502 
503  friend class ShaderGraph;
504 };
505 
507 
508 #endif
ShaderOutput * _connection
Definition: ShaderNode.h:287
const ShaderGraph * _parent
Definition: ShaderNode.h:490
type
Definition: core.h:556
Flags for classifying nodes into different categories.
Definition: ShaderNode.h:325
shared_ptr< class ShaderInput > ShaderInputPtr
Shared pointer to a ShaderInput.
Definition: ShaderNode.h:31
const ShaderOutput * getConnection() const
Definition: ShaderNode.h:274
const string & getColorSpace() const
Return the source color space for the value on this port.
Definition: ShaderNode.h:180
ShaderPortPtr getSelf()
Return a shared pointer instance of this object.
Definition: ShaderNode.h:129
short * getInput(int size) override
static const string TRANSFORM_POINT
Definition: ShaderNode.h:364
GLbitfield flags
Definition: glcorearb.h:1596
const ShaderNodeImpl & getImplementation() const
Return the implementation used for this node.
Definition: ShaderNode.h:428
static const string USER_DATA_NAME
Definition: ShaderNode.h:61
void addClassification(uint32_t c)
Add classification bits to this node.
Definition: ShaderNode.h:410
const string & getName() const
Return the name of this port.
Definition: ShaderNode.h:150
vector< ShaderInput * > _inputOrder
Definition: ShaderNode.h:495
static const string TRANSFORM_NORMAL
Definition: ShaderNode.h:366
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: Library.h:39
std::unordered_map< string, size_t > _entryIndex
Definition: ShaderNode.h:106
ValuePtr _value
Definition: ShaderNode.h:253
string _path
Definition: ShaderNode.h:250
void setColorSpace(const string &colorspace)
Set a source color space for the value on this port.
Definition: ShaderNode.h:177
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
const ShaderMetadata * findMetadata(const string &name) const
Definition: ShaderNode.h:77
std::unordered_map< string, ShaderInputPtr > _inputMap
Definition: ShaderNode.h:494
ShaderMetadataVecPtr _metadata
Definition: ShaderNode.h:501
ShaderOutput * getOutput(size_t index=0)
Definition: ShaderNode.h:447
Definition: Node.h:52
string _name
Definition: ShaderNode.h:491
const GLdouble * v
Definition: glcorearb.h:837
const ShaderMetadataVec & getAllMetadata() const
Return all entries in the registry.
Definition: ShaderNode.h:92
const ShaderInput * getInput(size_t index) const
Definition: ShaderNode.h:448
const ShaderOutput * getOutput(size_t index=0) const
Definition: ShaderNode.h:449
GLsizei const GLfloat * value
Definition: glcorearb.h:824
ShaderInput * getInput(size_t index)
Get inputs/outputs by index.
Definition: ShaderNode.h:446
void setBindInput()
Set the bind input state on this port to true.
Definition: ShaderNode.h:232
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static const string IMAGE
Definition: ShaderNode.h:360
const ShaderGraph * getParent() const
Definition: ShaderNode.h:391
vector< ShaderOutput * > _outputOrder
Definition: ShaderNode.h:498
bool hasClassification(uint32_t c) const
Return true if this node matches the given classification.
Definition: ShaderNode.h:416
virtual bool isAGraph() const
Return true if this node is a graph.
Definition: ShaderNode.h:386
size_t numOutputs() const
Definition: ShaderNode.h:443
void setMetadata(ShaderMetadataVecPtr metadata)
Set the metadata vector.
Definition: ShaderNode.h:462
void setUniform()
Set the uniform flag this port to true.
Definition: ShaderNode.h:220
static const string PROCEDURAL3D_GROUPNAME
Definition: ShaderNode.h:370
Metadata to be exported to generated shader.
Definition: ShaderNode.h:40
void setFlag(uint32_t flag, bool value)
Set the on|off state of a given flag.
Definition: ShaderNode.h:208
#define MX_GENSHADER_API
Definition: Export.h:18
string _variable
Definition: ShaderNode.h:252
const string & getVariable() const
Return the variable name of this port.
Definition: ShaderNode.h:159
bool getFlag(uint32_t flag) const
Return the on|off state of a given flag.
Definition: ShaderNode.h:214
static const string TRANSFORM_VECTOR
Definition: ShaderNode.h:365
bool isEditable(const ShaderGraphInputSocket &input) const
Definition: ShaderNode.h:481
ShaderMetadata(const string &n, TypeDesc t, ValuePtr v=nullptr)
Definition: ShaderNode.h:45
ShaderNode * _node
Definition: ShaderNode.h:247
bool isUniform() const
Return the uniform flag on this port.
Definition: ShaderNode.h:223
ShaderMetadataVecPtr getMetadata()
Get the metadata vector.
Definition: ShaderNode.h:465
const string & getPath() const
Return the path to this port.
Definition: ShaderNode.h:199
vector< ShaderInput * > ShaderInputVec
A vector of ShaderInput pointers.
Definition: ShaderNode.h:37
string _name
Definition: ShaderNode.h:249
void setName(const string &name)
Set the name of this port.
Definition: ShaderNode.h:147
const vector< ShaderInput * > & getInputs() const
Get vector of inputs/outputs.
Definition: ShaderNode.h:458
GLdouble n
Definition: glcorearb.h:2008
vector< ShaderMetadata > ShaderMetadataVec
Definition: ShaderNode.h:52
static const uint32_t BIND_INPUT
Definition: ShaderNode.h:117
static const uint32_t UNIFORM
Definition: ShaderNode.h:115
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
const ShaderMetadataVecPtr & getMetadata() const
Get the metadata vector.
Definition: ShaderNode.h:244
ShaderNodeImplPtr _impl
Definition: ShaderNode.h:500
ShaderMetadata * findMetadata(const string &name)
Definition: ShaderNode.h:85
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
Definition: ShaderNode.h:35
static const string DOT
Definition: ShaderNode.h:359
const ShaderInputVec & getConnections() const
Definition: ShaderNode.h:301
void setGeomProp(const string &geomprop)
Definition: ShaderNode.h:190
static const string TEXTURE2D_GROUPNAME
Definition: ShaderNode.h:367
static const string PROCEDURAL2D_GROUPNAME
Definition: ShaderNode.h:369
static const string BSDF_R
Definition: ShaderNode.h:362
void setEmitted()
Set the emitted state on this port to true.
Definition: ShaderNode.h:226
void setPath(const string &path)
Set the path to this port.
Definition: ShaderNode.h:196
static const uint32_t EMITTED
Definition: ShaderNode.h:116
void setMetadata(ShaderMetadataVecPtr metadata)
Set the metadata vector.
Definition: ShaderNode.h:238
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
const string & getSemantic() const
Return the variable semantic of this port.
Definition: ShaderNode.h:165
GLuint const GLchar * name
Definition: glcorearb.h:786
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
Definition: logging.h:294
static const string BSDF_T
Definition: ShaderNode.h:363
void setFlags(uint32_t flags)
Set flags on this port.
Definition: ShaderNode.h:202
uint32_t _classification
Definition: ShaderNode.h:492
ShaderInputVec _connections
Definition: ShaderNode.h:313
shared_ptr< ShaderMetadataRegistry > ShaderMetadataRegistryPtr
Definition: ShaderNode.h:109
ValuePtr value
Definition: ShaderNode.h:44
shared_ptr< ShaderMetadataVec > ShaderMetadataVecPtr
Definition: ShaderNode.h:53
GLdouble t
Definition: glad.h:2397
Flags set on shader ports.
Definition: ShaderNode.h:112
TypeDesc getType() const
Return the data type for this port.
Definition: ShaderNode.h:144
void clear()
Clear all entries in the registry.
Definition: ShaderNode.h:98
static const string SURFACESHADER
Definition: ShaderNode.h:361
GLenum GLenum dst
Definition: glcorearb.h:1793
string _semantic
Definition: ShaderNode.h:251
shared_ptr< class ShaderOutput > ShaderOutputPtr
Shared pointer to a ShaderOutput.
Definition: ShaderNode.h:33
TypeDesc type
Definition: ShaderNode.h:43
const vector< ShaderOutput * > & getOutputs() const
Definition: ShaderNode.h:459
vector< ShaderMetadata > _entries
Definition: ShaderNode.h:105
const ShaderNode * getNode() const
Return the node this port belongs to.
Definition: ShaderNode.h:138
ShaderNode * getNode()
Return the node this port belongs to.
Definition: ShaderNode.h:135
uint32_t _flags
Definition: ShaderNode.h:258
void setVariable(const string &name)
Set the variable name of this port.
Definition: ShaderNode.h:156
string _colorspace
Definition: ShaderNode.h:255
GLuint index
Definition: glcorearb.h:786
std::unordered_map< string, ShaderOutputPtr > _outputMap
Definition: ShaderNode.h:497
static const string TEXTURE3D_GROUPNAME
Definition: ShaderNode.h:368
string _unit
Definition: ShaderNode.h:254
ShaderMetadataVecPtr getMetadata()
Get the metadata vector.
Definition: ShaderNode.h:241
shared_ptr< class ShaderPort > ShaderPortPtr
Shared pointer to a ShaderPort.
Definition: ShaderNode.h:29
TypeDesc _type
Definition: ShaderNode.h:248
virtual ~ShaderNode()
Definition: ShaderNode.h:322
static const string CONSTANT
Definition: ShaderNode.h:358
const string & getGeomProp() const
Get geomprop name.
Definition: ShaderNode.h:193
ShaderMetadataVecPtr _metadata
Definition: ShaderNode.h:257
ValuePtr getValue() const
Return the value set on this port.
Definition: ShaderNode.h:171
const ShaderMetadataVecPtr & getMetadata() const
Get the metadata vector.
Definition: ShaderNode.h:468
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
uint32_t getFlags() const
Return flags set on this port.
Definition: ShaderNode.h:205
void addMetadata(const string &name, TypeDesc type, ValuePtr value=nullptr)
Definition: ShaderNode.h:66
size_t numInputs() const
Get number of inputs/outputs.
Definition: ShaderNode.h:442
bool isEmitted() const
Return the emitted state of this port.
Definition: ShaderNode.h:229
void setSemantic(const string &semantic)
Set the variable semantic of this port.
Definition: ShaderNode.h:162
string _geomprop
Definition: ShaderNode.h:256
bool isEditable(const ShaderInput &input) const
Definition: ShaderNode.h:473
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:30
static const ShaderNodePtr NONE
Definition: ShaderNode.h:356
void setClassification(uint32_t c)
Definition: ShaderNode.h:398
uint32_t getClassification() const
Get classification bits set for this node.
Definition: ShaderNode.h:404
void setValue(ValuePtr value)
Set a value on this port.
Definition: ShaderNode.h:168
string _channels
Definition: ShaderNode.h:288
const string & getName() const
Return the name of this node.
Definition: ShaderNode.h:422
const string & getUnit() const
Return the unit type for the value on this port.
Definition: ShaderNode.h:186
void setUnit(const string &unit)
Set a unit type for the value on this port.
Definition: ShaderNode.h:183
static const string GEOMETRIC_GROUPNAME
Definition: ShaderNode.h:371
void setType(TypeDesc type)
Set the data type for this port.
Definition: ShaderNode.h:141
GLenum src
Definition: glcorearb.h:1793
bool isBindInput() const
Return the emitted state of this port.
Definition: ShaderNode.h:235
ShaderOutput * getConnection()
Definition: ShaderNode.h:270