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

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

#include <ShaderNodeImpl.h>

Inheritance diagram for ShaderNodeImpl:
ClosureAddNode ClosureLayerNode ClosureMixNode ClosureMultiplyNode CompoundNode ConvolutionNode HwImplementation HwTexCoordNode HwTransformNode MaterialNode NopNode SourceCodeNode

Public Member Functions

virtual const string & getTarget () const
 Return an identifier for the target used by this implementation. More...
 
virtual void initialize (const InterfaceElement &element, GenContext &context)
 Initialize with the given implementation element. More...
 
const string & getName () const
 Return the name of this implementation.
 
size_t getHash () const
 Return a hash for this implementation. More...
 
virtual void addInputs (ShaderNode &node, GenContext &context) const
 Add additional inputs on a node. More...
 
virtual void setValues (const Node &node, ShaderNode &shaderNode, GenContext &context) const
 Set values for additional inputs on a node. More...
 
virtual void addClassification (ShaderNode &node) const
 Add additional classifications on a node. More...
 
virtual void createVariables (const ShaderNode &node, GenContext &context, Shader &shader) const
 Create shader variables needed for the implementation of this node (e.g. More...
 
virtual void emitFunctionDefinition (const ShaderNode &node, GenContext &context, ShaderStage &stage) const
 Emit function definition for the given node instance. More...
 
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. More...
 
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. More...
 
virtual bool isEditable (const ShaderInput &) const
 Returns true if an input is editable by users. More...
 
virtual bool isEditable (const ShaderGraphInputSocket &) const
 Returns true if a graph input is accessible by users. More...
 

Protected Member Functions

 ShaderNodeImpl ()
 Protected constructor.
 

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 ClosureCompoundNode, 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 HeightToNormalNodeGlsl, GeomColorNodeGlsl, GeomPropValueNodeGlsl, GeomPropValueNodeGlslAsUniform, LightCompoundNodeGlsl, LightNodeGlsl, LightShaderNodeGlsl, NumLightsNodeGlsl, SurfaceNodeGlsl, CompoundNode, ConvolutionNode, HwBitangentNode, HwFrameNode, HwNormalNode, HwPositionNode, HwTangentNode, HwTexCoordNode, HwTimeNode, HwTransformNode, and HwViewDirectionNode.

◆ emitFunctionCall()

◆ emitFunctionDefinition()

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

Emit function definition for the given node instance.

Reimplemented in HeightToNormalNodeGlsl, LightCompoundNodeGlsl, LightSamplerNodeGlsl, NumLightsNodeGlsl, BlurNode, ClosureCompoundNode, CompoundNode, 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.

◆ getTarget()

virtual const string & getTarget ( ) const
inlinevirtual

Return an identifier for the target used by this implementation.

By default an empty string is returned, representing all targets. Only override this method if your derived node implementation class is for a specific target.

Reimplemented in GlslImplementation, HeightToNormalNodeGlsl, LightCompoundNodeGlsl, and LightShaderNodeGlsl.

◆ 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 LightCompoundNodeGlsl, LightShaderNodeGlsl, CompoundNode, 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 acessible.

◆ 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 GeomPropValueNodeGlsl, 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: