VisualShader

Inherits: Shader < Resource < Reference < Object

A custom shader program with a visual editor.

Description

This class allows you to define a custom shader program that can be used for various materials to render objects.

The visual shader editor creates the shader.

Properties

Vector2graph_offsetVector2( 0, 0 )

Methods

voidadd_node ( Type type, VisualShaderNode node, Vector2 position, int id )
boolcan_connect_nodes ( Type type, int from_node, int from_port, int to_node, int to_port ) const
Errorconnect_nodes ( Type type, int from_node, int from_port, int to_node, int to_port )
voidconnect_nodes_forced ( Type type, int from_node, int from_port, int to_node, int to_port )
voiddisconnect_nodes ( Type type, int from_node, int from_port, int to_node, int to_port )
VisualShaderNodeget_node ( Type type, int id ) const
Arrayget_node_connections ( Type type ) const
PoolIntArrayget_node_list ( Type type ) const
Vector2get_node_position ( Type type, int id ) const
intget_valid_node_id ( Type type ) const
boolis_node_connection ( Type type, int from_node, int from_port, int to_node, int to_port ) const
voidremove_node ( Type type, int id )
voidset_mode ( Mode mode )
voidset_node_position ( Type type, int id, Vector2 position )

Enumerations

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_MAX = 3 —- Represents the size of the Type enum.

Constants

  • NODE_ID_INVALID = -1
  • NODE_ID_OUTPUT = 0

Property Descriptions

DefaultVector2( 0, 0 )
Setterset_graph_offset(value)
Getterget_graph_offset()

The offset vector of the whole graph.

Method Descriptions

Adds the specified node to the shader.


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


Connects the specified nodes and ports.


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

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


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

Connects the specified nodes and ports.


Returns the shader node instance with specified type and id.


  • Array get_node_connections ( Type type ) const

Returns the list of connected nodes with the specified type.


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


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


  • int get_valid_node_id ( Type type ) const

  • bool is_node_connection ( Type type, int from_node, int from_port, int to_node, int to_port ) const

Returns true if the specified node and port connection exist.


  • void remove_node ( Type type, int id )

Removes the specified node from the shader.


  • void set_mode ( Mode mode )

Sets the mode of this shader.


Sets the position of the specified node.