Index · Object → RefCounted → Resource → Shader → VisualShader

VisualShader

A custom shader program with a visual editor.

Class 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

var graph_offset: Vector2

Deprecated.

Inherited from Shader (1)
var code: String = ""
Inherited from Resource (4)

Methods

func add_node(type: VisualShader.Type, node: VisualShaderNode, position: Vector2, id: int) -> void

Adds the specified node to the shader.

func add_varying(name: String, mode: VisualShader.VaryingMode, type: VisualShader.VaryingType) -> void

Adds a new varying value node to the shader.

func attach_node_to_frame(type: VisualShader.Type, id: int, frame: int) -> void

Attaches the given node to the given frame.

func can_connect_nodes(type: VisualShader.Type, from_node: int, from_port: int, to_node: int, to_port: int) -> bool

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

func connect_nodes(type: VisualShader.Type, from_node: int, from_port: int, to_node: int, to_port: int) -> Error

Connects the specified nodes and ports.

func connect_nodes_forced(type: VisualShader.Type, from_node: int, from_port: int, to_node: int, to_port: int) -> void

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

func detach_node_from_frame(type: VisualShader.Type, id: int) -> void

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

func disconnect_nodes(type: VisualShader.Type, from_node: int, from_port: int, to_node: int, to_port: int) -> void

Connects the specified nodes and ports.

func get_node(type: VisualShader.Type, id: int) -> VisualShaderNode

Returns the shader node instance with specified type and id.

func get_node_connections(type: VisualShader.Type) -> Dictionary[]

Returns the list of connected nodes with the specified type.

func get_node_list(type: VisualShader.Type) -> PackedInt32Array

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

func get_node_position(type: VisualShader.Type, id: int) -> Vector2

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

func get_valid_node_id(type: VisualShader.Type) -> int

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

func has_varying(name: String) -> bool

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

func is_node_connection(type: VisualShader.Type, from_node: int, from_port: int, to_node: int, to_port: int) -> bool

Returns true if the specified node and port connection exist.

func remove_node(type: VisualShader.Type, id: int) -> void

Removes the specified node from the shader.

func remove_varying(name: String) -> void

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

func replace_node(type: VisualShader.Type, id: int, new_class: StringName) -> void

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

func set_mode(mode: Shader.Mode) -> void

Sets the mode of this shader.

func set_node_position(type: VisualShader.Type, id: int, position: Vector2) -> void

Sets the position of the specified node.

Inherited from Shader (5)
func get_shader_uniform_list(get_groups: bool = false) -> Array
func set_default_texture_parameter(name: StringName, texture: Texture, index: int = 0) -> void
Inherited from Resource (18)
func _get_rid() -> RID
func _reset_state() -> void
func _set_path_cache(path: String) -> void
func _setup_local_to_scene() -> void
func copy_from_resource(resource: Resource) -> Error
func duplicate(deep: bool = false) -> Resource
func duplicate_deep(deep_subresources_mode: Resource.DeepDuplicateMode = 1) -> Resource
func emit_changed() -> void
func get_rid() -> RID
func is_built_in() -> bool
func reset_state() -> void
func set_id_for_path(path: String, id: String) -> void
func set_path_cache(path: String) -> void
func setup_local_to_scene() -> void
func take_over_path(path: String) -> void
Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Resource (2)
signal changed()
Inherited from Object (2)

Enums & Constants

enum Type
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_TEXTURE_BLIT = 10

A shader used to process blit calls to a DrawableTexture.

TYPE_MAX = 11

Represents the size of the Type enum.

enum VaryingMode
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.

enum VaryingType
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.

const NODE_ID_INVALID = -1

Indicates an invalid VisualShader node.

const NODE_ID_OUTPUT = 0

Indicates an output node of VisualShader.