summaryrefslogtreecommitdiff
path: root/doc/classes/VisualShaderNodeCustom.xml
blob: ee751a894be6bdbc33bf516e0e6c2aeadcf62e3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualShaderNodeCustom" inherits="VisualShaderNode" version="3.2">
	<brief_description>
		Virtual class to define custom [VisualShaderNode]s for use in the Visual Shader Editor.
	</brief_description>
	<description>
		By inheriting this class you can create a custom [VisualShader] script addon which will be automatically added to the Visual Shader Editor. The [VisualShaderNode]'s behavior is defined by overriding the provided virtual methods.
		In order for the node to be registered as an editor addon, you must use the [code]tool[/code] keyword and provide a [code]class_name[/code] for your custom script. For example:
		[codeblock]
		tool
		extends VisualShaderNodeCustom
		class_name VisualShaderNodeNoise
		[/codeblock]
	</description>
	<tutorials>
		<link>http://docs.godotengine.org/en/latest/tutorials/plugins/editor/visual_shader_plugins.html</link>
	</tutorials>
	<methods>
		<method name="_get_category" qualifiers="virtual">
			<return type="String">
			</return>
			<description>
				Override this method to define the category of the associated custom node in the Visual Shader Editor's members dialog.
				Defining this method is [b]optional[/b]. If not overridden, the node will be filed under the "Custom" category.
			</description>
		</method>
		<method name="_get_code" qualifiers="virtual">
			<return type="String">
			</return>
			<argument index="0" name="input_vars" type="Array">
			</argument>
			<argument index="1" name="output_vars" type="Array">
			</argument>
			<argument index="2" name="mode" type="int">
			</argument>
			<argument index="3" name="type" type="int">
			</argument>
			<description>
				Override this method to define the actual shader code of the associated custom node. The shader code should be returned as a string, which can have multiple lines (the [code]"""[/code] multiline string construct can be used for convenience).
				The [code]input_vars[/code] and [code]output_vars[/code] arrays contain the string names of the various input and output variables, as defined by [code]_get_input_*[/code] and [code]_get_output_*[/code] virtual methods in this class.
				The output ports can be assigned values in the shader code. For example, [code]return output_vars[0] + " = " + input_vars[0] + ";"[/code].
				You can customize the generated code based on the shader [code]mode[/code] (see [enum Shader.Mode]) and/or [code]type[/code] (see [enum VisualShader.Type]).
				Defining this method is [b]required[/b].
			</description>
		</method>
		<method name="_get_description" qualifiers="virtual">
			<return type="String">
			</return>
			<description>
				Override this method to define the description of the associated custom node in the Visual Shader Editor's members dialog.
				Defining this method is [b]optional[/b].
			</description>
		</method>
		<method name="_get_global_code" qualifiers="virtual">
			<return type="String">
			</return>
			<argument index="0" name="mode" type="int">
			</argument>
			<description>
				Override this method to add shader code on top of the global shader, to define your own standard library of reusable methods, varyings, constants, uniforms, etc. The shader code should be returned as a string, which can have multiple lines (the [code]"""[/code] multiline string construct can be used for convenience).
				Be careful with this functionality as it can cause name conflicts with other custom nodes, so be sure to give the defined entities unique names.
				You can customize the generated code based on the shader [code]mode[/code] (see [enum Shader.Mode]).
				Defining this method is [b]optional[/b].
			</description>
		</method>
		<method name="_get_input_port_count" qualifiers="virtual">
			<return type="int">
			</return>
			<description>
				Override this method to define the amount of input ports of the associated custom node.
				Defining this method is [b]required[/b]. If not overridden, the node has no input ports.
			</description>
		</method>
		<method name="_get_input_port_name" qualifiers="virtual">
			<return type="String">
			</return>
			<argument index="0" name="port" type="int">
			</argument>
			<description>
				Override this method to define the names of input ports of the associated custom node. The names are used both for the input slots in the editor and as identifiers in the shader code, and are passed in the [code]input_vars[/code] array in [method _get_code].
				Defining this method is [b]optional[/b], but recommended. If not overridden, input ports are named as [code]"in" + str(port)[/code].
			</description>
		</method>
		<method name="_get_input_port_type" qualifiers="virtual">
			<return type="int">
			</return>
			<argument index="0" name="port" type="int">
			</argument>
			<description>
				Override this method to define the returned type of each input port of the associated custom node (see [enum VisualShaderNode.PortType] for possible types).
				Defining this method is [b]optional[/b], but recommended. If not overridden, input ports will return the [constant VisualShaderNode.PORT_TYPE_SCALAR] type.
			</description>
		</method>
		<method name="_get_name" qualifiers="virtual">
			<return type="String">
			</return>
			<description>
				Override this method to define the name of the associated custom node in the Visual Shader Editor's members dialog and graph.
				Defining this method is [b]optional[/b], but recommended. If not overridden, the node will be named as "Unnamed".
			</description>
		</method>
		<method name="_get_output_port_count" qualifiers="virtual">
			<return type="int">
			</return>
			<description>
				Override this method to define the amount of output ports of the associated custom node.
				Defining this method is [b]required[/b]. If not overridden, the node has no output ports.
			</description>
		</method>
		<method name="_get_output_port_name" qualifiers="virtual">
			<return type="String">
			</return>
			<argument index="0" name="port" type="int">
			</argument>
			<description>
				Override this method to define the names of output ports of the associated custom node. The names are used both for the output slots in the editor and as identifiers in the shader code, and are passed in the [code]output_vars[/code] array in [method _get_code].
				Defining this method is [b]optional[/b], but recommended. If not overridden, output ports are named as [code]"out" + str(port)[/code].
			</description>
		</method>
		<method name="_get_output_port_type" qualifiers="virtual">
			<return type="int">
			</return>
			<argument index="0" name="port" type="int">
			</argument>
			<description>
				Override this method to define the returned type of each output port of the associated custom node (see [enum VisualShaderNode.PortType] for possible types).
				Defining this method is [b]optional[/b], but recommended. If not overridden, output ports will return the [constant VisualShaderNode.PORT_TYPE_SCALAR] type.
			</description>
		</method>
		<method name="_get_return_icon_type" qualifiers="virtual">
			<return type="int">
			</return>
			<description>
				Override this method to define the return icon of the associated custom node in the Visual Shader Editor's members dialog.
				Defining this method is [b]optional[/b]. If not overridden, no return icon is shown.
			</description>
		</method>
		<method name="_get_subcategory" qualifiers="virtual">
			<return type="String">
			</return>
			<description>
				Override this method to define the subcategory of the associated custom node in the Visual Shader Editor's members dialog.
				Defining this method is [b]optional[/b]. If not overridden, the node will be filed under the root of the main category (see [method _get_category]).
			</description>
		</method>
	</methods>
	<constants>
	</constants>
</class>