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