Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

VisualShader

繼承: Shader < Resource < RefCounted < Object

帶有視覺化編輯器的自訂著色器程式。

說明

這類提供了一個類似圖形的視覺化編輯器,用於建立Shader。雖然VisualShader 不需要編碼,但它們與腳本著色器共用相同的邏輯。它們使用VisualShaderNode 可以相互連接以控制著色器的流程。視覺著色器圖在幕後轉換為腳本著色器。

教學

屬性

Vector2

graph_offset

方法

void

add_node(type: Type, node: VisualShaderNode, position: Vector2, id: int)

void

add_varying(name: String, mode: VaryingMode, type: VaryingType)

void

attach_node_to_frame(type: Type, id: int, frame: int)

bool

can_connect_nodes(type: Type, from_node: int, from_port: int, to_node: int, to_port: int) const

Error

connect_nodes(type: Type, from_node: int, from_port: int, to_node: int, to_port: int)

void

connect_nodes_forced(type: Type, from_node: int, from_port: int, to_node: int, to_port: int)

void

detach_node_from_frame(type: Type, id: int)

void

disconnect_nodes(type: Type, from_node: int, from_port: int, to_node: int, to_port: int)

VisualShaderNode

get_node(type: Type, id: int) const

Array[Dictionary]

get_node_connections(type: Type) const

PackedInt32Array

get_node_list(type: Type) const

Vector2

get_node_position(type: Type, id: int) const

int

get_valid_node_id(type: Type) const

bool

has_varying(name: String) const

bool

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

void

remove_node(type: Type, id: int)

void

remove_varying(name: String)

void

replace_node(type: Type, id: int, new_class: StringName)

void

set_mode(mode: Mode)

void

set_node_position(type: Type, id: int, position: Vector2)


列舉

enum Type: 🔗

Type TYPE_VERTEX = 0

頂點著色器,對頂點進行操作。

Type TYPE_FRAGMENT = 1

片段著色器,對片段(圖元)進行操作。

Type TYPE_LIGHT = 2

用於光線計算的著色器。

Type TYPE_START = 3

粒子著色器的“開始”階段所使用的函式。

Type TYPE_PROCESS = 4

粒子著色器的“處理”階段所使用的函式。

Type TYPE_COLLIDE = 5

粒子著色器的“碰撞”階段所使用的函式(粒子碰撞處理器)。

Type TYPE_START_CUSTOM = 6

粒子著色器的“開始”階段所使用的函式,帶自訂輸出。

Type TYPE_PROCESS_CUSTOM = 7

粒子著色器的“處理”階段所使用的函式,帶自訂輸出。

Type TYPE_SKY = 8

3D 環境中天空的著色器。

Type TYPE_FOG = 9

為體積霧貼圖的每個片段體素運作的一種計算著色器。

Type TYPE_TEXTURE_BLIT = 10

A shader used to process blit calls to a DrawableTexture.

Type TYPE_MAX = 11

代表 Type 列舉的大小。


enum VaryingMode: 🔗

VaryingMode VARYING_MODE_VERTEX_TO_FRAG_LIGHT = 0

Varying 從 Vertex 函式傳到 FragmentLight 函式。

VaryingMode VARYING_MODE_FRAG_TO_LIGHT = 1

Varying 從 Fragment 函式傳到 Light 函式。

VaryingMode VARYING_MODE_MAX = 2

代表 VaryingMode 列舉的大小。


enum VaryingType: 🔗

VaryingType VARYING_TYPE_FLOAT = 0

Varying 的型別為 float

VaryingType VARYING_TYPE_INT = 1

Varying 的型別為 int

VaryingType VARYING_TYPE_UINT = 2

Varying 的型別為無符號 int

VaryingType VARYING_TYPE_VECTOR_2D = 3

Varying 的型別為 Vector2

VaryingType VARYING_TYPE_VECTOR_3D = 4

Varying 的型別為 Vector3

VaryingType VARYING_TYPE_VECTOR_4D = 5

Varying 的型別為 Vector2

VaryingType VARYING_TYPE_BOOLEAN = 6

Varying 的型別為 bool

VaryingType VARYING_TYPE_TRANSFORM = 7

Varying 的型別為 Transform2D

VaryingType VARYING_TYPE_MAX = 8

代表 VaryingType 列舉的大小。


常數

NODE_ID_INVALID = -1 🔗

Indicates an invalid VisualShader node.

NODE_ID_OUTPUT = 0 🔗

Indicates an output node of VisualShader.


屬性說明

Vector2 graph_offset 🔗

已棄用: This property does nothing and always equals to zero.

Deprecated.


方法說明

void add_node(type: Type, node: VisualShaderNode, position: Vector2, id: int) 🔗

向著色器中新增指定的節點 node


void add_varying(name: String, mode: VaryingMode, type: VaryingType) 🔗

向著色器中新增新的 varying 值節點。


void attach_node_to_frame(type: Type, id: int, frame: int) 🔗

Attaches the given node to the given frame.


bool can_connect_nodes(type: Type, from_node: int, from_port: int, to_node: int, to_port: int) const 🔗

如果指定節點和埠可以連接在一起,則返回 true


Error connect_nodes(type: Type, from_node: int, from_port: int, to_node: int, to_port: int) 🔗

連接指定的節點和埠。


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

連接指定的節點和埠,即使它們無法連接。這樣的連接是無效的,將不能正常工作。


void detach_node_from_frame(type: Type, id: int) 🔗

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


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

連接指定的節點和埠。


VisualShaderNode get_node(type: Type, id: int) const 🔗

返回具有指定 typeid 的著色器節點實例。


Array[Dictionary] get_node_connections(type: Type) const 🔗

返回具有指定型別的連接節點的列表。


PackedInt32Array get_node_list(type: Type) const 🔗

返回著色器中具有指定型別的所有節點的列表。


Vector2 get_node_position(type: Type, id: int) const 🔗

返回指定節點在著色器圖中的位置。


int get_valid_node_id(type: Type) const 🔗

返回能夠加入到著色器圖中的下一個有效節點 ID。


bool has_varying(name: String) const 🔗

如果著色器中存在名為 name 的 varying 則返回 true


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

如果指定的節點和埠連接存在,返回 true


void remove_node(type: Type, id: int) 🔗

從著色器中刪除指定的節點。


void remove_varying(name: String) 🔗

返回名為 name 的 varying 值節點。如果不存在該名稱的節點則輸出錯誤。


void replace_node(type: Type, id: int, new_class: StringName) 🔗

將指定節點替換為新型別的節點。


void set_mode(mode: Mode) 🔗

設定該著色器的模式。


void set_node_position(type: Type, id: int, position: Vector2) 🔗

設定指定節點的位置。