VisualShader
A custom shader program with a visual editor.
A custom shader program with a visual editor.
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.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
VisualShaderConstructor
public VisualShader();Properties1
GraphOffsetProperty · Deprecated
public Vector2 GraphOffset { get; set; }Deprecated.
Methods22
AddNodevoid
public void AddNode(VisualShader.Type type, VisualShaderNode node, Vector2 position, int id);Add a block resource to the selected graph stage. Use a free ID from GetValidNodeId(); ID 0 belongs to Output. Do not Dispose() a C# block while the graph uses it. In 1.0.0 this updates ports but does not write defaults from _GetInputPortDefaultValue(): assign them explicitly.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
node | VisualShaderNode | — |
position | Vector2 | — |
id | int | — |
typeThe graph stage, such as VisualShader.Type.Fragment. Node IDs and connections belong to this stage.
nodeA VisualShaderNode resource, not a game Entity.
positionThe block position in the graph editor, not image or world coordinates.
idAn unused ID in the selected stage.
AddVaryingvoid
public void AddVarying(string name, VisualShader.VaryingMode mode, VisualShader.VaryingType type);Adds a new varying value node to the shader.
| Name | Type | Default |
|---|---|---|
name | string | — |
mode | VisualShader.VaryingMode | — |
type | VisualShader.VaryingType | — |
AttachNodeToFramevoid
public void AttachNodeToFrame(VisualShader.Type type, int id, int frame);Attaches the given node to the given frame.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
id | int | — |
frame | int | — |
CanConnectNodesbool
public bool CanConnectNodes(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort);Check block and port existence, type compatibility, duplicate connections, self-connections and cycles. Use before ConnectNodes(); this check neither changes the graph nor compiles the shader.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
fromNode | int | — |
fromPort | int | — |
toNode | int | — |
toPort | int | — |
typeThe graph stage, such as VisualShader.Type.Fragment. Node IDs and connections belong to this stage.
fromNodeThe source block ID.
fromPortThe zero-based source output port index.
toNodeThe destination block ID; 0 identifies Output.
toPortThe zero-based destination input port index.
booltrue when connection preflight allows the link.
ConnectNodesError
public Error ConnectNodes(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort);Connect one block output to another block input in the same stage. Use CanConnectNodes() first, especially to prevent cycles: ConnectNodes() does not repeat every preflight check. Disconnect the old link before replacing an occupied input.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
fromNode | int | — |
fromPort | int | — |
toNode | int | — |
toPort | int | — |
typeThe graph stage, such as VisualShader.Type.Fragment. Node IDs and connections belong to this stage.
fromNodeThe source block ID.
fromPortThe zero-based source output port index.
toNodeThe destination block ID; 0 identifies Output.
toPortThe zero-based destination input port index.
ErrorError.Ok when the link is created; otherwise an error code. This is not a GPU compilation result.
ConnectNodesForcedvoid
public void ConnectNodesForced(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort);Connects the specified nodes and ports, even if they can't be connected. Such connection is invalid and will not function properly.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
fromNode | int | — |
fromPort | int | — |
toNode | int | — |
toPort | int | — |
DetachNodeFromFramevoid
public void DetachNodeFromFrame(VisualShader.Type type, int id);Detaches the given node from the frame it is attached to.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
id | int | — |
DisconnectNodesvoid
public void DisconnectNodes(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort);Remove the specified link if present. This does not remove blocks. Once disconnected, an input uses its default again when one is assigned.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
fromNode | int | — |
fromPort | int | — |
toNode | int | — |
toPort | int | — |
typeThe graph stage, such as VisualShader.Type.Fragment. Node IDs and connections belong to this stage.
fromNodeThe source block ID.
fromPortThe zero-based source output port index.
toNodeThe destination block ID; 0 identifies Output.
toPortThe zero-based destination input port index.
GetGraphOffsetVector2
public Vector2 GetGraphOffset();Vector2GetNodeVisualShaderNode
public VisualShaderNode GetNode(VisualShader.Type type, int id);Return the block resource by ID in the specified stage. A graph block is not an Entity; use VisualShaderNode methods and its retained C# type.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
id | int | — |
typeThe graph stage, such as VisualShader.Type.Fragment. Node IDs and connections belong to this stage.
idThe block ID in this stage.
VisualShaderNodeThe block resource, or null when the ID is absent.
GetNodeConnectionsReckfell.Collections.Array<Reckfell.Collections.Dictionary>
public Reckfell.Collections.Array<Reckfell.Collections.Dictionary> GetNodeConnections(VisualShader.Type type);Returns the list of connected nodes with the specified type.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
Reckfell.Collections.Array<Reckfell.Collections.Dictionary>GetNodeListint[]
public int[] GetNodeList(VisualShader.Type type);Return block IDs for one stage, including Output. This is an ID snapshot, not the resources themselves; use GetNode() to retrieve a block.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
typeThe graph stage, such as VisualShader.Type.Fragment. Node IDs and connections belong to this stage.
int[]An array of stage block IDs.
GetNodePositionVector2
public Vector2 GetNodePosition(VisualShader.Type type, int id);Returns the position of the specified node within the shader graph.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
id | int | — |
Vector2GetValidNodeIdint
public int GetValidNodeId(VisualShader.Type type);Return an available ID for a new block in the selected stage. Query immediately before AddNode(); the result does not reserve an ID and is not a stable gameplay object ID.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
typeThe graph stage, such as VisualShader.Type.Fragment. Node IDs and connections belong to this stage.
intAn available block ID.
HasVaryingbool
public bool HasVarying(string name);Returns true if the shader has a varying with the given name.
| Name | Type | Default |
|---|---|---|
name | string | — |
boolIsNodeConnectionbool
public bool IsNodeConnection(VisualShader.Type type, int fromNode, int fromPort, int toNode, int toPort);Returns true if the specified node and port connection exists.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
fromNode | int | — |
fromPort | int | — |
toNode | int | — |
toPort | int | — |
boolRemoveNodevoid
public void RemoveNode(VisualShader.Type type, int id);Remove a block and its incident connections from the selected stage. Output cannot be removed. Retained but disconnected calculation blocks are not emitted merely because they remain in the graph.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
id | int | — |
typeThe graph stage, such as VisualShader.Type.Fragment. Node IDs and connections belong to this stage.
idThe block ID to remove; not the Output ID.
RemoveVaryingvoid
public void RemoveVarying(string name);Removes a varying value node with the given name. Prints an error if a node with this name is not found.
| Name | Type | Default |
|---|---|---|
name | string | — |
ReplaceNodevoid
public void ReplaceNode(VisualShader.Type type, int id, StringName newClass);Replaces the specified node with a node of new class type.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
id | int | — |
newClass | StringName | — |
SetGraphOffsetvoid
public void SetGraphOffset(Vector2 offset);| Name | Type | Default |
|---|---|---|
offset | Vector2 | — |
SetModevoid
public void SetMode(Shader.Mode mode);Sets the mode of this shader.
| Name | Type | Default |
|---|---|---|
mode | Shader.Mode | — |
SetNodePositionvoid
public void SetNodePosition(VisualShader.Type type, int id, Vector2 position);Sets the position of the specified node.
| Name | Type | Default |
|---|---|---|
type | VisualShader.Type | — |
id | int | — |
position | Vector2 | — |
Fields and constants2
NodeIdInvalidField
public const long NodeIdInvalid = -1;Indicates an invalid VisualShader node.
NodeIdOutputField
public const long NodeIdOutput = 0;Indicates an output node of VisualShader.
VisualShader.Type
| Value | Description |
|---|---|
Collide = 5 | A function for the "collide" stage (particle collision handler) of particle shader. |
Fog = 9 | A compute shader that runs for each froxel of the volumetric fog map. |
Fragment = 1 | A fragment shader, operating on fragments (pixels). |
Light = 2 | A shader for light calculations. |
Max = 11 | Represents the size of the |
Process = 4 | A function for the "process" stage of particle shader. |
ProcessCustom = 7 | A function for the "process" stage of particle shader, with customized output. |
Sky = 8 | A shader for 3D environment's sky. |
Start = 3 | A function for the "start" stage of particle shader. |
StartCustom = 6 | A function for the "start" stage of particle shader, with customized output. |
TextureBlit = 10 | A shader used to process blit calls to a DrawableTexture. |
Vertex = 0 | A vertex shader, operating on vertices. |
VisualShader.VaryingMode
| Value | Description |
|---|---|
FragToLight = 1 | Varying is passed from |
Max = 2 | Represents the size of the |
VertexToFragLight = 0 | Varying is passed from |
VisualShader.VaryingType
| Value | Description |
|---|---|
Boolean = 6 | Varying is of type [bool]. |
Float = 0 | Varying is of type [float]. |
Int = 1 | Varying is of type [int]. |
Max = 8 | Represents the size of the |
Transform = 7 | Varying is of type |
Uint = 2 | Varying is of type unsigned [int]. |
Vector2D = 3 | Varying is of type |
Vector3D = 4 | Varying is of type |
Vector4D = 5 | Varying is of type |