MaterialX 1.39.4
Loading...
Searching...
No Matches
ShaderNodeImpl Class Reference

Class handling the shader generation implementation for a node. More...

#include <ShaderNodeImpl.h>

Inheritance diagram for ShaderNodeImpl:
CompoundNode HwImplementation HwTexCoordNode HwTransformNode MaterialNode NopNode SourceCodeNode LightCompoundNodeGlsl HwBitangentNode HwFrameNode HwGeomColorNode HwGeomPropValueNode HwGeomPropValueNodeAsUniform HwNormalNode HwPositionNode HwTangentNode HwTimeNode HwViewDirectionNode LightNodeGlsl LightSamplerNodeGlsl NumLightsNodeGlsl SurfaceNodeGlsl HwTransformNormalNode HwTransformVectorNode HwImageNode LightShaderNodeGlsl

Public Member Functions

virtual void initialize (const InterfaceElement &element, GenContext &context)
 Initialize with the given implementation element.
 
const string & getName () const
 Return the name of this implementation.
 
size_t getHash () const
 Return a hash for this implementation.
 
virtual void addInputs (ShaderNode &node, GenContext &context) const
 Add additional inputs on a node.
 
virtual void setValues (const Node &node, ShaderNode &shaderNode, GenContext &context) const
 Set values for additional inputs on a node.
 
virtual void addClassification (ShaderNode &node) const
 Add additional classifications on a node.
 
virtual void createVariables (const ShaderNode &node, GenContext &context, Shader &shader) const
 Create shader variables needed for the implementation of this node (e.g.
 
virtual void emitFunctionDefinition (const ShaderNode &node, GenContext &context, ShaderStage &stage) const
 Emit function definition for the given node instance.
 
virtual void emitFunctionCall (const ShaderNode &node, GenContext &context, ShaderStage &stage) const
 Emit the function call or inline source code for given node instance in the given context.
 
virtual void emitOutputVariables (const ShaderNode &node, GenContext &context, ShaderStage &stage) const
 Emit declaration and initialization of output variables to use in a function call.
 
virtual ShaderGraphgetGraph () const
 Return a pointer to the graph if this implementation is using a graph, or returns nullptr otherwise.
 
virtual bool isEditable (const ShaderInput &) const
 Returns true if an input is editable by users.
 
virtual bool isEditable (const ShaderGraphInputSocket &) const
 Returns true if a graph input is accessible by users.
 

Protected Member Functions

 ShaderNodeImpl ()
 Protected constructor.
 
bool nodeOutputIsClosure (const ShaderNode &node) const
 Returns true if the first output of the node is a closure This is used by SourceCodeNode and CompoundNode to generate the appropriate shader code.
 

Protected Attributes

string _name
 
size_t _hash
 

Detailed Description

Class handling the shader generation implementation for a node.

Responsible for emitting the function definition and function call that is the node implementation.

Member Function Documentation

◆ addClassification()

virtual void addClassification ( ShaderNode & node) const
virtual

Add additional classifications on a node.

Reimplemented in CompoundNode, and MaterialNode.

◆ addInputs()

virtual void addInputs ( ShaderNode & node,
GenContext & context ) const
virtual

Add additional inputs on a node.

Reimplemented in HwImageNode.

◆ createVariables()

virtual void createVariables ( const ShaderNode & node,
GenContext & context,
Shader & shader ) const
virtual

Create shader variables needed for the implementation of this node (e.g.

uniforms, inputs and outputs). Used if the node requires input data from the application.

Reimplemented in CompoundNode, HwBitangentNode, HwFrameNode, HwGeomColorNode, HwGeomPropValueNode, HwGeomPropValueNodeAsUniform, HwNormalNode, HwPositionNode, HwTangentNode, HwTexCoordNode, HwTimeNode, HwTransformNode, HwViewDirectionNode, LightCompoundNodeGlsl, LightNodeGlsl, LightShaderNodeGlsl, NumLightsNodeGlsl, and SurfaceNodeGlsl.

◆ emitFunctionCall()

virtual void emitFunctionCall ( const ShaderNode & node,
GenContext & context,
ShaderStage & stage ) const
virtual

◆ emitFunctionDefinition()

virtual void emitFunctionDefinition ( const ShaderNode & node,
GenContext & context,
ShaderStage & stage ) const
virtual

Emit function definition for the given node instance.

Reimplemented in CompoundNode, LightCompoundNodeGlsl, LightSamplerNodeGlsl, NumLightsNodeGlsl, and SourceCodeNode.

◆ getGraph()

virtual ShaderGraph * getGraph ( ) const
virtual

Return a pointer to the graph if this implementation is using a graph, or returns nullptr otherwise.

Reimplemented in CompoundNode.

◆ getHash()

size_t getHash ( ) const
inline

Return a hash for this implementation.

The hash should correspond to the function signature generated for the node, and can be used to compare implementations, e.g. to query if an identical function has already been emitted during shader generation.

◆ initialize()

virtual void initialize ( const InterfaceElement & element,
GenContext & context )
virtual

Initialize with the given implementation element.

Initialization must set the name and hash for the implementation, as well as any other data needed to emit code for the node.

Reimplemented in CompoundNode, LightCompoundNodeGlsl, LightShaderNodeGlsl, and SourceCodeNode.

◆ isEditable() [1/2]

virtual bool isEditable ( const ShaderGraphInputSocket & ) const
inlinevirtual

Returns true if a graph input is accessible by users.

Accessible inputs are allowed to be published as shader uniforms and hence must be presentable in a user interface. By default all graph inputs are considered to be accessible.

◆ isEditable() [2/2]

virtual bool isEditable ( const ShaderInput & ) const
inlinevirtual

Returns true if an input is editable by users.

Editable inputs are allowed to be published as shader uniforms and hence must be presentable in a user interface. By default all inputs are considered to be editable.

Reimplemented in HwGeomPropValueNode, and HwImplementation.

◆ setValues()

virtual void setValues ( const Node & node,
ShaderNode & shaderNode,
GenContext & context ) const
virtual

Set values for additional inputs on a node.

Reimplemented in HwImageNode.


The documentation for this class was generated from the following file: