Table of Contents

Class VisualShader

A custom shader program with a visual editor.

Inheritance
VisualShader

Remarks

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.

See Also

Fields

NODE_ID_INVALID

Indicates an invalid VisualShader node.

const NODE_ID_INVALID = -1

NODE_ID_OUTPUT

Indicates an output node of VisualShader.

const NODE_ID_OUTPUT = 0

Properties

graph_offset

The offset vector of the whole graph.

var graph_offset : Vector2 = Vector2(0, 0)

Property Value

Vector2

Remarks

Methods

add_node(int, VisualShaderNode, Vector2, int)

Adds the specified node to the shader.

void add_node(int type, VisualShaderNode node, Vector2 position, int id)

Parameters

type int
node VisualShaderNode
position Vector2
id int

add_varying(String, int, int)

Adds a new varying value node to the shader.

void add_varying(String name, int mode, int type)

Parameters

name String
mode int
type int

attach_node_to_frame(int, int, int)

Attaches the given node to the given frame.

void attach_node_to_frame(int type, int id, int frame)

Parameters

type int
id int
frame int

can_connect_nodes(int, int, int, int, int)

Qualifiers: const

Returns true if the specified nodes and ports can be connected together.

bool can_connect_nodes(int type, int from_node, int from_port, int to_node, int to_port)

Parameters

type int
from_node int
from_port int
to_node int
to_port int

connect_nodes(int, int, int, int, int)

Connects the specified nodes and ports.

int connect_nodes(int type, int from_node, int from_port, int to_node, int to_port)

Parameters

type int
from_node int
from_port int
to_node int
to_port int

connect_nodes_forced(int, int, int, int, int)

Connects the specified nodes and ports, even if they can't be connected. Such connection is invalid and will not function properly.

void connect_nodes_forced(int type, int from_node, int from_port, int to_node, int to_port)

Parameters

type int
from_node int
from_port int
to_node int
to_port int

detach_node_from_frame(int, int)

Detaches the given node from the frame it is attached to.

void detach_node_from_frame(int type, int id)

Parameters

type int
id int

disconnect_nodes(int, int, int, int, int)

Connects the specified nodes and ports.

void disconnect_nodes(int type, int from_node, int from_port, int to_node, int to_port)

Parameters

type int
from_node int
from_port int
to_node int
to_port int

get_node(int, int)

Qualifiers: const

Returns the shader node instance with specified type and id.

VisualShaderNode get_node(int type, int id)

Parameters

type int
id int

get_node_connections(int)

Qualifiers: const

Returns the list of connected nodes with the specified type.

Dictionary[] get_node_connections(int type)

Parameters

type int

get_node_list(int)

Qualifiers: const

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

PackedInt32Array get_node_list(int type)

Parameters

type int

get_node_position(int, int)

Qualifiers: const

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

Vector2 get_node_position(int type, int id)

Parameters

type int
id int

get_valid_node_id(int)

Qualifiers: const

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

int get_valid_node_id(int type)

Parameters

type int

has_varying(String)

Qualifiers: const

Returns true if the shader has a varying with the given name.

bool has_varying(String name)

Parameters

name String

is_node_connection(int, int, int, int, int)

Qualifiers: const

Returns true if the specified node and port connection exist.

bool is_node_connection(int type, int from_node, int from_port, int to_node, int to_port)

Parameters

type int
from_node int
from_port int
to_node int
to_port int

remove_node(int, int)

Removes the specified node from the shader.

void remove_node(int type, int id)

Parameters

type int
id int

remove_varying(String)

Removes a varying value node with the given name. Prints an error if a node with this name is not found.

void remove_varying(String name)

Parameters

name String

replace_node(int, int, StringName)

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

void replace_node(int type, int id, StringName new_class)

Parameters

type int
id int
new_class StringName

set_mode(int)

Sets the mode of this shader.

void set_mode(int mode)

Parameters

mode int

set_node_position(int, int, Vector2)

Sets the position of the specified node.

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

Parameters

type int
id int
position Vector2