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 // TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
3 // All rights reserved. See LICENSE.txt for license.
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 
40 /// Metadata to be exported to generated shader.
42 {
43  string name;
44  const TypeDesc* type;
46  ShaderMetadata(const string& n, const TypeDesc* t, ValuePtr v = nullptr) :
47  name(n),
48  type(t),
49  value(v)
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, const 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 
112 /// Flags set on shader ports.
114 {
115  public:
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;
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, const 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(const TypeDesc* type) { _type = type; }
143 
144  /// Return the data type for this port.
145  const 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) { _value = value; }
170 
171  /// Return the value set on this port.
172  ValuePtr getValue() const { return _value; }
173 
174  /// Set a source color space for the value on this port.
175  void setColorSpace(const string& colorspace) { _colorspace = colorspace; }
176 
177  /// Return the source color space for the value on this port.
178  const string& getColorSpace() const { return _colorspace; }
179 
180  /// Set a unit type for the value on this port.
181  void setUnit(const string& unit) { _unit = unit; }
182 
183  /// Return the unit type for the value on this port.
184  const string& getUnit() const { return _unit; }
185 
186  /// Set geomprop name if the input has a default
187  /// geomprop to be assigned when it is unconnected.
188  void setGeomProp(const string& geomprop) { _geomprop = geomprop; }
189 
190  /// Get geomprop name.
191  const string& getGeomProp() const { return _geomprop; }
192 
193  /// Set the path to this port.
194  void setPath(const string& path) { _path = path; }
195 
196  /// Return the path to this port.
197  const string& getPath() const { return _path; }
198 
199  /// Set flags on this port.
200  void setFlags(uint32_t flags) { _flags = flags; }
201 
202  /// Return flags set on this port.
203  uint32_t getFlags() const { return _flags; }
204 
205  /// Set the on|off state of a given flag.
206  void setFlag(uint32_t flag, bool value)
207  {
208  _flags = value ? (_flags | flag) : (_flags & ~flag);
209  }
210 
211  /// Return the on|off state of a given flag.
212  bool getFlag(uint32_t flag) const
213  {
214  return ((_flags & flag) != 0);
215  }
216 
217  /// Set the uniform flag this port to true.
218  void setUniform() { _flags |= ShaderPortFlag::UNIFORM; }
219 
220  /// Return the uniform flag on this port.
221  bool isUniform() const { return (_flags & ShaderPortFlag::UNIFORM) != 0; }
222 
223  /// Set the emitted state on this port to true.
224  void setEmitted() { _flags |= ShaderPortFlag::EMITTED; }
225 
226  /// Return the emitted state of this port.
227  bool isEmitted() const { return (_flags & ShaderPortFlag::EMITTED) != 0; }
228 
229  /// Set the bind input state on this port to true.
231 
232  /// Return the emitted state of this port.
233  bool isBindInput() const { return (_flags & ShaderPortFlag::BIND_INPUT) != 0; }
234 
235  /// Set the metadata vector.
236  void setMetadata(ShaderMetadataVecPtr metadata) { _metadata = metadata; }
237 
238  /// Get the metadata vector.
239  ShaderMetadataVecPtr getMetadata() { return _metadata; }
240 
241  /// Get the metadata vector.
242  const ShaderMetadataVecPtr& getMetadata() const { return _metadata; }
243 
244  protected:
246  const TypeDesc* _type;
247  string _name;
248  string _path;
249  string _semantic;
250  string _variable;
252  string _unit;
253  string _colorspace;
254  string _geomprop;
256  uint32_t _flags;
257 };
258 
259 /// @class ShaderInput
260 /// An input on a ShaderNode
262 {
263  public:
264  ShaderInput(ShaderNode* node, const TypeDesc* type, const string& name);
265 
266  /// Return a connection to an upstream node output,
267  /// or nullptr if not connected.
268  ShaderOutput* getConnection() { return _connection; }
269 
270  /// Return a connection to an upstream node output,
271  /// or nullptr if not connected.
272  const ShaderOutput* getConnection() const { return _connection; }
273 
274  /// Make a connection from the given source output to this input.
275  void makeConnection(ShaderOutput* src);
276 
277  /// Break the connection to this input.
278  void breakConnection();
279 
280  /// Set optional channels value
281  void setChannels(const string& channels) { _channels = channels; }
282 
283  /// Get optional channels value
284  const string& getChannels() const { return _channels; }
285 
286  /// Return the sibling node connected upstream,
287  /// or nullptr if there is no sibling upstream.
288  ShaderNode* getConnectedSibling() const;
289 
290  protected:
292  string _channels;
293  friend class ShaderOutput;
294 };
295 
296 /// @class ShaderOutput
297 /// An output on a ShaderNode
299 {
300  public:
301  ShaderOutput(ShaderNode* node, const TypeDesc* type, const string& name);
302 
303  /// Return a set of connections to downstream node inputs,
304  /// empty if not connected.
305  const ShaderInputVec& getConnections() const { return _connections; }
306 
307  /// Make a connection from this output to the given input
308  void makeConnection(ShaderInput* dst);
309 
310  /// Break a connection from this output to the given input
311  void breakConnection(ShaderInput* dst);
312 
313  /// Break all connections from this output
314  void breakConnections();
315 
316  protected:
318  friend class ShaderInput;
319 };
320 
321 /// @class ShaderNode
322 /// Class representing a node in the shader generation DAG
324 {
325  public:
326  virtual ~ShaderNode() { }
327 
328  /// Flags for classifying nodes into different categories.
330  {
331  public:
332  // Node classes
333  static const uint32_t TEXTURE = 1 << 0; /// Any node that outputs floats, colors, vectors, etc.
334  static const uint32_t CLOSURE = 1 << 1; /// Any node that represents light integration
335  static const uint32_t SHADER = 1 << 2; /// Any node that outputs a shader
336  // Specific texture node types
337  static const uint32_t FILETEXTURE = 1 << 3; /// A file texture node
338  static const uint32_t CONDITIONAL = 1 << 4; /// A conditional node
339  static const uint32_t CONSTANT = 1 << 5; /// A constant node
340  // Specific closure types
341  static const uint32_t BSDF = 1 << 6; /// A BSDF node
342  static const uint32_t BSDF_R = 1 << 7; /// A reflection BSDF node
343  static const uint32_t BSDF_T = 1 << 8; /// A transmission BSDF node
344  static const uint32_t EDF = 1 << 9; /// A EDF node
345  static const uint32_t VDF = 1 << 10; /// A VDF node
346  static const uint32_t LAYER = 1 << 11; /// A node for vertical layering of other closure nodes
347  static const uint32_t THINFILM = 1 << 12; /// A node for adding thin-film over microfacet BSDF nodes
348  // Specific shader types
349  static const uint32_t SURFACE = 1 << 13; /// A surface shader node
350  static const uint32_t VOLUME = 1 << 14; /// A volume shader node
351  static const uint32_t LIGHT = 1 << 15; /// A light shader node
352  static const uint32_t UNLIT = 1 << 16; /// An unlit surface shader node
353  // Specific conditional types
354  static const uint32_t IFELSE = 1 << 17; /// An if-else statement
355  static const uint32_t SWITCH = 1 << 18; /// A switch statement
356  // Types based on nodegroup
357  static const uint32_t SAMPLE2D = 1 << 19; /// Can be sampled in 2D (uv space)
358  static const uint32_t SAMPLE3D = 1 << 20; /// Can be sampled in 3D (position)
359  };
360 
361  /// @struct ScopeInfo
362  /// Information on source code scope for the node.
363  ///
364  /// @todo: Refactor the scope handling, using scope id's instead
365  ///
366  struct ScopeInfo
367  {
368  enum Type
369  {
374  };
375 
376  ScopeInfo() : type(UNKNOWN), conditionalNode(nullptr), conditionBitmask(0), fullConditionMask(0) {}
377 
378  void merge(const ScopeInfo& fromScope);
379  void adjustAtConditionalInput(ShaderNode* condNode, int branch, uint32_t fullMask);
380  bool usedByBranch(int branchIndex) const { return (conditionBitmask & (1 << branchIndex)) != 0; }
381 
386  };
387 
388  static const ShaderNodePtr NONE;
389 
390  static const string CONSTANT;
391  static const string IMAGE;
392  static const string COMPARE;
393  static const string SWITCH;
394  static const string SCATTER_MODE;
395  static const string BSDF_R;
396  static const string BSDF_T;
397  static const string TRANSFORM_POINT;
398  static const string TRANSFORM_VECTOR;
399  static const string TRANSFORM_NORMAL;
400  static const string TEXTURE2D_GROUPNAME;
401  static const string TEXTURE3D_GROUPNAME;
402  static const string PROCEDURAL2D_GROUPNAME;
403  static const string PROCEDURAL3D_GROUPNAME;
404 
405  public:
406  /// Constructor.
407  ShaderNode(const ShaderGraph* parent, const string& name);
408 
409  /// Create a new node from a nodedef.
410  static ShaderNodePtr create(const ShaderGraph* parent, const string& name, const NodeDef& nodeDef,
411  GenContext& context);
412 
413  /// Create a new node from a node implementation.
414  static ShaderNodePtr create(const ShaderGraph* parent, const string& name, ShaderNodeImplPtr impl,
415  unsigned int classification = Classification::TEXTURE);
416 
417  /// Return true if this node is a graph.
418  virtual bool isAGraph() const { return false; }
419 
420  /// Return the parent graph that owns this node.
421  /// If this node is a root graph it has no parent
422  /// and nullptr will be returned.
423  const ShaderGraph* getParent() const
424  {
425  return _parent;
426  }
427 
428  /// Return true if this node matches the given classification.
429  bool hasClassification(uint32_t c) const
430  {
431  return (_classification & c) == c;
432  }
433 
434  /// Return the name of this node.
435  const string& getName() const
436  {
437  return _name;
438  }
439 
440  /// Return the implementation used for this node.
442  {
443  return *_impl;
444  }
445 
446  /// Return the scope info for this node.
448  {
449  return _scopeInfo;
450  }
451 
452  /// Return the scope info for this node.
453  const ScopeInfo& getScopeInfo() const
454  {
455  return _scopeInfo;
456  }
457 
458  /// Returns true if this node is only referenced by a conditional.
459  bool referencedConditionally() const;
460 
461  /// Initialize this shader node with all required data
462  /// from the given node and nodedef.
463  void initialize(const Node& node, const NodeDef& nodeDef, GenContext& context);
464 
465  /// Add inputs/outputs
466  ShaderInput* addInput(const string& name, const TypeDesc* type);
467  ShaderOutput* addOutput(const string& name, const TypeDesc* type);
468 
469  /// Get number of inputs/outputs
470  size_t numInputs() const { return _inputOrder.size(); }
471  size_t numOutputs() const { return _outputOrder.size(); }
472 
473  /// Get inputs/outputs by index
474  ShaderInput* getInput(size_t index) { return _inputOrder[index]; }
475  ShaderOutput* getOutput(size_t index = 0) { return _outputOrder[index]; }
476  const ShaderInput* getInput(size_t index) const { return _inputOrder[index]; }
477  const ShaderOutput* getOutput(size_t index = 0) const { return _outputOrder[index]; }
478 
479  /// Get inputs/outputs by name
480  ShaderInput* getInput(const string& name);
481  ShaderOutput* getOutput(const string& name);
482  const ShaderInput* getInput(const string& name) const;
483  const ShaderOutput* getOutput(const string& name) const;
484 
485  /// Get vector of inputs/outputs
486  const vector<ShaderInput*>& getInputs() const { return _inputOrder; }
487  const vector<ShaderOutput*>& getOutputs() const { return _outputOrder; }
488 
489  /// Set the metadata vector.
490  void setMetadata(ShaderMetadataVecPtr metadata) { _metadata = metadata; }
491 
492  /// Get the metadata vector.
493  ShaderMetadataVecPtr getMetadata() { return _metadata; }
494 
495  /// Get the metadata vector.
496  const ShaderMetadataVecPtr& getMetadata() const { return _metadata; }
497 
498  /// Returns true if an input is editable by users.
499  /// Editable inputs are allowed to be published as shader uniforms
500  /// and hence must be presentable in a user interface.
501  bool isEditable(const ShaderInput& input) const
502  {
503  return (!_impl || _impl->isEditable(input));
504  }
505 
506  /// Returns true if a graph input is accessible by users.
507  /// Editable inputs are allowed to be published as shader uniforms
508  /// and hence must be presentable in a user interface.
510  {
511  return (!_impl || _impl->isEditable(input));
512  }
513 
514  protected:
515  /// Create metadata from the nodedef according to registered metadata.
516  void createMetadata(const NodeDef& nodeDef, GenContext& context);
517 
519  string _name;
520  uint32_t _classification;
521 
522  std::unordered_map<string, ShaderInputPtr> _inputMap;
523  vector<ShaderInput*> _inputOrder;
524 
525  std::unordered_map<string, ShaderOutputPtr> _outputMap;
526  vector<ShaderOutput*> _outputOrder;
527 
531 
532  friend class ShaderGraph;
533 };
534 
536 
537 #endif
ShaderOutput * _connection
Definition: ShaderNode.h:291
const ScopeInfo & getScopeInfo() const
Return the scope info for this node.
Definition: ShaderNode.h:453
const ShaderGraph * _parent
Definition: ShaderNode.h:518
Flags for classifying nodes into different categories.
Definition: ShaderNode.h:329
shared_ptr< class ShaderInput > ShaderInputPtr
Shared pointer to a ShaderInput.
Definition: ShaderNode.h:31
const ShaderOutput * getConnection() const
Definition: ShaderNode.h:272
const string & getColorSpace() const
Return the source color space for the value on this port.
Definition: ShaderNode.h:178
ShaderPortPtr getSelf()
Return a shared pointer instance of this object.
Definition: ShaderNode.h:130
short * getInput(int size) override
static const string TRANSFORM_POINT
Definition: ShaderNode.h:397
const ShaderNodeImpl & getImplementation() const
Return the implementation used for this node.
Definition: ShaderNode.h:441
static const string USER_DATA_NAME
Definition: ShaderNode.h:61
const string & getName() const
Return the name of this port.
Definition: ShaderNode.h:151
vector< ShaderInput * > _inputOrder
Definition: ShaderNode.h:523
static const string TRANSFORM_NORMAL
Definition: ShaderNode.h:399
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: Library.h:40
bool usedByBranch(int branchIndex) const
Definition: ShaderNode.h:380
std::unordered_map< string, size_t > _entryIndex
Definition: ShaderNode.h:106
ValuePtr _value
Definition: ShaderNode.h:251
string _path
Definition: ShaderNode.h:248
void setColorSpace(const string &colorspace)
Set a source color space for the value on this port.
Definition: ShaderNode.h:175
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:23
const ShaderMetadata * findMetadata(const string &name) const
Definition: ShaderNode.h:77
std::unordered_map< string, ShaderInputPtr > _inputMap
Definition: ShaderNode.h:522
ShaderMetadataVecPtr _metadata
Definition: ShaderNode.h:529
ShaderOutput * getOutput(size_t index=0)
Definition: ShaderNode.h:475
Definition: Node.h:52
string _name
Definition: ShaderNode.h:519
const ShaderMetadataVec & getAllMetadata() const
Return all entries in the registry.
Definition: ShaderNode.h:92
const ShaderInput * getInput(size_t index) const
Definition: ShaderNode.h:476
const ShaderOutput * getOutput(size_t index=0) const
Definition: ShaderNode.h:477
ShaderInput * getInput(size_t index)
Get inputs/outputs by index.
Definition: ShaderNode.h:474
void setBindInput()
Set the bind input state on this port to true.
Definition: ShaderNode.h:230
const GLfloat * c
Definition: glew.h:16631
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
GLenum GLenum GLenum input
Definition: glew.h:14162
static const string IMAGE
Definition: ShaderNode.h:391
ScopeInfo _scopeInfo
Definition: ShaderNode.h:530
const ShaderGraph * getParent() const
Definition: ShaderNode.h:423
vector< ShaderOutput * > _outputOrder
Definition: ShaderNode.h:526
MX_GENSHADER_API const TypeDesc * BSDF
bool hasClassification(uint32_t c) const
Return true if this node matches the given classification.
Definition: ShaderNode.h:429
virtual bool isAGraph() const
Return true if this node is a graph.
Definition: ShaderNode.h:418
size_t numOutputs() const
Definition: ShaderNode.h:471
void setMetadata(ShaderMetadataVecPtr metadata)
Set the metadata vector.
Definition: ShaderNode.h:490
void setUniform()
Set the uniform flag this port to true.
Definition: ShaderNode.h:218
static const string PROCEDURAL3D_GROUPNAME
Definition: ShaderNode.h:403
Metadata to be exported to generated shader.
Definition: ShaderNode.h:41
void setFlag(uint32_t flag, bool value)
Set the on|off state of a given flag.
Definition: ShaderNode.h:206
#define MX_GENSHADER_API
Definition: Export.h:18
const TypeDesc * _type
Definition: ShaderNode.h:246
GLuint const GLchar * name
Definition: glcorearb.h:786
string _variable
Definition: ShaderNode.h:250
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:212
GLenum src
Definition: glcorearb.h:1793
static const string TRANSFORM_VECTOR
Definition: ShaderNode.h:398
bool isEditable(const ShaderGraphInputSocket &input) const
Definition: ShaderNode.h:509
GLdouble GLdouble t
Definition: glew.h:1403
uint32_t conditionBitmask
Definition: ShaderNode.h:384
ShaderNode * _node
Definition: ShaderNode.h:245
bool isUniform() const
Return the uniform flag on this port.
Definition: ShaderNode.h:221
ShaderMetadataVecPtr getMetadata()
Get the metadata vector.
Definition: ShaderNode.h:493
const string & getPath() const
Return the path to this port.
Definition: ShaderNode.h:197
vector< ShaderInput * > ShaderInputVec
A vector of ShaderInput pointers.
Definition: ShaderNode.h:37
string _name
Definition: ShaderNode.h:247
ShaderMetadata(const string &n, const TypeDesc *t, ValuePtr v=nullptr)
Definition: ShaderNode.h:46
void setName(const string &name)
Set the name of this port.
Definition: ShaderNode.h:148
void setType(const TypeDesc *type)
Set the data type for this port.
Definition: ShaderNode.h:142
const vector< ShaderInput * > & getInputs() const
Get vector of inputs/outputs.
Definition: ShaderNode.h:486
vector< ShaderMetadata > ShaderMetadataVec
Definition: ShaderNode.h:52
static const uint32_t BIND_INPUT
Definition: ShaderNode.h:118
static const uint32_t UNIFORM
Definition: ShaderNode.h:116
const ShaderMetadataVecPtr & getMetadata() const
Get the metadata vector.
Definition: ShaderNode.h:242
void addMetadata(const string &name, const TypeDesc *type, ValuePtr value=nullptr)
Definition: ShaderNode.h:66
const TypeDesc * type
Definition: ShaderNode.h:44
ShaderNodeImplPtr _impl
Definition: ShaderNode.h:528
ShaderMetadata * findMetadata(const string &name)
Definition: ShaderNode.h:85
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
Definition: ShaderNode.h:35
const ShaderInputVec & getConnections() const
Definition: ShaderNode.h:305
void setGeomProp(const string &geomprop)
Definition: ShaderNode.h:188
static const string TEXTURE2D_GROUPNAME
Definition: ShaderNode.h:400
MX_GENSHADER_API const TypeDesc * VDF
static const string PROCEDURAL2D_GROUPNAME
Definition: ShaderNode.h:402
const GLdouble * v
Definition: glcorearb.h:837
ShaderNode * conditionalNode
Definition: ShaderNode.h:383
static const string BSDF_R
Definition: ShaderNode.h:395
void setEmitted()
Set the emitted state on this port to true.
Definition: ShaderNode.h:224
const string & getChannels() const
Get optional channels value.
Definition: ShaderNode.h:284
void setPath(const string &path)
Set the path to this port.
Definition: ShaderNode.h:194
static const uint32_t EMITTED
Definition: ShaderNode.h:117
void setMetadata(ShaderMetadataVecPtr metadata)
Set the metadata vector.
Definition: ShaderNode.h:236
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:166
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:396
void setFlags(uint32_t flags)
Set flags on this port.
Definition: ShaderNode.h:200
uint32_t _classification
Definition: ShaderNode.h:520
GLbitfield flags
Definition: glcorearb.h:1596
ShaderInputVec _connections
Definition: ShaderNode.h:317
shared_ptr< ShaderMetadataRegistry > ShaderMetadataRegistryPtr
Definition: ShaderNode.h:109
ValuePtr value
Definition: ShaderNode.h:45
shared_ptr< ShaderMetadataVec > ShaderMetadataVecPtr
Definition: ShaderNode.h:53
Flags set on shader ports.
Definition: ShaderNode.h:113
GLdouble n
Definition: glcorearb.h:2008
static const string SWITCH
Definition: ShaderNode.h:393
void clear()
Clear all entries in the registry.
Definition: ShaderNode.h:98
string _semantic
Definition: ShaderNode.h:249
shared_ptr< class ShaderOutput > ShaderOutputPtr
Shared pointer to a ShaderOutput.
Definition: ShaderNode.h:33
const vector< ShaderOutput * > & getOutputs() const
Definition: ShaderNode.h:487
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:256
void setVariable(const string &name)
Set the variable name of this port.
Definition: ShaderNode.h:157
string _colorspace
Definition: ShaderNode.h:253
GLuint index
Definition: glcorearb.h:786
std::unordered_map< string, ShaderOutputPtr > _outputMap
Definition: ShaderNode.h:525
static const string TEXTURE3D_GROUPNAME
Definition: ShaderNode.h:401
string _unit
Definition: ShaderNode.h:252
ShaderMetadataVecPtr getMetadata()
Get the metadata vector.
Definition: ShaderNode.h:239
shared_ptr< class ShaderPort > ShaderPortPtr
Shared pointer to a ShaderPort.
Definition: ShaderNode.h:29
static const string SCATTER_MODE
Definition: ShaderNode.h:394
virtual ~ShaderNode()
Definition: ShaderNode.h:326
static const string COMPARE
Definition: ShaderNode.h:392
MX_GENSHADER_API const TypeDesc * EDF
GLsizei const GLfloat * value
Definition: glcorearb.h:824
static const string CONSTANT
Definition: ShaderNode.h:390
const string & getGeomProp() const
Get geomprop name.
Definition: ShaderNode.h:191
ShaderMetadataVecPtr _metadata
Definition: ShaderNode.h:255
ValuePtr getValue() const
Return the value set on this port.
Definition: ShaderNode.h:172
const ShaderMetadataVecPtr & getMetadata() const
Get the metadata vector.
Definition: ShaderNode.h:496
Definition: core.h:1131
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:24
void setChannels(const string &channels)
Set optional channels value.
Definition: ShaderNode.h:281
uint32_t getFlags() const
Return flags set on this port.
Definition: ShaderNode.h:203
size_t numInputs() const
Get number of inputs/outputs.
Definition: ShaderNode.h:470
bool isEmitted() const
Return the emitted state of this port.
Definition: ShaderNode.h:227
const TypeDesc * getType() const
Return the data type for this port.
Definition: ShaderNode.h:145
void setSemantic(const string &semantic)
Set the variable semantic of this port.
Definition: ShaderNode.h:163
string _geomprop
Definition: ShaderNode.h:254
type
Definition: core.h:1059
bool isEditable(const ShaderInput &input) const
Definition: ShaderNode.h:501
GLenum GLenum dst
Definition: glcorearb.h:1793
uint32_t fullConditionMask
Definition: ShaderNode.h:385
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:29
static const ShaderNodePtr NONE
Definition: ShaderNode.h:388
void setValue(ValuePtr value)
Set a value on this port.
Definition: ShaderNode.h:169
string _channels
Definition: ShaderNode.h:292
const string & getName() const
Return the name of this node.
Definition: ShaderNode.h:435
const string & getUnit() const
Return the unit type for the value on this port.
Definition: ShaderNode.h:184
ScopeInfo & getScopeInfo()
Return the scope info for this node.
Definition: ShaderNode.h:447
void setUnit(const string &unit)
Set a unit type for the value on this port.
Definition: ShaderNode.h:181
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.
Definition: ShaderNode.h:233
ShaderOutput * getConnection()
Definition: ShaderNode.h:268