Debian Codegraph @

doc/classes/VisualShaderNodeCustom.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="VisualShaderNodeCustom" inherits="VisualShaderNode" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Virtual class to define custom [VisualShaderNode]s for use in the Visual Shader Editor.
5 </brief_description>
6 <description>
7 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.
8 In order for the node to be registered as an editor addon, you must use the [code]@tool[/code] annotation and provide a [code]class_name[/code] for your custom script. For example:
9 [codeblock]
10 @tool
11 extends VisualShaderNodeCustom
12 class_name VisualShaderNodeNoise
13 [/codeblock]
14 </description>
15 <tutorials>
16 <link title="Visual Shader plugins">$DOCS_URL/tutorials/plugins/editor/visual_shader_plugins.html</link>
17 </tutorials>
18 <methods>
19 <method name="_get_category" qualifiers="virtual const">
20 <return type="String" />
21 <description>
22 Override this method to define the path to the associated custom node in the Visual Shader Editor's members dialog. The path may look like [code]"MyGame/MyFunctions/Noise"[/code].
23 Defining this method is [b]optional[/b]. If not overridden, the node will be filed under the "Addons" category.
24 </description>
25 </method>
26 <method name="_get_code" qualifiers="virtual const">
27 <return type="String" />
28 <param index="0" name="input_vars" type="String[]" />
29 <param index="1" name="output_vars" type="String[]" />
30 <param index="2" name="mode" type="int" enum="Shader.Mode" />
31 <param index="3" name="type" type="int" enum="VisualShader.Type" />
32 <description>
33 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).
34 The [param input_vars] and [param output_vars] 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.
35 The output ports can be assigned values in the shader code. For example, [code]return output_vars[0] + " = " + input_vars[0] + ";"[/code].
36 You can customize the generated code based on the shader [param mode] and/or [param type].
37 Defining this method is [b]required[/b].
38 </description>
39 </method>
40 <method name="_get_default_input_port" qualifiers="virtual const">
41 <return type="int" />
42 <param index="0" name="type" type="int" enum="VisualShaderNode.PortType" />
43 <description>
44 Override this method to define the input port which should be connected by default when this node is created as a result of dragging a connection from an existing node to the empty space on the graph.
45 Defining this method is [b]optional[/b]. If not overridden, the connection will be created to the first valid port.
46 </description>
47 </method>
48 <method name="_get_description" qualifiers="virtual const">
49 <return type="String" />
50 <description>
51 Override this method to define the description of the associated custom node in the Visual Shader Editor's members dialog.
52 Defining this method is [b]optional[/b].
53 </description>
54 </method>
55 <method name="_get_func_code" qualifiers="virtual const">
56 <return type="String" />
57 <param index="0" name="mode" type="int" enum="Shader.Mode" />
58 <param index="1" name="type" type="int" enum="VisualShader.Type" />
59 <description>
60 Override this method to add a shader code to the beginning of each shader function (once). 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).
61 If there are multiple custom nodes of different types which use this feature the order of each insertion is undefined.
62 You can customize the generated code based on the shader [param mode] and/or [param type].
63 Defining this method is [b]optional[/b].
64 </description>
65 </method>
66 <method name="_get_global_code" qualifiers="virtual const">
67 <return type="String" />
68 <param index="0" name="mode" type="int" enum="Shader.Mode" />
69 <description>
70 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).
71 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.
72 You can customize the generated code based on the shader [param mode].
73 Defining this method is [b]optional[/b].
74 </description>
75 </method>
76 <method name="_get_input_port_count" qualifiers="virtual const">
77 <return type="int" />
78 <description>
79 Override this method to define the number of input ports of the associated custom node.
80 Defining this method is [b]required[/b]. If not overridden, the node has no input ports.
81 </description>
82 </method>
83 <method name="_get_input_port_default_value" qualifiers="virtual const">
84 <return type="Variant" />
85 <param index="0" name="port" type="int" />
86 <description>
87 Override this method to define the default value for the specified input port. Prefer use this over [method VisualShaderNode.set_input_port_default_value].
88 Defining this method is [b]required[/b]. If not overridden, the node has no default values for their input ports.
89 </description>
90 </method>
91 <method name="_get_input_port_name" qualifiers="virtual const">
92 <return type="String" />
93 <param index="0" name="port" type="int" />
94 <description>
95 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].
96 Defining this method is [b]optional[/b], but recommended. If not overridden, input ports are named as [code]"in" + str(port)[/code].
97 </description>
98 </method>
99 <method name="_get_input_port_type" qualifiers="virtual const">
100 <return type="int" enum="VisualShaderNode.PortType" />
101 <param index="0" name="port" type="int" />
102 <description>
103 Override this method to define the returned type of each input port of the associated custom node.
104 Defining this method is [b]optional[/b], but recommended. If not overridden, input ports will return the [constant VisualShaderNode.PORT_TYPE_SCALAR] type.
105 </description>
106 </method>
107 <method name="_get_name" qualifiers="virtual const">
108 <return type="String" />
109 <description>
110 Override this method to define the name of the associated custom node in the Visual Shader Editor's members dialog and graph.
111 Defining this method is [b]optional[/b], but recommended. If not overridden, the node will be named as "Unnamed".
112 </description>
113 </method>
114 <method name="_get_output_port_count" qualifiers="virtual const">
115 <return type="int" />
116 <description>
117 Override this method to define the number of output ports of the associated custom node.
118 Defining this method is [b]required[/b]. If not overridden, the node has no output ports.
119 </description>
120 </method>
121 <method name="_get_output_port_name" qualifiers="virtual const">
122 <return type="String" />
123 <param index="0" name="port" type="int" />
124 <description>
125 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].
126 Defining this method is [b]optional[/b], but recommended. If not overridden, output ports are named as [code]"out" + str(port)[/code].
127 </description>
128 </method>
129 <method name="_get_output_port_type" qualifiers="virtual const">
130 <return type="int" enum="VisualShaderNode.PortType" />
131 <param index="0" name="port" type="int" />
132 <description>
133 Override this method to define the returned type of each output port of the associated custom node.
134 Defining this method is [b]optional[/b], but recommended. If not overridden, output ports will return the [constant VisualShaderNode.PORT_TYPE_SCALAR] type.
135 </description>
136 </method>
137 <method name="_get_property_count" qualifiers="virtual const">
138 <return type="int" />
139 <description>
140 Override this method to define the number of the properties.
141 Defining this method is [b]optional[/b].
142 </description>
143 </method>
144 <method name="_get_property_default_index" qualifiers="virtual const">
145 <return type="int" />
146 <param index="0" name="index" type="int" />
147 <description>
148 Override this method to define the default index of the property of the associated custom node.
149 Defining this method is [b]optional[/b].
150 </description>
151 </method>
152 <method name="_get_property_name" qualifiers="virtual const">
153 <return type="String" />
154 <param index="0" name="index" type="int" />
155 <description>
156 Override this method to define the names of the property of the associated custom node.
157 Defining this method is [b]optional[/b].
158 </description>
159 </method>
160 <method name="_get_property_options" qualifiers="virtual const">
161 <return type="PackedStringArray" />
162 <param index="0" name="index" type="int" />
163 <description>
164 Override this method to define the options inside the drop-down list property of the associated custom node.
165 Defining this method is [b]optional[/b].
166 </description>
167 </method>
168 <method name="_get_return_icon_type" qualifiers="virtual const">
169 <return type="int" enum="VisualShaderNode.PortType" />
170 <description>
171 Override this method to define the return icon of the associated custom node in the Visual Shader Editor's members dialog.
172 Defining this method is [b]optional[/b]. If not overridden, no return icon is shown.
173 </description>
174 </method>
175 <method name="_is_available" qualifiers="virtual const">
176 <return type="bool" />
177 <param index="0" name="mode" type="int" enum="Shader.Mode" />
178 <param index="1" name="type" type="int" enum="VisualShader.Type" />
179 <description>
180 Override this method to prevent the node to be visible in the member dialog for the certain [param mode] and/or [param type].
181 Defining this method is [b]optional[/b]. If not overridden, it's [code]true[/code].
182 </description>
183 </method>
184 <method name="_is_highend" qualifiers="virtual const">
185 <return type="bool" />
186 <description>
187 Override this method to enable the high-end mark in the Visual Shader Editor's members dialog. This should return [code]true[/code] for nodes that only work when using the Forward+ and Mobile renderers.
188 Defining this method is [b]optional[/b]. If not overridden, it's [code]false[/code], which indicates this node works with all renderers (including Compatibility).
189 </description>
190 </method>
191 <method name="get_option_index" qualifiers="const">
192 <return type="int" />
193 <param index="0" name="option" type="int" />
194 <description>
195 Returns the selected index of the drop-down list option within a graph. You may use this function to define the specific behavior in the [method _get_code] or [method _get_global_code].
196 </description>
197 </method>
198 </methods>
199 </class>