class_visualshadernode.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/VisualShaderNode.xml.
  6. .. _class_VisualShaderNode:
  7. VisualShaderNode
  8. ================
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`VisualShaderNodeBillboard<class_VisualShaderNodeBillboard>`, :ref:`VisualShaderNodeClamp<class_VisualShaderNodeClamp>`, :ref:`VisualShaderNodeColorFunc<class_VisualShaderNodeColorFunc>`, :ref:`VisualShaderNodeColorOp<class_VisualShaderNodeColorOp>`, :ref:`VisualShaderNodeCompare<class_VisualShaderNodeCompare>`, :ref:`VisualShaderNodeConstant<class_VisualShaderNodeConstant>`, :ref:`VisualShaderNodeCubemap<class_VisualShaderNodeCubemap>`, :ref:`VisualShaderNodeCustom<class_VisualShaderNodeCustom>`, :ref:`VisualShaderNodeDerivativeFunc<class_VisualShaderNodeDerivativeFunc>`, :ref:`VisualShaderNodeDeterminant<class_VisualShaderNodeDeterminant>`, :ref:`VisualShaderNodeDistanceFade<class_VisualShaderNodeDistanceFade>`, :ref:`VisualShaderNodeDotProduct<class_VisualShaderNodeDotProduct>`, :ref:`VisualShaderNodeFloatFunc<class_VisualShaderNodeFloatFunc>`, :ref:`VisualShaderNodeFloatOp<class_VisualShaderNodeFloatOp>`, :ref:`VisualShaderNodeFresnel<class_VisualShaderNodeFresnel>`, :ref:`VisualShaderNodeIf<class_VisualShaderNodeIf>`, :ref:`VisualShaderNodeInput<class_VisualShaderNodeInput>`, :ref:`VisualShaderNodeIntFunc<class_VisualShaderNodeIntFunc>`, :ref:`VisualShaderNodeIntOp<class_VisualShaderNodeIntOp>`, :ref:`VisualShaderNodeIs<class_VisualShaderNodeIs>`, :ref:`VisualShaderNodeLinearSceneDepth<class_VisualShaderNodeLinearSceneDepth>`, :ref:`VisualShaderNodeMix<class_VisualShaderNodeMix>`, :ref:`VisualShaderNodeMultiplyAdd<class_VisualShaderNodeMultiplyAdd>`, :ref:`VisualShaderNodeOuterProduct<class_VisualShaderNodeOuterProduct>`, :ref:`VisualShaderNodeOutput<class_VisualShaderNodeOutput>`, :ref:`VisualShaderNodeParameter<class_VisualShaderNodeParameter>`, :ref:`VisualShaderNodeParameterRef<class_VisualShaderNodeParameterRef>`, :ref:`VisualShaderNodeParticleAccelerator<class_VisualShaderNodeParticleAccelerator>`, :ref:`VisualShaderNodeParticleConeVelocity<class_VisualShaderNodeParticleConeVelocity>`, :ref:`VisualShaderNodeParticleEmit<class_VisualShaderNodeParticleEmit>`, :ref:`VisualShaderNodeParticleEmitter<class_VisualShaderNodeParticleEmitter>`, :ref:`VisualShaderNodeParticleMultiplyByAxisAngle<class_VisualShaderNodeParticleMultiplyByAxisAngle>`, :ref:`VisualShaderNodeParticleRandomness<class_VisualShaderNodeParticleRandomness>`, :ref:`VisualShaderNodeProximityFade<class_VisualShaderNodeProximityFade>`, :ref:`VisualShaderNodeRandomRange<class_VisualShaderNodeRandomRange>`, :ref:`VisualShaderNodeRemap<class_VisualShaderNodeRemap>`, :ref:`VisualShaderNodeResizableBase<class_VisualShaderNodeResizableBase>`, :ref:`VisualShaderNodeRotationByAxis<class_VisualShaderNodeRotationByAxis>`, :ref:`VisualShaderNodeSample3D<class_VisualShaderNodeSample3D>`, :ref:`VisualShaderNodeScreenNormalWorldSpace<class_VisualShaderNodeScreenNormalWorldSpace>`, :ref:`VisualShaderNodeScreenUVToSDF<class_VisualShaderNodeScreenUVToSDF>`, :ref:`VisualShaderNodeSDFRaymarch<class_VisualShaderNodeSDFRaymarch>`, :ref:`VisualShaderNodeSDFToScreenUV<class_VisualShaderNodeSDFToScreenUV>`, :ref:`VisualShaderNodeSmoothStep<class_VisualShaderNodeSmoothStep>`, :ref:`VisualShaderNodeStep<class_VisualShaderNodeStep>`, :ref:`VisualShaderNodeSwitch<class_VisualShaderNodeSwitch>`, :ref:`VisualShaderNodeTexture<class_VisualShaderNodeTexture>`, :ref:`VisualShaderNodeTextureSDF<class_VisualShaderNodeTextureSDF>`, :ref:`VisualShaderNodeTextureSDFNormal<class_VisualShaderNodeTextureSDFNormal>`, :ref:`VisualShaderNodeTransformCompose<class_VisualShaderNodeTransformCompose>`, :ref:`VisualShaderNodeTransformDecompose<class_VisualShaderNodeTransformDecompose>`, :ref:`VisualShaderNodeTransformFunc<class_VisualShaderNodeTransformFunc>`, :ref:`VisualShaderNodeTransformOp<class_VisualShaderNodeTransformOp>`, :ref:`VisualShaderNodeTransformVecMult<class_VisualShaderNodeTransformVecMult>`, :ref:`VisualShaderNodeUIntFunc<class_VisualShaderNodeUIntFunc>`, :ref:`VisualShaderNodeUIntOp<class_VisualShaderNodeUIntOp>`, :ref:`VisualShaderNodeUVFunc<class_VisualShaderNodeUVFunc>`, :ref:`VisualShaderNodeUVPolarCoord<class_VisualShaderNodeUVPolarCoord>`, :ref:`VisualShaderNodeVarying<class_VisualShaderNodeVarying>`, :ref:`VisualShaderNodeVectorBase<class_VisualShaderNodeVectorBase>`, :ref:`VisualShaderNodeWorldPositionFromDepth<class_VisualShaderNodeWorldPositionFromDepth>`
  11. Base class for :ref:`VisualShader<class_VisualShader>` nodes. Not related to scene nodes.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Visual shader graphs consist of various nodes. Each node in the graph is a separate object and they are represented as a rectangular boxes with title and a set of properties. Each node also has connection ports that allow to connect it to another nodes and control the flow of the shader.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`Using VisualShaders <../tutorials/shaders/visual_shaders>`
  20. .. rst-class:: classref-reftable-group
  21. Properties
  22. ----------
  23. .. table::
  24. :widths: auto
  25. +-----------------------+-----------------------------------------------------------------------------------------+--------+
  26. | :ref:`int<class_int>` | :ref:`output_port_for_preview<class_VisualShaderNode_property_output_port_for_preview>` | ``-1`` |
  27. +-----------------------+-----------------------------------------------------------------------------------------+--------+
  28. .. rst-class:: classref-reftable-group
  29. Methods
  30. -------
  31. .. table::
  32. :widths: auto
  33. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`clear_default_input_values<class_VisualShaderNode_method_clear_default_input_values>` **(** **)** |
  35. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`get_default_input_port<class_VisualShaderNode_method_get_default_input_port>` **(** :ref:`PortType<enum_VisualShaderNode_PortType>` type **)** |const| |
  37. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Array<class_Array>` | :ref:`get_default_input_values<class_VisualShaderNode_method_get_default_input_values>` **(** **)** |const| |
  39. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Variant<class_Variant>` | :ref:`get_input_port_default_value<class_VisualShaderNode_method_get_input_port_default_value>` **(** :ref:`int<class_int>` port **)** |const| |
  41. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`remove_input_port_default_value<class_VisualShaderNode_method_remove_input_port_default_value>` **(** :ref:`int<class_int>` port **)** |
  43. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_default_input_values<class_VisualShaderNode_method_set_default_input_values>` **(** :ref:`Array<class_Array>` values **)** |
  45. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_input_port_default_value<class_VisualShaderNode_method_set_input_port_default_value>` **(** :ref:`int<class_int>` port, :ref:`Variant<class_Variant>` value, :ref:`Variant<class_Variant>` prev_value=null **)** |
  47. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. .. rst-class:: classref-section-separator
  49. ----
  50. .. rst-class:: classref-descriptions-group
  51. Enumerations
  52. ------------
  53. .. _enum_VisualShaderNode_PortType:
  54. .. rst-class:: classref-enumeration
  55. enum **PortType**:
  56. .. _class_VisualShaderNode_constant_PORT_TYPE_SCALAR:
  57. .. rst-class:: classref-enumeration-constant
  58. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_SCALAR** = ``0``
  59. Floating-point scalar. Translated to ``float`` type in shader code.
  60. .. _class_VisualShaderNode_constant_PORT_TYPE_SCALAR_INT:
  61. .. rst-class:: classref-enumeration-constant
  62. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_SCALAR_INT** = ``1``
  63. Integer scalar. Translated to ``int`` type in shader code.
  64. .. _class_VisualShaderNode_constant_PORT_TYPE_SCALAR_UINT:
  65. .. rst-class:: classref-enumeration-constant
  66. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_SCALAR_UINT** = ``2``
  67. Unsigned integer scalar. Translated to ``uint`` type in shader code.
  68. .. _class_VisualShaderNode_constant_PORT_TYPE_VECTOR_2D:
  69. .. rst-class:: classref-enumeration-constant
  70. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_VECTOR_2D** = ``3``
  71. 2D vector of floating-point values. Translated to ``vec2`` type in shader code.
  72. .. _class_VisualShaderNode_constant_PORT_TYPE_VECTOR_3D:
  73. .. rst-class:: classref-enumeration-constant
  74. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_VECTOR_3D** = ``4``
  75. 3D vector of floating-point values. Translated to ``vec3`` type in shader code.
  76. .. _class_VisualShaderNode_constant_PORT_TYPE_VECTOR_4D:
  77. .. rst-class:: classref-enumeration-constant
  78. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_VECTOR_4D** = ``5``
  79. 4D vector of floating-point values. Translated to ``vec4`` type in shader code.
  80. .. _class_VisualShaderNode_constant_PORT_TYPE_BOOLEAN:
  81. .. rst-class:: classref-enumeration-constant
  82. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_BOOLEAN** = ``6``
  83. Boolean type. Translated to ``bool`` type in shader code.
  84. .. _class_VisualShaderNode_constant_PORT_TYPE_TRANSFORM:
  85. .. rst-class:: classref-enumeration-constant
  86. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_TRANSFORM** = ``7``
  87. Transform type. Translated to ``mat4`` type in shader code.
  88. .. _class_VisualShaderNode_constant_PORT_TYPE_SAMPLER:
  89. .. rst-class:: classref-enumeration-constant
  90. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_SAMPLER** = ``8``
  91. Sampler type. Translated to reference of sampler uniform in shader code. Can only be used for input ports in non-uniform nodes.
  92. .. _class_VisualShaderNode_constant_PORT_TYPE_MAX:
  93. .. rst-class:: classref-enumeration-constant
  94. :ref:`PortType<enum_VisualShaderNode_PortType>` **PORT_TYPE_MAX** = ``9``
  95. Represents the size of the :ref:`PortType<enum_VisualShaderNode_PortType>` enum.
  96. .. rst-class:: classref-section-separator
  97. ----
  98. .. rst-class:: classref-descriptions-group
  99. Property Descriptions
  100. ---------------------
  101. .. _class_VisualShaderNode_property_output_port_for_preview:
  102. .. rst-class:: classref-property
  103. :ref:`int<class_int>` **output_port_for_preview** = ``-1``
  104. .. rst-class:: classref-property-setget
  105. - void **set_output_port_for_preview** **(** :ref:`int<class_int>` value **)**
  106. - :ref:`int<class_int>` **get_output_port_for_preview** **(** **)**
  107. Sets the output port index which will be showed for preview. If set to ``-1`` no port will be open for preview.
  108. .. rst-class:: classref-section-separator
  109. ----
  110. .. rst-class:: classref-descriptions-group
  111. Method Descriptions
  112. -------------------
  113. .. _class_VisualShaderNode_method_clear_default_input_values:
  114. .. rst-class:: classref-method
  115. void **clear_default_input_values** **(** **)**
  116. Clears the default input ports value.
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_VisualShaderNode_method_get_default_input_port:
  120. .. rst-class:: classref-method
  121. :ref:`int<class_int>` **get_default_input_port** **(** :ref:`PortType<enum_VisualShaderNode_PortType>` type **)** |const|
  122. Returns the input port which should be connected by default when this node is created as a result of dragging a connection from an existing node to the empty space on the graph.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_VisualShaderNode_method_get_default_input_values:
  126. .. rst-class:: classref-method
  127. :ref:`Array<class_Array>` **get_default_input_values** **(** **)** |const|
  128. Returns an :ref:`Array<class_Array>` containing default values for all of the input ports of the node in the form ``[index0, value0, index1, value1, ...]``.
  129. .. rst-class:: classref-item-separator
  130. ----
  131. .. _class_VisualShaderNode_method_get_input_port_default_value:
  132. .. rst-class:: classref-method
  133. :ref:`Variant<class_Variant>` **get_input_port_default_value** **(** :ref:`int<class_int>` port **)** |const|
  134. Returns the default value of the input ``port``.
  135. .. rst-class:: classref-item-separator
  136. ----
  137. .. _class_VisualShaderNode_method_remove_input_port_default_value:
  138. .. rst-class:: classref-method
  139. void **remove_input_port_default_value** **(** :ref:`int<class_int>` port **)**
  140. Removes the default value of the input ``port``.
  141. .. rst-class:: classref-item-separator
  142. ----
  143. .. _class_VisualShaderNode_method_set_default_input_values:
  144. .. rst-class:: classref-method
  145. void **set_default_input_values** **(** :ref:`Array<class_Array>` values **)**
  146. Sets the default input ports values using an :ref:`Array<class_Array>` of the form ``[index0, value0, index1, value1, ...]``. For example: ``[0, Vector3(0, 0, 0), 1, Vector3(0, 0, 0)]``.
  147. .. rst-class:: classref-item-separator
  148. ----
  149. .. _class_VisualShaderNode_method_set_input_port_default_value:
  150. .. rst-class:: classref-method
  151. void **set_input_port_default_value** **(** :ref:`int<class_int>` port, :ref:`Variant<class_Variant>` value, :ref:`Variant<class_Variant>` prev_value=null **)**
  152. Sets the default ``value`` for the selected input ``port``.
  153. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  154. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  155. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  156. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  157. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  158. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  159. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`