MaterialX 1.38.10
Loading...
Searching...
No Matches
ShaderNodeImpl.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_SHADERNODEIMPL_H
7#define MATERIALX_SHADERNODEIMPL_H
8
11
13
15#include <MaterialXCore/Util.h>
16
17MATERIALX_NAMESPACE_BEGIN
18
20class Node;
22
24using ShaderNodeImplPtr = shared_ptr<class ShaderNodeImpl>;
25
30class MX_GENSHADER_API ShaderNodeImpl
31{
32 public:
33 virtual ~ShaderNodeImpl() { }
34
39 virtual const string& getTarget() const { return EMPTY_STRING; }
40
44 virtual void initialize(const InterfaceElement& element, GenContext& context);
45
47 const string& getName() const
48 {
49 return _name;
50 }
51
56 size_t getHash() const
57 {
58 return _hash;
59 }
60
62 virtual void addInputs(ShaderNode& node, GenContext& context) const;
63
65 virtual void setValues(const Node& node, ShaderNode& shaderNode, GenContext& context) const;
66
68 virtual void addClassification(ShaderNode& node) const;
69
72 virtual void createVariables(const ShaderNode& node, GenContext& context, Shader& shader) const;
73
75 virtual void emitFunctionDefinition(const ShaderNode& node, GenContext& context, ShaderStage& stage) const;
76
78 virtual void emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const;
79
81 virtual void emitOutputVariables(const ShaderNode& node, GenContext& context, ShaderStage& stage) const;
82
85 virtual ShaderGraph* getGraph() const;
86
91 virtual bool isEditable(const ShaderInput& /*input*/) const
92 {
93 return true;
94 }
95
100 virtual bool isEditable(const ShaderGraphInputSocket& /*input*/) const
101 {
102 return true;
103 }
104
105 protected:
108
109 protected:
110 string _name;
111 size_t _hash;
112};
113
115class MX_GENSHADER_API NopNode : public ShaderNodeImpl
116{
117 public:
118 static ShaderNodeImplPtr create();
119};
120
121MATERIALX_NAMESPACE_END
122
123#endif
Utility methods.
Macros for declaring imported and exported symbols.
Library-wide includes and types.
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: Library.h:40
shared_ptr< class ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: ShaderNodeImpl.h:24
A context class for shader generation.
Definition: GenContext.h:31
The base class for interface elements such as Node, NodeDef, and NodeGraph.
Definition: Interface.h:318
A node element within a NodeGraph or Document.
Definition: Node.h:53
A no operation node, to be used for organizational nodes that has no code to execute.
Definition: ShaderNodeImpl.h:116
Class representing a graph (DAG) for shader generation.
Definition: ShaderGraph.h:44
Class containing all data needed during shader generation.
Definition: Shader.h:33
An input on a ShaderNode.
Definition: ShaderNode.h:264
Class representing a node in the shader generation DAG.
Definition: ShaderNode.h:326
Class handling the shader generation implementation for a node.
Definition: ShaderNodeImpl.h:31
virtual bool isEditable(const ShaderInput &) const
Returns true if an input is editable by users.
Definition: ShaderNodeImpl.h:91
virtual bool isEditable(const ShaderGraphInputSocket &) const
Returns true if a graph input is accessible by users.
Definition: ShaderNodeImpl.h:100
const string & getName() const
Return the name of this implementation.
Definition: ShaderNodeImpl.h:47
virtual const string & getTarget() const
Return an identifier for the target used by this implementation.
Definition: ShaderNodeImpl.h:39
size_t getHash() const
Return a hash for this implementation.
Definition: ShaderNodeImpl.h:56
An output on a ShaderNode.
Definition: ShaderNode.h:301
A shader stage, containing the state and resulting source code for the stage.
Definition: ShaderStage.h:139