Class reference
VisualShader
Inherits Shader
A custom shader program with a visual editor.
Description
This class provides a graph-like visual editor for creating a Shader. Although VisualShaders do not require coding, they share the same logic with script shaders. They use VisualShaderNodes 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.
Properties
Vector2 graph_offset
Vector2 graph_offsetThis property does nothing and always equals to zero.
Deprecated.
Methods
void add_node(int type, VisualShaderNode node, Vector2 position, int id)
int type, VisualShaderNode node, Vector2 position, int id)Adds the specified node to the shader.
void add_varying(String name, int mode, int type)
String name, int mode, int type)Adds a new varying value node to the shader.
void attach_node_to_frame(int type, int id, int frame)
int type, int id, int frame)Attaches the given node to the given frame.
bool can_connect_nodes(int type, int from_node, int from_port, int to_node, int to_port) const
bool can_connect_nodes(int type, int from_node, int from_port, int to_node, int to_port) constReturns true if the specified nodes and ports can be connected together.
int connect_nodes(int type, int from_node, int from_port, int to_node, int to_port)
int connect_nodes(int type, int from_node, int from_port, int to_node, int to_port)Connects the specified nodes and ports.
void connect_nodes_forced(int type, int from_node, int from_port, int to_node, int to_port)
int type, int from_node, int from_port, int to_node, int to_port)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(int type, int id)
int type, int id)Detaches the given node from the frame it is attached to.
void disconnect_nodes(int type, int from_node, int from_port, int to_node, int to_port)
int type, int from_node, int from_port, int to_node, int to_port)Connects the specified nodes and ports.
VisualShaderNode get_node(int type, int id) const
VisualShaderNode get_node(int type, int id) constReturns the shader node instance with specified type and id.
Dictionary[] get_node_connections(int type) const
int type) constReturns the list of connected nodes with the specified type.
PackedInt32Array get_node_list(int type) const
PackedInt32Array get_node_list(int type) constReturns the list of all nodes in the shader with the specified type.
Vector2 get_node_position(int type, int id) const
Vector2 get_node_position(int type, int id) constReturns the position of the specified node within the shader graph.
int get_valid_node_id(int type) const
int get_valid_node_id(int type) constReturns next valid node ID that can be added to the shader graph.
bool has_varying(String name) const
bool has_varying(String name) constReturns true if the shader has a varying with the given name.
bool is_node_connection(int type, int from_node, int from_port, int to_node, int to_port) const
bool is_node_connection(int type, int from_node, int from_port, int to_node, int to_port) constReturns true if the specified node and port connection exist.
void remove_node(int type, int id)
int type, int id)Removes the specified node from the shader.
void remove_varying(String name)
String name)Removes a varying value node with the given name. Prints an error if a node with this name is not found.
void replace_node(int type, int id, StringName new_class)
int type, int id, StringName new_class)Replaces the specified node with a node of new class type.
void set_mode(int mode)
int mode)Sets the mode of this shader.
void set_node_position(int type, int id, Vector2 position)
int type, int id, Vector2 position)Sets the position of the specified node.
Constants
TYPE_VERTEX = 0
A vertex shader, operating on vertices.
TYPE_FRAGMENT = 1
A fragment shader, operating on fragments (pixels).
TYPE_LIGHT = 2
A shader for light calculations.
TYPE_START = 3
A function for the "start" stage of particle shader.
TYPE_PROCESS = 4
A function for the "process" stage of particle shader.
TYPE_COLLIDE = 5
A function for the "collide" stage (particle collision handler) of particle shader.
TYPE_START_CUSTOM = 6
A function for the "start" stage of particle shader, with customized output.
TYPE_PROCESS_CUSTOM = 7
A function for the "process" stage of particle shader, with customized output.
TYPE_SKY = 8
A shader for 3D environment's sky.
TYPE_FOG = 9
A compute shader that runs for each froxel of the volumetric fog map.
TYPE_MAX = 10
Represents the size of the Type enum.
VARYING_MODE_VERTEX_TO_FRAG_LIGHT = 0
Varying is passed from Vertex function to Fragment and Light functions.
VARYING_MODE_FRAG_TO_LIGHT = 1
Varying is passed from Fragment function to Light function.
VARYING_MODE_MAX = 2
Represents the size of the VaryingMode enum.
VARYING_TYPE_FLOAT = 0
Varying is of type float.
VARYING_TYPE_INT = 1
Varying is of type int.
VARYING_TYPE_UINT = 2
Varying is of type unsigned int.
VARYING_TYPE_VECTOR_2D = 3
Varying is of type Vector2.
VARYING_TYPE_VECTOR_3D = 4
Varying is of type Vector3.
VARYING_TYPE_VECTOR_4D = 5
Varying is of type Vector4.
VARYING_TYPE_BOOLEAN = 6
Varying is of type bool.
VARYING_TYPE_TRANSFORM = 7
Varying is of type Transform3D.
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.