class_visualshader.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/VisualShader.xml.
  6. .. _class_VisualShader:
  7. VisualShader
  8. ============
  9. **Inherits:** :ref:`Shader<class_Shader>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. A custom shader program with a visual editor.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This class allows you to define a custom shader program that can be used for various materials to render objects.
  15. The visual shader editor creates the shader.
  16. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +-------------------------------+---------------------------------------------------------------+---------------------+
  22. | :ref:`Vector2<class_Vector2>` | :ref:`graph_offset<class_VisualShader_property_graph_offset>` | ``Vector2( 0, 0 )`` |
  23. +-------------------------------+---------------------------------------------------------------+---------------------+
  24. .. rst-class:: classref-reftable-group
  25. Methods
  26. -------
  27. .. table::
  28. :widths: auto
  29. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | 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 **)** |
  31. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :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| |
  33. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :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 **)** |
  35. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | 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 **)** |
  37. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | 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 **)** |
  39. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`VisualShaderNode<class_VisualShaderNode>` | :ref:`get_node<class_VisualShader_method_get_node>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const| |
  41. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Array<class_Array>` | :ref:`get_node_connections<class_VisualShader_method_get_node_connections>` **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const| |
  43. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`PoolIntArray<class_PoolIntArray>` | :ref:`get_node_list<class_VisualShader_method_get_node_list>` **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const| |
  45. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :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| |
  47. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`get_valid_node_id<class_VisualShader_method_get_valid_node_id>` **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const| |
  49. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :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| |
  51. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`remove_node<class_VisualShader_method_remove_node>` **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |
  53. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_mode<class_VisualShader_method_set_mode>` **(** :ref:`Mode<enum_Shader_Mode>` mode **)** |
  55. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | 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 **)** |
  57. +-------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. .. rst-class:: classref-section-separator
  59. ----
  60. .. rst-class:: classref-descriptions-group
  61. Enumerations
  62. ------------
  63. .. _enum_VisualShader_Type:
  64. .. rst-class:: classref-enumeration
  65. enum **Type**:
  66. .. _class_VisualShader_constant_TYPE_VERTEX:
  67. .. rst-class:: classref-enumeration-constant
  68. :ref:`Type<enum_VisualShader_Type>` **TYPE_VERTEX** = ``0``
  69. A vertex shader, operating on vertices.
  70. .. _class_VisualShader_constant_TYPE_FRAGMENT:
  71. .. rst-class:: classref-enumeration-constant
  72. :ref:`Type<enum_VisualShader_Type>` **TYPE_FRAGMENT** = ``1``
  73. A fragment shader, operating on fragments (pixels).
  74. .. _class_VisualShader_constant_TYPE_LIGHT:
  75. .. rst-class:: classref-enumeration-constant
  76. :ref:`Type<enum_VisualShader_Type>` **TYPE_LIGHT** = ``2``
  77. A shader for light calculations.
  78. .. _class_VisualShader_constant_TYPE_MAX:
  79. .. rst-class:: classref-enumeration-constant
  80. :ref:`Type<enum_VisualShader_Type>` **TYPE_MAX** = ``3``
  81. Represents the size of the :ref:`Type<enum_VisualShader_Type>` enum.
  82. .. rst-class:: classref-section-separator
  83. ----
  84. .. rst-class:: classref-descriptions-group
  85. Constants
  86. ---------
  87. .. _class_VisualShader_constant_NODE_ID_INVALID:
  88. .. rst-class:: classref-constant
  89. **NODE_ID_INVALID** = ``-1``
  90. .. _class_VisualShader_constant_NODE_ID_OUTPUT:
  91. .. rst-class:: classref-constant
  92. **NODE_ID_OUTPUT** = ``0``
  93. .. rst-class:: classref-section-separator
  94. ----
  95. .. rst-class:: classref-descriptions-group
  96. Property Descriptions
  97. ---------------------
  98. .. _class_VisualShader_property_graph_offset:
  99. .. rst-class:: classref-property
  100. :ref:`Vector2<class_Vector2>` **graph_offset** = ``Vector2( 0, 0 )``
  101. .. rst-class:: classref-property-setget
  102. - void **set_graph_offset** **(** :ref:`Vector2<class_Vector2>` value **)**
  103. - :ref:`Vector2<class_Vector2>` **get_graph_offset** **(** **)**
  104. The offset vector of the whole graph.
  105. .. rst-class:: classref-section-separator
  106. ----
  107. .. rst-class:: classref-descriptions-group
  108. Method Descriptions
  109. -------------------
  110. .. _class_VisualShader_method_add_node:
  111. .. rst-class:: classref-method
  112. void **add_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`VisualShaderNode<class_VisualShaderNode>` node, :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` id **)**
  113. Adds the specified node to the shader.
  114. .. rst-class:: classref-item-separator
  115. ----
  116. .. _class_VisualShader_method_can_connect_nodes:
  117. .. rst-class:: classref-method
  118. :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|
  119. Returns ``true`` if the specified nodes and ports can be connected together.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_VisualShader_method_connect_nodes:
  123. .. rst-class:: classref-method
  124. :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 **)**
  125. Connects the specified nodes and ports.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_VisualShader_method_connect_nodes_forced:
  129. .. rst-class:: classref-method
  130. 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 **)**
  131. Connects the specified nodes and ports, even if they can't be connected. Such connection is invalid and will not function properly.
  132. .. rst-class:: classref-item-separator
  133. ----
  134. .. _class_VisualShader_method_disconnect_nodes:
  135. .. rst-class:: classref-method
  136. 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 **)**
  137. Connects the specified nodes and ports.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_VisualShader_method_get_node:
  141. .. rst-class:: classref-method
  142. :ref:`VisualShaderNode<class_VisualShaderNode>` **get_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const|
  143. Returns the shader node instance with specified ``type`` and ``id``.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_VisualShader_method_get_node_connections:
  147. .. rst-class:: classref-method
  148. :ref:`Array<class_Array>` **get_node_connections** **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const|
  149. Returns the list of connected nodes with the specified type.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_VisualShader_method_get_node_list:
  153. .. rst-class:: classref-method
  154. :ref:`PoolIntArray<class_PoolIntArray>` **get_node_list** **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const|
  155. Returns the list of all nodes in the shader with the specified type.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_VisualShader_method_get_node_position:
  159. .. rst-class:: classref-method
  160. :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** |const|
  161. Returns the position of the specified node within the shader graph.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_VisualShader_method_get_valid_node_id:
  165. .. rst-class:: classref-method
  166. :ref:`int<class_int>` **get_valid_node_id** **(** :ref:`Type<enum_VisualShader_Type>` type **)** |const|
  167. .. container:: contribute
  168. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  169. .. rst-class:: classref-item-separator
  170. ----
  171. .. _class_VisualShader_method_is_node_connection:
  172. .. rst-class:: classref-method
  173. :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|
  174. Returns ``true`` if the specified node and port connection exist.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_VisualShader_method_remove_node:
  178. .. rst-class:: classref-method
  179. void **remove_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)**
  180. Removes the specified node from the shader.
  181. .. rst-class:: classref-item-separator
  182. ----
  183. .. _class_VisualShader_method_set_mode:
  184. .. rst-class:: classref-method
  185. void **set_mode** **(** :ref:`Mode<enum_Shader_Mode>` mode **)**
  186. Sets the mode of this shader.
  187. .. rst-class:: classref-item-separator
  188. ----
  189. .. _class_VisualShader_method_set_node_position:
  190. .. rst-class:: classref-method
  191. void **set_node_position** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id, :ref:`Vector2<class_Vector2>` position **)**
  192. Sets the position of the specified node.
  193. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  194. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  195. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  196. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`