class_visualshader.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.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:`Reference<class_Reference>` **<** :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:`String<class_String>` | code | **O:** ``"shader_type spatial;void vertex() {// Output:0}void fragment() {// Output:0}void light() {// Output:0}"`` |
  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:`PoolIntArray<class_PoolIntArray>` | :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:`set_mode<class_VisualShader_method_set_mode>` **(** :ref:`Mode<enum_Shader_Mode>` mode **)** |
  49. +-------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | 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 **)** |
  51. +-------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. Enumerations
  53. ------------
  54. .. _enum_VisualShader_Type:
  55. .. _class_VisualShader_constant_TYPE_VERTEX:
  56. .. _class_VisualShader_constant_TYPE_FRAGMENT:
  57. .. _class_VisualShader_constant_TYPE_LIGHT:
  58. .. _class_VisualShader_constant_TYPE_MAX:
  59. enum **Type**:
  60. - **TYPE_VERTEX** = **0** --- A vertex shader, operating on vertices.
  61. - **TYPE_FRAGMENT** = **1** --- A fragment shader, operating on fragments (pixels).
  62. - **TYPE_LIGHT** = **2** --- A shader for light calculations.
  63. - **TYPE_MAX** = **3** --- Represents the size of the :ref:`Type<enum_VisualShader_Type>` enum.
  64. Constants
  65. ---------
  66. .. _class_VisualShader_constant_NODE_ID_INVALID:
  67. .. _class_VisualShader_constant_NODE_ID_OUTPUT:
  68. - **NODE_ID_INVALID** = **-1**
  69. - **NODE_ID_OUTPUT** = **0**
  70. Property Descriptions
  71. ---------------------
  72. .. _class_VisualShader_property_graph_offset:
  73. - :ref:`Vector2<class_Vector2>` **graph_offset**
  74. +-----------+-------------------------+
  75. | *Default* | ``Vector2( 0, 0 )`` |
  76. +-----------+-------------------------+
  77. | *Setter* | set_graph_offset(value) |
  78. +-----------+-------------------------+
  79. | *Getter* | get_graph_offset() |
  80. +-----------+-------------------------+
  81. The offset vector of the whole graph.
  82. Method Descriptions
  83. -------------------
  84. .. _class_VisualShader_method_add_node:
  85. - void **add_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`VisualShaderNode<class_VisualShaderNode>` node, :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` id **)**
  86. Adds the specified node to the shader.
  87. ----
  88. .. _class_VisualShader_method_can_connect_nodes:
  89. - :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
  90. Returns ``true`` if the specified nodes and ports can be connected together.
  91. ----
  92. .. _class_VisualShader_method_connect_nodes:
  93. - :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 **)**
  94. Connects the specified nodes and ports.
  95. ----
  96. .. _class_VisualShader_method_connect_nodes_forced:
  97. - 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 **)**
  98. Connects the specified nodes and ports, even if they can't be connected. Such connection is invalid and will not function properly.
  99. ----
  100. .. _class_VisualShader_method_disconnect_nodes:
  101. - 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 **)**
  102. Connects the specified nodes and ports.
  103. ----
  104. .. _class_VisualShader_method_get_node:
  105. - :ref:`VisualShaderNode<class_VisualShaderNode>` **get_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** const
  106. Returns the shader node instance with specified ``type`` and ``id``.
  107. ----
  108. .. _class_VisualShader_method_get_node_connections:
  109. - :ref:`Array<class_Array>` **get_node_connections** **(** :ref:`Type<enum_VisualShader_Type>` type **)** const
  110. Returns the list of connected nodes with the specified type.
  111. ----
  112. .. _class_VisualShader_method_get_node_list:
  113. - :ref:`PoolIntArray<class_PoolIntArray>` **get_node_list** **(** :ref:`Type<enum_VisualShader_Type>` type **)** const
  114. Returns the list of all nodes in the shader with the specified type.
  115. ----
  116. .. _class_VisualShader_method_get_node_position:
  117. - :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)** const
  118. Returns the position of the specified node within the shader graph.
  119. ----
  120. .. _class_VisualShader_method_get_valid_node_id:
  121. - :ref:`int<class_int>` **get_valid_node_id** **(** :ref:`Type<enum_VisualShader_Type>` type **)** const
  122. ----
  123. .. _class_VisualShader_method_is_node_connection:
  124. - :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
  125. Returns ``true`` if the specified node and port connection exist.
  126. ----
  127. .. _class_VisualShader_method_remove_node:
  128. - void **remove_node** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id **)**
  129. Removes the specified node from the shader.
  130. ----
  131. .. _class_VisualShader_method_set_mode:
  132. - void **set_mode** **(** :ref:`Mode<enum_Shader_Mode>` mode **)**
  133. Sets the mode of this shader.
  134. ----
  135. .. _class_VisualShader_method_set_node_position:
  136. - void **set_node_position** **(** :ref:`Type<enum_VisualShader_Type>` type, :ref:`int<class_int>` id, :ref:`Vector2<class_Vector2>` position **)**
  137. Sets the position of the specified node.