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
NodeIdOutput
Denotes output node of VisualShader.
public const long NodeIdOutput = 0
Field Value
Properties
GraphOffset
The offset vector of the whole graph.
public Vector2 GraphOffset { get; set; }
Property Value
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.Typenode
VisualShaderNodeposition
Vector2id
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
stringmode
VisualShader.VaryingModetype
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
Returns
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
Returns
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
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
GetNode(Type, int)
Returns the shader node instance with specified type
and id
.
public VisualShaderNode GetNode(VisualShader.Type type, int id)
Parameters
type
VisualShader.Typeid
int
Returns
GetNodeConnections(Type)
Returns the list of connected nodes with the specified type.
public Array<Dictionary> GetNodeConnections(VisualShader.Type type)
Parameters
type
VisualShader.Type
Returns
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.Typeid
int
Returns
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
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_nameName of the method to check for.
Returns
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_nameName of the signal to check for.
Returns
HasVarying(string)
Returns true
if the shader has a varying with the given name
.
public bool HasVarying(string name)
Parameters
name
string
Returns
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_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
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
Returns
RemoveNode(Type, int)
Removes the specified node from the shader.
public void RemoveNode(VisualShader.Type type, int id)
Parameters
type
VisualShader.Typeid
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.Typeid
intnewClass
StringName
SetMode(Mode)
Sets the mode of this shader.
public void SetMode(Shader.Mode mode)
Parameters
SetNodePosition(Type, int, Vector2)
Sets the position of the specified node.
public void SetNodePosition(VisualShader.Type type, int id, Vector2 position)
Parameters
type
VisualShader.Typeid
intposition
Vector2