Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
VisualShaderNodeCustom¶
Inherits: VisualShaderNode < Resource < RefCounted < Object
用于定义自定义 VisualShaderNode 的虚类,以便在可视化着色器编辑器中使用。
Description¶
继承这个类可以创建自定义的 VisualShader 脚本扩展,会自动加入到 Visual Shader 编辑器中。VisualShaderNode 的行为可以通过覆盖虚方法定义。
要让节点注册为编辑器扩展,你必须为你的自定义脚本使用 @tool
注解并提供 class_name
。例如:
@tool
extends VisualShaderNodeCustom
class_name VisualShaderNodeNoise
Tutorials¶
Methods¶
_get_category ( ) virtual const |
|
_get_code ( String[] input_vars, String[] output_vars, Mode mode, Type type ) virtual const |
|
_get_default_input_port ( PortType type ) virtual const |
|
_get_description ( ) virtual const |
|
_get_func_code ( Mode mode, Type type ) virtual const |
|
_get_global_code ( Mode mode ) virtual const |
|
_get_input_port_count ( ) virtual const |
|
_get_input_port_name ( int port ) virtual const |
|
_get_input_port_type ( int port ) virtual const |
|
_get_name ( ) virtual const |
|
_get_output_port_count ( ) virtual const |
|
_get_output_port_name ( int port ) virtual const |
|
_get_output_port_type ( int port ) virtual const |
|
_get_return_icon_type ( ) virtual const |
|
_is_available ( Mode mode, Type type ) virtual const |
|
_is_highend ( ) virtual const |
Method Descriptions¶
String _get_category ( ) virtual const
覆盖这个方法可以定义 Visual Shader 编辑器的成员对话框中关联的自定义节点的路径。路径类似于 "MyGame/MyFunctions/Noise"
。
定义这个方法是可选的。不覆盖时,该节点会被归在“Addons”分类下。
String _get_code ( String[] input_vars, String[] output_vars, Mode mode, Type type ) virtual const
覆盖这个方法可以定义关联的自定义节点的实际着色器代码。着色器代码应该以字符串形式返回,可以包含多行(用 """
构造多行字符串比较方便)。
input_vars
和 output_vars
数组包含各个输入和输出变量的字符串名称,这些变量由这个类的 _get_input_*
和 _get_output_*
虚方法定义。
着色器代码中可以为输出端口赋值。例如 return output_vars[0] + " = " + input_vars[0] + ";"
。
你可以根据着色器模式 mode
(见 Mode)和/或类型 type
(见 Type)自定义生成的代码。
必须定义这个方法。
int _get_default_input_port ( PortType type ) virtual const
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.
Defining this method is optional. If not overridden, the connection will be created to the first valid port.
String _get_description ( ) virtual const
覆盖这个方法可以定义可视化着色器编辑器的成员对话框中的相关自定义节点的描述。
定义这个方法是可选的。