mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
366 lines
21 KiB
ReStructuredText
366 lines
21 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. DO NOT EDIT THIS FILE!!!
|
|
.. Generated automatically from Godot engine sources.
|
|
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
|
|
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/VisualShader.xml.
|
|
|
|
.. _class_VisualShader:
|
|
|
|
VisualShader
|
|
============
|
|
|
|
**Inherits:** :ref:`Shader<class_Shader>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_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
|
|
----------
|
|
|
|
+-------------------------------+---------------------------------------------------------------+-------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`graph_offset<class_VisualShader_property_graph_offset>` | ``Vector2(0, 0)`` |
|
|
+-------------------------------+---------------------------------------------------------------+-------------------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`add_node<class_VisualShader_method_add_node>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`VisualShaderNode<class_VisualShaderNode>` node, :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` id **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`add_varying<class_VisualShader_method_add_varying>` **(** :ref:`String<class_String>` name, :ref:`VaryingMode<enum_VisualShader_VaryingMode>` mode, :ref:`VaryingType<enum_VisualShader_VaryingType>` type **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`can_connect_nodes<class_VisualShader_method_can_connect_nodes>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_int>` to_port **)** |const| |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`connect_nodes<class_VisualShader_method_connect_nodes>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_int>` to_port **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`connect_nodes_forced<class_VisualShader_method_connect_nodes_forced>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_int>` to_port **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`disconnect_nodes<class_VisualShader_method_disconnect_nodes>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_int>` to_port **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`VisualShaderNode<class_VisualShaderNode>` | :ref:`get_node<class_VisualShader_method_get_node>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const| |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Dictionary[]<class_Dictionary>` | :ref:`get_node_connections<class_VisualShader_method_get_node_connections>` **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const| |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`get_node_list<class_VisualShader_method_get_node_list>` **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const| |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`get_node_position<class_VisualShader_method_get_node_position>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const| |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_valid_node_id<class_VisualShader_method_get_valid_node_id>` **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const| |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`has_varying<class_VisualShader_method_has_varying>` **(** :ref:`String<class_String>` name **)** |const| |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_node_connection<class_VisualShader_method_is_node_connection>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_int>` to_port **)** |const| |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`remove_node<class_VisualShader_method_remove_node>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`remove_varying<class_VisualShader_method_remove_varying>` **(** :ref:`String<class_String>` name **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`replace_node<class_VisualShader_method_replace_node>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id, :ref:`StringName<class_StringName>` new_class **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_mode<class_VisualShader_method_set_mode>` **(** :ref:`Mode<enum_Shader_Mode>` mode **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_node_position<class_VisualShader_method_set_node_position>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id, :ref:`Vector2<class_Vector2>` position **)** |
|
|
+-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Enumerations
|
|
------------
|
|
|
|
.. _enum_VisualShader_Type:
|
|
|
|
.. _class_VisualShader_constant_TYPE_VERTEX:
|
|
|
|
.. _class_VisualShader_constant_TYPE_FRAGMENT:
|
|
|
|
.. _class_VisualShader_constant_TYPE_LIGHT:
|
|
|
|
.. _class_VisualShader_constant_TYPE_START:
|
|
|
|
.. _class_VisualShader_constant_TYPE_PROCESS:
|
|
|
|
.. _class_VisualShader_constant_TYPE_COLLIDE:
|
|
|
|
.. _class_VisualShader_constant_TYPE_START_CUSTOM:
|
|
|
|
.. _class_VisualShader_constant_TYPE_PROCESS_CUSTOM:
|
|
|
|
.. _class_VisualShader_constant_TYPE_SKY:
|
|
|
|
.. _class_VisualShader_constant_TYPE_FOG:
|
|
|
|
.. _class_VisualShader_constant_TYPE_MAX:
|
|
|
|
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_START** = **3**
|
|
|
|
- **TYPE_PROCESS** = **4**
|
|
|
|
- **TYPE_COLLIDE** = **5**
|
|
|
|
- **TYPE_START_CUSTOM** = **6**
|
|
|
|
- **TYPE_PROCESS_CUSTOM** = **7**
|
|
|
|
- **TYPE_SKY** = **8**
|
|
|
|
- **TYPE_FOG** = **9** --- A compute shader that runs for each froxel of the volumetric fog map.
|
|
|
|
- **TYPE_MAX** = **10** --- Represents the size of the :ref:`Type<enum_VisualShader_Type>` enum.
|
|
|
|
----
|
|
|
|
.. _enum_VisualShader_VaryingMode:
|
|
|
|
.. _class_VisualShader_constant_VARYING_MODE_VERTEX_TO_FRAG_LIGHT:
|
|
|
|
.. _class_VisualShader_constant_VARYING_MODE_FRAG_TO_LIGHT:
|
|
|
|
.. _class_VisualShader_constant_VARYING_MODE_MAX:
|
|
|
|
enum **VaryingMode**:
|
|
|
|
- **VARYING_MODE_VERTEX_TO_FRAG_LIGHT** = **0**
|
|
|
|
- **VARYING_MODE_FRAG_TO_LIGHT** = **1**
|
|
|
|
- **VARYING_MODE_MAX** = **2**
|
|
|
|
----
|
|
|
|
.. _enum_VisualShader_VaryingType:
|
|
|
|
.. _class_VisualShader_constant_VARYING_TYPE_FLOAT:
|
|
|
|
.. _class_VisualShader_constant_VARYING_TYPE_INT:
|
|
|
|
.. _class_VisualShader_constant_VARYING_TYPE_VECTOR_2D:
|
|
|
|
.. _class_VisualShader_constant_VARYING_TYPE_VECTOR_3D:
|
|
|
|
.. _class_VisualShader_constant_VARYING_TYPE_VECTOR_4D:
|
|
|
|
.. _class_VisualShader_constant_VARYING_TYPE_BOOLEAN:
|
|
|
|
.. _class_VisualShader_constant_VARYING_TYPE_TRANSFORM:
|
|
|
|
.. _class_VisualShader_constant_VARYING_TYPE_MAX:
|
|
|
|
enum **VaryingType**:
|
|
|
|
- **VARYING_TYPE_FLOAT** = **0**
|
|
|
|
- **VARYING_TYPE_INT** = **1**
|
|
|
|
- **VARYING_TYPE_VECTOR_2D** = **2**
|
|
|
|
- **VARYING_TYPE_VECTOR_3D** = **3**
|
|
|
|
- **VARYING_TYPE_VECTOR_4D** = **4**
|
|
|
|
- **VARYING_TYPE_BOOLEAN** = **5**
|
|
|
|
- **VARYING_TYPE_TRANSFORM** = **6**
|
|
|
|
- **VARYING_TYPE_MAX** = **7**
|
|
|
|
Constants
|
|
---------
|
|
|
|
.. _class_VisualShader_constant_NODE_ID_INVALID:
|
|
|
|
.. _class_VisualShader_constant_NODE_ID_OUTPUT:
|
|
|
|
- **NODE_ID_INVALID** = **-1**
|
|
|
|
- **NODE_ID_OUTPUT** = **0**
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_VisualShader_property_graph_offset:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **graph_offset**
|
|
|
|
+-----------+-------------------------+
|
|
| *Default* | ``Vector2(0, 0)`` |
|
|
+-----------+-------------------------+
|
|
| *Setter* | set_graph_offset(value) |
|
|
+-----------+-------------------------+
|
|
| *Getter* | get_graph_offset() |
|
|
+-----------+-------------------------+
|
|
|
|
The offset vector of the whole graph.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_VisualShader_method_add_node:
|
|
|
|
- void **add_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`VisualShaderNode<class_VisualShaderNode>` node, :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` id **)**
|
|
|
|
Adds the specified ``node`` to the shader.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_add_varying:
|
|
|
|
- void **add_varying** **(** :ref:`String<class_String>` name, :ref:`VaryingMode<enum_VisualShader_VaryingMode>` mode, :ref:`VaryingType<enum_VisualShader_VaryingType>` type **)**
|
|
|
|
.. container:: contribute
|
|
|
|
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_can_connect_nodes:
|
|
|
|
- :ref:`bool<class_bool>` **can_connect_nodes** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_int>` to_port **)** |const|
|
|
|
|
Returns ``true`` if the specified nodes and ports can be connected together.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_connect_nodes:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **connect_nodes** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_int>` to_port **)**
|
|
|
|
Connects the specified nodes and ports.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_connect_nodes_forced:
|
|
|
|
- void **connect_nodes_forced** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_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.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_disconnect_nodes:
|
|
|
|
- void **disconnect_nodes** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_int>` to_port **)**
|
|
|
|
Connects the specified nodes and ports.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_get_node:
|
|
|
|
- :ref:`VisualShaderNode<class_VisualShaderNode>` **get_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const|
|
|
|
|
Returns the shader node instance with specified ``type`` and ``id``.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_get_node_connections:
|
|
|
|
- :ref:`Dictionary[]<class_Dictionary>` **get_node_connections** **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const|
|
|
|
|
Returns the list of connected nodes with the specified type.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_get_node_list:
|
|
|
|
- :ref:`PackedInt32Array<class_PackedInt32Array>` **get_node_list** **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const|
|
|
|
|
Returns the list of all nodes in the shader with the specified type.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_get_node_position:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const|
|
|
|
|
Returns the position of the specified node within the shader graph.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_get_valid_node_id:
|
|
|
|
- :ref:`int<class_int>` **get_valid_node_id** **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const|
|
|
|
|
.. container:: contribute
|
|
|
|
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_has_varying:
|
|
|
|
- :ref:`bool<class_bool>` **has_varying** **(** :ref:`String<class_String>` name **)** |const|
|
|
|
|
.. container:: contribute
|
|
|
|
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_is_node_connection:
|
|
|
|
- :ref:`bool<class_bool>` **is_node_connection** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` from_node, :ref:`int<class_int>` from_port, :ref:`int<class_int>` to_node, :ref:`int<class_int>` to_port **)** |const|
|
|
|
|
Returns ``true`` if the specified node and port connection exist.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_remove_node:
|
|
|
|
- void **remove_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)**
|
|
|
|
Removes the specified node from the shader.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_remove_varying:
|
|
|
|
- void **remove_varying** **(** :ref:`String<class_String>` name **)**
|
|
|
|
.. container:: contribute
|
|
|
|
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_replace_node:
|
|
|
|
- void **replace_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id, :ref:`StringName<class_StringName>` new_class **)**
|
|
|
|
Replaces the specified node with a node of new class type.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_set_mode:
|
|
|
|
- void **set_mode** **(** :ref:`Mode<enum_Shader_Mode>` mode **)**
|
|
|
|
Sets the mode of this shader.
|
|
|
|
----
|
|
|
|
.. _class_VisualShader_method_set_node_position:
|
|
|
|
- void **set_node_position** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id, :ref:`Vector2<class_Vector2>` position **)**
|
|
|
|
Sets the position of the specified node.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
|
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
|
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|
|
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|