VisualShader
继承: Shader < Resource < RefCounted < Object
A custom shader program with a visual editor.
描述
This class provides a graph-like visual editor for creating a Shader. Although VisualShader s do not require coding, they share the same logic with script shaders. They use VisualShaderNode s that can be connected to each other to control the flow of the shader. The visual shader graph is converted to a script shader behind the scenes.
属性
方法
void | add_node ( type: Type, node: VisualShaderNode, position: Vector2, id: int ) |
void | add_varying ( name: String, mode: VaryingMode, type: VaryingType ) |
void | attach_node_to_frame ( type: Type, id: int, frame: int ) |
bool | can_connect_nodes ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int ) const1 |
| Error | connect_nodes ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int ) |
void | connect_nodes_forced ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int ) |
void | detach_node_from_frame ( type: Type, id: int ) |
void | disconnect_nodes ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int ) |
VisualShaderNode | get_node ( type: Type, id: int ) const1 |
Array Dictionary | get_node_connections ( type: Type ) const1 |
PackedInt32Array | get_node_list ( type: Type ) const1 |
Vector2 | get_node_position ( type: Type, id: int ) const1 |
int | get_valid_node_id ( type: Type ) const1 |
bool | has_varying ( name: String ) const1 |
bool | is_node_connection ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int ) const1 |
void | remove_node ( type: Type, id: int ) |
void | remove_varying ( name: String ) |
void | replace_node ( type: Type, id: int, new_class: StringName ) |
void | set_mode ( mode: Mode ) |
void | set_node_position ( type: Type, id: int, position: Vector2 ) |
枚举
enum Type:
Type TYPE_VERTEX = 0
A vertex shader, operating on vertices.
Type TYPE_FRAGMENT = 1
A fragment shader, operating on fragments (pixels).
Type TYPE_LIGHT = 2
A shader for light calculations.
Type TYPE_START = 3
A function for the "start" stage of particle shader.
Type TYPE_PROCESS = 4
A function for the "process" stage of particle shader.
Type TYPE_COLLIDE = 5
A function for the "collide" stage (particle collision handler) of particle shader.
Type TYPE_START_CUSTOM = 6
A function for the "start" stage of particle shader, with customized output.
Type TYPE_PROCESS_CUSTOM = 7
A function for the "process" stage of particle shader, with customized output.
Type TYPE_SKY = 8
A shader for 3D environment's sky.
Type TYPE_FOG = 9
A compute shader that runs for each froxel of the volumetric fog map.
Type TYPE_MAX = 10
Represents the size of the Type enum.
enum VaryingMode:
VaryingMode VARYING_MODE_VERTEX_TO_FRAG_LIGHT = 0
Varying is passed from Vertex function to Fragment and Light functions.
VaryingMode VARYING_MODE_FRAG_TO_LIGHT = 1
Varying is passed from Fragment function to Light function.
VaryingMode VARYING_MODE_MAX = 2
Represents the size of the VaryingMode enum.
enum VaryingType:
VaryingType VARYING_TYPE_FLOAT = 0
Varying is of type float.
VaryingType VARYING_TYPE_INT = 1
Varying is of type int.
VaryingType VARYING_TYPE_UINT = 2
Varying is of type unsigned int.
VaryingType VARYING_TYPE_VECTOR_2D = 3
Varying is of type Vector2.
VaryingType VARYING_TYPE_VECTOR_3D = 4
Varying is of type Vector3.
VaryingType VARYING_TYPE_VECTOR_4D = 5
Varying is of type Vector4.
VaryingType VARYING_TYPE_BOOLEAN = 6
Varying is of type bool.
VaryingType VARYING_TYPE_TRANSFORM = 7
Varying is of type Transform3D.
VaryingType VARYING_TYPE_MAX = 8
Represents the size of the VaryingType enum.
常量
NODE_ID_INVALID = -1
Indicates an invalid VisualShader node.
NODE_ID_OUTPUT = 0
Indicates an output node of VisualShader.
属性说明
Vector2 graph_offset = Vector2(0, 0)
The offset vector of the whole graph.
方法说明
void add_node ( type: Type, node: VisualShaderNode, position: Vector2, id: int )
Adds the specified node to the shader.
void add_varying ( name: String, mode: VaryingMode, type: VaryingType )
Adds a new varying value node to the shader.
void attach_node_to_frame ( type: Type, id: int, frame: int )
Attaches the given node to the given frame.
bool can_connect_nodes ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int ) const1
Returns true if the specified nodes and ports can be connected together.
Error connect_nodes ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int )
Connects the specified nodes and ports.
void connect_nodes_forced ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int )
Connects the specified nodes and ports, even if they can't be connected. Such connection is invalid and will not function properly.
void detach_node_from_frame ( type: Type, id: int )
Detaches the given node from the frame it is attached to.
void disconnect_nodes ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int )
Connects the specified nodes and ports.
VisualShaderNode get_node ( type: Type, id: int ) const1
Returns the shader node instance with specified type and id.
Array Dictionary get_node_connections ( type: Type ) const1
Returns the list of connected nodes with the specified type.
PackedInt32Array get_node_list ( type: Type ) const1
Returns the list of all nodes in the shader with the specified type.
Vector2 get_node_position ( type: Type, id: int ) const1
Returns the position of the specified node within the shader graph.
int get_valid_node_id ( type: Type ) const1
Returns next valid node ID that can be added to the shader graph.
bool has_varying ( name: String ) const1
Returns true if the shader has a varying with the given name.
bool is_node_connection ( type: Type, from_node: int, from_port: int, to_node: int, to_port: int ) const1
Returns true if the specified node and port connection exist.
void remove_node ( type: Type, id: int )
Removes the specified node from the shader.
void remove_varying ( name: String )
Removes a varying value node with the given name. Prints an error if a node with this name is not found.
void replace_node ( type: Type, id: int, new_class: StringName )
Replaces the specified node with a node of new class type.
void set_mode ( mode: Mode )
Sets the mode of this shader.
void set_node_position ( type: Type, id: int, position: Vector2 )
Sets the position of the specified node.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。