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

Deprecated.

This property does nothing and always equals to zero.

Deprecated.

Methods

void add_varying(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)

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

Returns 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)

Connects the specified nodes and ports.

void connect_nodes_forced(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)

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)

Connects the specified nodes and ports.

Dictionary[] get_node_connections(int type) const

Returns the list of connected nodes with the specified type.

PackedInt32Array get_node_list(int type) const

Returns the list of all nodes in the shader with the specified type.

Vector2 get_node_position(int type, int id) const

Returns the position of the specified node within the shader graph.

int get_valid_node_id(int type) const

Returns next valid node ID that can be added to the shader graph.

bool has_varying(String name) const

Returns 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

Returns true if the specified node and port connection exist.

void remove_node(int type, int id)

Removes the specified node from the shader.

void remove_varying(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)

Replaces the specified node with a node of new class type.

void set_mode(int mode)

Sets the mode of this shader.

void set_node_position(int type, int id, Vector2 position)

Sets the position of the specified node.

Constants

TYPE_VERTEX = 0

Enum: Type

A vertex shader, operating on vertices.

TYPE_FRAGMENT = 1

Enum: Type

A fragment shader, operating on fragments (pixels).

TYPE_LIGHT = 2

Enum: Type

A shader for light calculations.

TYPE_START = 3

Enum: Type

A function for the "start" stage of particle shader.

TYPE_PROCESS = 4

Enum: Type

A function for the "process" stage of particle shader.

TYPE_COLLIDE = 5

Enum: Type

A function for the "collide" stage (particle collision handler) of particle shader.

TYPE_START_CUSTOM = 6

Enum: Type

A function for the "start" stage of particle shader, with customized output.

TYPE_PROCESS_CUSTOM = 7

Enum: Type

A function for the "process" stage of particle shader, with customized output.

TYPE_SKY = 8

Enum: Type

A shader for 3D environment's sky.

TYPE_FOG = 9

Enum: Type

A compute shader that runs for each froxel of the volumetric fog map.

TYPE_MAX = 10

Enum: Type

Represents the size of the Type enum.

VARYING_MODE_VERTEX_TO_FRAG_LIGHT = 0

Enum: VaryingMode

Varying is passed from Vertex function to Fragment and Light functions.

VARYING_MODE_FRAG_TO_LIGHT = 1

Enum: VaryingMode

Varying is passed from Fragment function to Light function.

VARYING_MODE_MAX = 2

Enum: VaryingMode

Represents the size of the VaryingMode enum.

VARYING_TYPE_FLOAT = 0

Enum: VaryingType

Varying is of type float.

VARYING_TYPE_INT = 1

Enum: VaryingType

Varying is of type int.

VARYING_TYPE_UINT = 2

Enum: VaryingType

Varying is of type unsigned int.

VARYING_TYPE_VECTOR_2D = 3

Enum: VaryingType

Varying is of type Vector2.

VARYING_TYPE_VECTOR_3D = 4

Enum: VaryingType

Varying is of type Vector3.

VARYING_TYPE_VECTOR_4D = 5

Enum: VaryingType

Varying is of type Vector4.

VARYING_TYPE_BOOLEAN = 6

Enum: VaryingType

Varying is of type bool.

VARYING_TYPE_TRANSFORM = 7

Enum: VaryingType

Varying is of type Transform3D.

VARYING_TYPE_MAX = 8

Enum: VaryingType

Represents the size of the VaryingType enum.

Tutorials

Source revision 4f5b14abade2
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.