class_visualshadernodecustom.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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/VisualShaderNodeCustom.xml.
  6. .. _class_VisualShaderNodeCustom:
  7. VisualShaderNodeCustom
  8. ======================
  9. **Inherits:** :ref:`VisualShaderNode<class_VisualShaderNode>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. Virtual class to define custom :ref:`VisualShaderNode<class_VisualShaderNode>`\ s for use in the Visual Shader Editor.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. By inheriting this class you can create a custom :ref:`VisualShader<class_VisualShader>` script addon which will be automatically added to the Visual Shader Editor. The :ref:`VisualShaderNode<class_VisualShaderNode>`'s behavior is defined by overriding the provided virtual methods.
  15. In order for the node to be registered as an editor addon, you must use the ``tool`` keyword and provide a ``class_name`` for your custom script. For example:
  16. ::
  17. tool
  18. extends VisualShaderNodeCustom
  19. class_name VisualShaderNodeNoise
  20. .. rst-class:: classref-introduction-group
  21. Tutorials
  22. ---------
  23. - :doc:`../tutorials/plugins/editor/visual_shader_plugins`
  24. .. rst-class:: classref-reftable-group
  25. Methods
  26. -------
  27. .. table::
  28. :widths: auto
  29. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`String<class_String>` | :ref:`_get_category<class_VisualShaderNodeCustom_method__get_category>` **(** **)** |virtual| |
  31. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`String<class_String>` | :ref:`_get_code<class_VisualShaderNodeCustom_method__get_code>` **(** :ref:`Array<class_Array>` input_vars, :ref:`Array<class_Array>` output_vars, :ref:`int<class_int>` mode, :ref:`int<class_int>` type **)** |virtual| |
  33. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`String<class_String>` | :ref:`_get_description<class_VisualShaderNodeCustom_method__get_description>` **(** **)** |virtual| |
  35. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`String<class_String>` | :ref:`_get_global_code<class_VisualShaderNodeCustom_method__get_global_code>` **(** :ref:`int<class_int>` mode **)** |virtual| |
  37. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`_get_input_port_count<class_VisualShaderNodeCustom_method__get_input_port_count>` **(** **)** |virtual| |
  39. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`String<class_String>` | :ref:`_get_input_port_name<class_VisualShaderNodeCustom_method__get_input_port_name>` **(** :ref:`int<class_int>` port **)** |virtual| |
  41. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`_get_input_port_type<class_VisualShaderNodeCustom_method__get_input_port_type>` **(** :ref:`int<class_int>` port **)** |virtual| |
  43. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`String<class_String>` | :ref:`_get_name<class_VisualShaderNodeCustom_method__get_name>` **(** **)** |virtual| |
  45. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`_get_output_port_count<class_VisualShaderNodeCustom_method__get_output_port_count>` **(** **)** |virtual| |
  47. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`String<class_String>` | :ref:`_get_output_port_name<class_VisualShaderNodeCustom_method__get_output_port_name>` **(** :ref:`int<class_int>` port **)** |virtual| |
  49. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`int<class_int>` | :ref:`_get_output_port_type<class_VisualShaderNodeCustom_method__get_output_port_type>` **(** :ref:`int<class_int>` port **)** |virtual| |
  51. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`int<class_int>` | :ref:`_get_return_icon_type<class_VisualShaderNodeCustom_method__get_return_icon_type>` **(** **)** |virtual| |
  53. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`String<class_String>` | :ref:`_get_subcategory<class_VisualShaderNodeCustom_method__get_subcategory>` **(** **)** |virtual| |
  55. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. .. rst-class:: classref-section-separator
  57. ----
  58. .. rst-class:: classref-descriptions-group
  59. Method Descriptions
  60. -------------------
  61. .. _class_VisualShaderNodeCustom_method__get_category:
  62. .. rst-class:: classref-method
  63. :ref:`String<class_String>` **_get_category** **(** **)** |virtual|
  64. Override this method to define the category of the associated custom node in the Visual Shader Editor's members dialog. The path may look like ``"MyGame/MyFunctions/Noise"``.
  65. Defining this method is **optional**. If not overridden, the node will be filed under the "Custom" category.
  66. .. rst-class:: classref-item-separator
  67. ----
  68. .. _class_VisualShaderNodeCustom_method__get_code:
  69. .. rst-class:: classref-method
  70. :ref:`String<class_String>` **_get_code** **(** :ref:`Array<class_Array>` input_vars, :ref:`Array<class_Array>` output_vars, :ref:`int<class_int>` mode, :ref:`int<class_int>` type **)** |virtual|
  71. Override this method to define the actual shader code of the associated custom node. The shader code should be returned as a string, which can have multiple lines (the ``"""`` multiline string construct can be used for convenience).
  72. The ``input_vars`` and ``output_vars`` arrays contain the string names of the various input and output variables, as defined by ``_get_input_*`` and ``_get_output_*`` virtual methods in this class.
  73. The output ports can be assigned values in the shader code. For example, ``return output_vars[0] + " = " + input_vars[0] + ";"``.
  74. You can customize the generated code based on the shader ``mode`` (see :ref:`Mode<enum_Shader_Mode>`) and/or ``type`` (see :ref:`Type<enum_VisualShader_Type>`).
  75. Defining this method is **required**.
  76. .. rst-class:: classref-item-separator
  77. ----
  78. .. _class_VisualShaderNodeCustom_method__get_description:
  79. .. rst-class:: classref-method
  80. :ref:`String<class_String>` **_get_description** **(** **)** |virtual|
  81. Override this method to define the description of the associated custom node in the Visual Shader Editor's members dialog.
  82. Defining this method is **optional**.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_VisualShaderNodeCustom_method__get_global_code:
  86. .. rst-class:: classref-method
  87. :ref:`String<class_String>` **_get_global_code** **(** :ref:`int<class_int>` mode **)** |virtual|
  88. Override this method to add shader code on top of the global shader, to define your own standard library of reusable methods, varyings, constants, uniforms, etc. The shader code should be returned as a string, which can have multiple lines (the ``"""`` multiline string construct can be used for convenience).
  89. Be careful with this functionality as it can cause name conflicts with other custom nodes, so be sure to give the defined entities unique names.
  90. You can customize the generated code based on the shader ``mode`` (see :ref:`Mode<enum_Shader_Mode>`).
  91. Defining this method is **optional**.
  92. .. rst-class:: classref-item-separator
  93. ----
  94. .. _class_VisualShaderNodeCustom_method__get_input_port_count:
  95. .. rst-class:: classref-method
  96. :ref:`int<class_int>` **_get_input_port_count** **(** **)** |virtual|
  97. Override this method to define the amount of input ports of the associated custom node.
  98. Defining this method is **required**. If not overridden, the node has no input ports.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_VisualShaderNodeCustom_method__get_input_port_name:
  102. .. rst-class:: classref-method
  103. :ref:`String<class_String>` **_get_input_port_name** **(** :ref:`int<class_int>` port **)** |virtual|
  104. Override this method to define the names of input ports of the associated custom node. The names are used both for the input slots in the editor and as identifiers in the shader code, and are passed in the ``input_vars`` array in :ref:`_get_code<class_VisualShaderNodeCustom_method__get_code>`.
  105. Defining this method is **optional**, but recommended. If not overridden, input ports are named as ``"in" + str(port)``.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_VisualShaderNodeCustom_method__get_input_port_type:
  109. .. rst-class:: classref-method
  110. :ref:`int<class_int>` **_get_input_port_type** **(** :ref:`int<class_int>` port **)** |virtual|
  111. Override this method to define the returned type of each input port of the associated custom node (see :ref:`PortType<enum_VisualShaderNode_PortType>` for possible types).
  112. Defining this method is **optional**, but recommended. If not overridden, input ports will return the :ref:`VisualShaderNode.PORT_TYPE_SCALAR<class_VisualShaderNode_constant_PORT_TYPE_SCALAR>` type.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_VisualShaderNodeCustom_method__get_name:
  116. .. rst-class:: classref-method
  117. :ref:`String<class_String>` **_get_name** **(** **)** |virtual|
  118. Override this method to define the name of the associated custom node in the Visual Shader Editor's members dialog and graph.
  119. Defining this method is **optional**, but recommended. If not overridden, the node will be named as "Unnamed".
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_VisualShaderNodeCustom_method__get_output_port_count:
  123. .. rst-class:: classref-method
  124. :ref:`int<class_int>` **_get_output_port_count** **(** **)** |virtual|
  125. Override this method to define the amount of output ports of the associated custom node.
  126. Defining this method is **required**. If not overridden, the node has no output ports.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_VisualShaderNodeCustom_method__get_output_port_name:
  130. .. rst-class:: classref-method
  131. :ref:`String<class_String>` **_get_output_port_name** **(** :ref:`int<class_int>` port **)** |virtual|
  132. Override this method to define the names of output ports of the associated custom node. The names are used both for the output slots in the editor and as identifiers in the shader code, and are passed in the ``output_vars`` array in :ref:`_get_code<class_VisualShaderNodeCustom_method__get_code>`.
  133. Defining this method is **optional**, but recommended. If not overridden, output ports are named as ``"out" + str(port)``.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_VisualShaderNodeCustom_method__get_output_port_type:
  137. .. rst-class:: classref-method
  138. :ref:`int<class_int>` **_get_output_port_type** **(** :ref:`int<class_int>` port **)** |virtual|
  139. Override this method to define the returned type of each output port of the associated custom node (see :ref:`PortType<enum_VisualShaderNode_PortType>` for possible types).
  140. Defining this method is **optional**, but recommended. If not overridden, output ports will return the :ref:`VisualShaderNode.PORT_TYPE_SCALAR<class_VisualShaderNode_constant_PORT_TYPE_SCALAR>` type.
  141. .. rst-class:: classref-item-separator
  142. ----
  143. .. _class_VisualShaderNodeCustom_method__get_return_icon_type:
  144. .. rst-class:: classref-method
  145. :ref:`int<class_int>` **_get_return_icon_type** **(** **)** |virtual|
  146. Override this method to define the return icon of the associated custom node in the Visual Shader Editor's members dialog.
  147. Defining this method is **optional**. If not overridden, no return icon is shown.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_VisualShaderNodeCustom_method__get_subcategory:
  151. .. rst-class:: classref-method
  152. :ref:`String<class_String>` **_get_subcategory** **(** **)** |virtual|
  153. Override this method to define the subcategory of the associated custom node in the Visual Shader Editor's members dialog.
  154. Defining this method is **optional**. If not overridden, the node will be filed under the root of the main category (see :ref:`_get_category<class_VisualShaderNodeCustom_method__get_category>`).
  155. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  156. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  157. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  158. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`