MaterialX 1.38.2
ShaderNodeImpl.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_SHADERNODEIMPL_H
7#define MATERIALX_SHADERNODEIMPL_H
8
11
13
15#include <MaterialXCore/Util.h>
16
17namespace MaterialX
18{
19
20class InterfaceElement;
21class Node;
22using ShaderGraphInputSocket = ShaderOutput;
23
25using ShaderNodeImplPtr = shared_ptr<class ShaderNodeImpl>;
26
31class MX_GENSHADER_API ShaderNodeImpl
32{
33 public:
34 virtual ~ShaderNodeImpl() { }
35
40 virtual const string& getTarget() const { return EMPTY_STRING; }
41
45 virtual void initialize(const InterfaceElement& element, GenContext& context);
46
48 const string& getName() const
49 {
50 return _name;
51 }
52
57 size_t getHash() const
58 {
59 return _hash;
60 }
61
63 virtual void addInputs(ShaderNode& node, GenContext& context) const;
64
66 virtual void setValues(const Node& node, ShaderNode& shaderNode, GenContext& context) const;
67
70 virtual void createVariables(const ShaderNode& node, GenContext& context, Shader& shader) const;
71
73 virtual void emitFunctionDefinition(const ShaderNode& node, GenContext& context, ShaderStage& stage) const;
74
76 virtual void emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const;
77
80 virtual ShaderGraph* getGraph() const;
81
86 virtual bool isEditable(const ShaderInput& /*input*/) const
87 {
88 return true;
89 }
90
95 virtual bool isEditable(const ShaderGraphInputSocket& /*input*/) const
96 {
97 return true;
98 }
99
100 protected:
103
104 protected:
105 string _name;
106 size_t _hash;
107};
108
109} // namespace MaterialX
110
111#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
ShaderOutput ShaderGraphInputSocket
An internal input socket in a shader graph, used for connecting internal nodes to the outside.
Definition: ShaderGraph.h:33
A context class for shader generation.
Definition: GenContext.h:27
The base class for interface elements such as Node, NodeDef, and NodeGraph.
Definition: Interface.h:317
A node element within a NodeGraph or Document.
Definition: Node.h:54
Class representing a graph (DAG) for shader generation.
Definition: ShaderGraph.h:45
Class containing all data needed during shader generation.
Definition: Shader.h:34
An input on a ShaderNode.
Definition: ShaderNode.h:256
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:32
virtual bool isEditable(const ShaderInput &) const
Returns true if an input is editable by users.
Definition: ShaderNodeImpl.h:86
virtual bool isEditable(const ShaderGraphInputSocket &) const
Returns true if a graph input is accessible by users.
Definition: ShaderNodeImpl.h:95
const string & getName() const
Return the name of this implementation.
Definition: ShaderNodeImpl.h:48
virtual const string & getTarget() const
Return an identifier for the target used by this implementation.
Definition: ShaderNodeImpl.h:40
size_t getHash() const
Return a hash for this implementation.
Definition: ShaderNodeImpl.h:57
An output on a ShaderNode.
Definition: ShaderNode.h:289
A shader stage, containing the state and resulting source code for the stage.
Definition: ShaderStage.h:124