class_visualshader.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the VisualShader.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_VisualShader:
  6. VisualShader
  7. ============
  8. **Inherits:** :ref:`Shader<class_Shader>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  9. A custom shader program with a visual editor.
  10. Description
  11. -----------
  12. This class allows you to define a custom shader program that can be used for various materials to render objects.
  13. The visual shader editor creates the shader.
  14. Properties
  15. ----------
  16. +-------------------------------------+-------------------------------------------------------------------+-------------------+
  17. | :ref:`Dictionary<class_Dictionary>` | :ref:`engine_version<class_VisualShader_property_engine_version>` | ``{}`` |
  18. +-------------------------------------+-------------------------------------------------------------------+-------------------+
  19. | :ref:`Vector2<class_Vector2>` | :ref:`graph_offset<class_VisualShader_property_graph_offset>` | ``Vector2(0, 0)`` |
  20. +-------------------------------------+-------------------------------------------------------------------+-------------------+
  21. Methods
  22. -------
  23. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | 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 **)** |
  25. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :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| |
  27. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :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 **)** |
  29. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | 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 **)** |
  31. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | 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 **)** |
  33. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`VisualShaderNode<class_VisualShaderNode>` | :ref:`get_node<class_VisualShader_method_get_node>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const| |
  35. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Array<class_Array>` | :ref:`get_node_connections<class_VisualShader_method_get_node_connections>` **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const| |
  37. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`get_node_list<class_VisualShader_method_get_node_list>` **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const| |
  39. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :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| |
  41. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_valid_node_id<class_VisualShader_method_get_valid_node_id>` **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const| |
  43. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :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| |
  45. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`remove_node<class_VisualShader_method_remove_node>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |
  47. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | 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 **)** |
  49. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_mode<class_VisualShader_method_set_mode>` **(** :ref:`Mode<enum_Shader_Mode>` mode **)** |
  51. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | 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 **)** |
  53. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. Enumerations
  55. ------------
  56. .. _enum_VisualShader_Type:
  57. .. _class_VisualShader_constant_TYPE_VERTEX:
  58. .. _class_VisualShader_constant_TYPE_FRAGMENT:
  59. .. _class_VisualShader_constant_TYPE_LIGHT:
  60. .. _class_VisualShader_constant_TYPE_START:
  61. .. _class_VisualShader_constant_TYPE_PROCESS:
  62. .. _class_VisualShader_constant_TYPE_COLLIDE:
  63. .. _class_VisualShader_constant_TYPE_START_CUSTOM:
  64. .. _class_VisualShader_constant_TYPE_PROCESS_CUSTOM:
  65. .. _class_VisualShader_constant_TYPE_SKY:
  66. .. _class_VisualShader_constant_TYPE_FOG:
  67. .. _class_VisualShader_constant_TYPE_MAX:
  68. enum **Type**:
  69. - **TYPE_VERTEX** = **0** --- A vertex shader, operating on vertices.
  70. - **TYPE_FRAGMENT** = **1** --- A fragment shader, operating on fragments (pixels).
  71. - **TYPE_LIGHT** = **2** --- A shader for light calculations.
  72. - **TYPE_START** = **3**
  73. - **TYPE_PROCESS** = **4**
  74. - **TYPE_COLLIDE** = **5**
  75. - **TYPE_START_CUSTOM** = **6**
  76. - **TYPE_PROCESS_CUSTOM** = **7**
  77. - **TYPE_SKY** = **8**
  78. - **TYPE_FOG** = **9** --- A compute shader that runs for each froxel of the volumetric fog map.
  79. - **TYPE_MAX** = **10** --- Represents the size of the :ref:`Type<enum_VisualShader_Type>` enum.
  80. Constants
  81. ---------
  82. .. _class_VisualShader_constant_NODE_ID_INVALID:
  83. .. _class_VisualShader_constant_NODE_ID_OUTPUT:
  84. - **NODE_ID_INVALID** = **-1**
  85. - **NODE_ID_OUTPUT** = **0**
  86. Property Descriptions
  87. ---------------------
  88. .. _class_VisualShader_property_engine_version:
  89. - :ref:`Dictionary<class_Dictionary>` **engine_version**
  90. +-----------+---------------------------+
  91. | *Default* | ``{}`` |
  92. +-----------+---------------------------+
  93. | *Setter* | set_engine_version(value) |
  94. +-----------+---------------------------+
  95. | *Getter* | get_engine_version() |
  96. +-----------+---------------------------+
  97. The Godot version this ``VisualShader`` was designed for, in the form of a :ref:`Dictionary<class_Dictionary>` with ``major`` and ``minor`` keys with integer values. Example: ``{"major": 4, "minor": 0}``
  98. This is used by the editor to convert visual shaders from older Godot versions.
  99. ----
  100. .. _class_VisualShader_property_graph_offset:
  101. - :ref:`Vector2<class_Vector2>` **graph_offset**
  102. +-----------+-------------------------+
  103. | *Default* | ``Vector2(0, 0)`` |
  104. +-----------+-------------------------+
  105. | *Setter* | set_graph_offset(value) |
  106. +-----------+-------------------------+
  107. | *Getter* | get_graph_offset() |
  108. +-----------+-------------------------+
  109. The offset vector of the whole graph.
  110. Method Descriptions
  111. -------------------
  112. .. _class_VisualShader_method_add_node:
  113. - void **add_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`VisualShaderNode<class_VisualShaderNode>` node, :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` id **)**
  114. Adds the specified node to the shader.
  115. ----
  116. .. _class_VisualShader_method_can_connect_nodes:
  117. - :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|
  118. Returns ``true`` if the specified nodes and ports can be connected together.
  119. ----
  120. .. _class_VisualShader_method_connect_nodes:
  121. - :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 **)**
  122. Connects the specified nodes and ports.
  123. ----
  124. .. _class_VisualShader_method_connect_nodes_forced:
  125. - 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 **)**
  126. Connects the specified nodes and ports, even if they can't be connected. Such connection is invalid and will not function properly.
  127. ----
  128. .. _class_VisualShader_method_disconnect_nodes:
  129. - 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 **)**
  130. Connects the specified nodes and ports.
  131. ----
  132. .. _class_VisualShader_method_get_node:
  133. - :ref:`VisualShaderNode<class_VisualShaderNode>` **get_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const|
  134. Returns the shader node instance with specified ``type`` and ``id``.
  135. ----
  136. .. _class_VisualShader_method_get_node_connections:
  137. - :ref:`Array<class_Array>` **get_node_connections** **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const|
  138. Returns the list of connected nodes with the specified type.
  139. ----
  140. .. _class_VisualShader_method_get_node_list:
  141. - :ref:`PackedInt32Array<class_PackedInt32Array>` **get_node_list** **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const|
  142. Returns the list of all nodes in the shader with the specified type.
  143. ----
  144. .. _class_VisualShader_method_get_node_position:
  145. - :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const|
  146. Returns the position of the specified node within the shader graph.
  147. ----
  148. .. _class_VisualShader_method_get_valid_node_id:
  149. - :ref:`int<class_int>` **get_valid_node_id** **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const|
  150. ----
  151. .. _class_VisualShader_method_is_node_connection:
  152. - :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|
  153. Returns ``true`` if the specified node and port connection exist.
  154. ----
  155. .. _class_VisualShader_method_remove_node:
  156. - void **remove_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)**
  157. Removes the specified node from the shader.
  158. ----
  159. .. _class_VisualShader_method_replace_node:
  160. - void **replace_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id, :ref:`StringName<class_StringName>` new_class **)**
  161. Replaces the specified node with a node of new class type.
  162. ----
  163. .. _class_VisualShader_method_set_mode:
  164. - void **set_mode** **(** :ref:`Mode<enum_Shader_Mode>` mode **)**
  165. Sets the mode of this shader.
  166. ----
  167. .. _class_VisualShader_method_set_node_position:
  168. - void **set_node_position** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id, :ref:`Vector2<class_Vector2>` position **)**
  169. Sets the position of the specified node.
  170. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  171. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  172. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  173. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  174. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  175. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`