Table of Contents

Class VisualShader

Namespace
Godot
Assembly
GodotSharp.dll

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.

public class VisualShader : Shader, IDisposable
Inheritance
VisualShader
Implements
Inherited Members

Constructors

VisualShader()

public VisualShader()

Fields

NodeIdInvalid

Denotes invalid VisualShader node.

public const long NodeIdInvalid = -1

Field Value

long

NodeIdOutput

Denotes output node of VisualShader.

public const long NodeIdOutput = 0

Field Value

long

Properties

GraphOffset

The offset vector of the whole graph.

public Vector2 GraphOffset { get; set; }

Property Value

Vector2

Methods

AddNode(Type, VisualShaderNode, Vector2, int)

Adds the specified node to the shader.

public void AddNode(VisualShader.Type type, VisualShaderNode node, Vector2 position, int id)

Parameters

type VisualShader.Type
node VisualShaderNode
position Vector2
id int

AddVarying(string, VaryingMode, VaryingType)

Adds a new varying value node to the shader.

public void AddVarying(string name, VisualShader.VaryingMode mode, VisualShader.VaryingType type)

Parameters

name string
mode VisualShader.VaryingMode
type VisualShader.VaryingType

CanConnectNodes(Type, int, int, int, int)

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

public bool CanConnectNodes(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort)

Parameters

type VisualShader.Type
fromNode int
fromPort int
toNode int
toPort int

Returns

bool

ConnectNodes(Type, int, int, int, int)

Connects the specified nodes and ports.

public Error ConnectNodes(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort)

Parameters

type VisualShader.Type
fromNode int
fromPort int
toNode int
toPort int

Returns

Error

ConnectNodesForced(Type, 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.

public void ConnectNodesForced(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort)

Parameters

type VisualShader.Type
fromNode int
fromPort int
toNode int
toPort int

DisconnectNodes(Type, int, int, int, int)

Connects the specified nodes and ports.

public void DisconnectNodes(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort)

Parameters

type VisualShader.Type
fromNode int
fromPort int
toNode int
toPort int

GetNode(Type, int)

Returns the shader node instance with specified type and id.

public VisualShaderNode GetNode(VisualShader.Type type, int id)

Parameters

type VisualShader.Type
id int

Returns

VisualShaderNode

GetNodeConnections(Type)

Returns the list of connected nodes with the specified type.

public Array<Dictionary> GetNodeConnections(VisualShader.Type type)

Parameters

type VisualShader.Type

Returns

Array<Dictionary>

GetNodeList(Type)

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

public int[] GetNodeList(VisualShader.Type type)

Parameters

type VisualShader.Type

Returns

int[]

GetNodePosition(Type, int)

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

public Vector2 GetNodePosition(VisualShader.Type type, int id)

Parameters

type VisualShader.Type
id int

Returns

Vector2

GetValidNodeId(Type)

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

public int GetValidNodeId(VisualShader.Type type)

Parameters

type VisualShader.Type

Returns

int

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

HasVarying(string)

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

public bool HasVarying(string name)

Parameters

name string

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsNodeConnection(Type, int, int, int, int)

Returns true if the specified node and port connection exist.

public bool IsNodeConnection(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort)

Parameters

type VisualShader.Type
fromNode int
fromPort int
toNode int
toPort int

Returns

bool

RemoveNode(Type, int)

Removes the specified node from the shader.

public void RemoveNode(VisualShader.Type type, int id)

Parameters

type VisualShader.Type
id int

RemoveVarying(string)

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

public void RemoveVarying(string name)

Parameters

name string

ReplaceNode(Type, int, StringName)

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

public void ReplaceNode(VisualShader.Type type, int id, StringName newClass)

Parameters

type VisualShader.Type
id int
newClass StringName

SetMode(Mode)

Sets the mode of this shader.

public void SetMode(Shader.Mode mode)

Parameters

mode Shader.Mode

SetNodePosition(Type, int, Vector2)

Sets the position of the specified node.

public void SetNodePosition(VisualShader.Type type, int id, Vector2 position)

Parameters

type VisualShader.Type
id int
position Vector2