class_shader.rst 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.3/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.3/doc/classes/Shader.xml.
  6. .. _class_Shader:
  7. Shader
  8. ======
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`VisualShader<class_VisualShader>`
  11. A shader implemented in the Godot shading language.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. A custom shader program implemented in the Godot shading language, saved with the ``.gdshader`` extension.
  16. This class is used by a :ref:`ShaderMaterial<class_ShaderMaterial>` and allows you to write your own custom behavior for rendering visual items or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`Shaders documentation index <../tutorials/shaders/index>`
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +-----------------------------+-----------------------------------------+--------+
  27. | :ref:`String<class_String>` | :ref:`code<class_Shader_property_code>` | ``""`` |
  28. +-----------------------------+-----------------------------------------+--------+
  29. .. rst-class:: classref-reftable-group
  30. Methods
  31. -------
  32. .. table::
  33. :widths: auto
  34. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Texture2D<class_Texture2D>` | :ref:`get_default_texture_parameter<class_Shader_method_get_default_texture_parameter>`\ (\ name\: :ref:`StringName<class_StringName>`, index\: :ref:`int<class_int>` = 0\ ) |const| |
  36. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Mode<enum_Shader_Mode>` | :ref:`get_mode<class_Shader_method_get_mode>`\ (\ ) |const| |
  38. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Array<class_Array>` | :ref:`get_shader_uniform_list<class_Shader_method_get_shader_uniform_list>`\ (\ get_groups\: :ref:`bool<class_bool>` = false\ ) |
  40. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | |void| | :ref:`set_default_texture_parameter<class_Shader_method_set_default_texture_parameter>`\ (\ name\: :ref:`StringName<class_StringName>`, texture\: :ref:`Texture2D<class_Texture2D>`, index\: :ref:`int<class_int>` = 0\ ) |
  42. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. .. rst-class:: classref-section-separator
  44. ----
  45. .. rst-class:: classref-descriptions-group
  46. Enumerations
  47. ------------
  48. .. _enum_Shader_Mode:
  49. .. rst-class:: classref-enumeration
  50. enum **Mode**: :ref:`🔗<enum_Shader_Mode>`
  51. .. _class_Shader_constant_MODE_SPATIAL:
  52. .. rst-class:: classref-enumeration-constant
  53. :ref:`Mode<enum_Shader_Mode>` **MODE_SPATIAL** = ``0``
  54. Mode used to draw all 3D objects.
  55. .. _class_Shader_constant_MODE_CANVAS_ITEM:
  56. .. rst-class:: classref-enumeration-constant
  57. :ref:`Mode<enum_Shader_Mode>` **MODE_CANVAS_ITEM** = ``1``
  58. Mode used to draw all 2D objects.
  59. .. _class_Shader_constant_MODE_PARTICLES:
  60. .. rst-class:: classref-enumeration-constant
  61. :ref:`Mode<enum_Shader_Mode>` **MODE_PARTICLES** = ``2``
  62. Mode used to calculate particle information on a per-particle basis. Not used for drawing.
  63. .. _class_Shader_constant_MODE_SKY:
  64. .. rst-class:: classref-enumeration-constant
  65. :ref:`Mode<enum_Shader_Mode>` **MODE_SKY** = ``3``
  66. Mode used for drawing skies. Only works with shaders attached to :ref:`Sky<class_Sky>` objects.
  67. .. _class_Shader_constant_MODE_FOG:
  68. .. rst-class:: classref-enumeration-constant
  69. :ref:`Mode<enum_Shader_Mode>` **MODE_FOG** = ``4``
  70. Mode used for setting the color and density of volumetric fog effect.
  71. .. rst-class:: classref-section-separator
  72. ----
  73. .. rst-class:: classref-descriptions-group
  74. Property Descriptions
  75. ---------------------
  76. .. _class_Shader_property_code:
  77. .. rst-class:: classref-property
  78. :ref:`String<class_String>` **code** = ``""`` :ref:`🔗<class_Shader_property_code>`
  79. .. rst-class:: classref-property-setget
  80. - |void| **set_code**\ (\ value\: :ref:`String<class_String>`\ )
  81. - :ref:`String<class_String>` **get_code**\ (\ )
  82. Returns the shader's code as the user has written it, not the full generated code used internally.
  83. .. rst-class:: classref-section-separator
  84. ----
  85. .. rst-class:: classref-descriptions-group
  86. Method Descriptions
  87. -------------------
  88. .. _class_Shader_method_get_default_texture_parameter:
  89. .. rst-class:: classref-method
  90. :ref:`Texture2D<class_Texture2D>` **get_default_texture_parameter**\ (\ name\: :ref:`StringName<class_StringName>`, index\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_Shader_method_get_default_texture_parameter>`
  91. Returns the texture that is set as default for the specified parameter.
  92. \ **Note:** ``name`` must match the name of the uniform in the code exactly.
  93. \ **Note:** If the sampler array is used use ``index`` to access the specified texture.
  94. .. rst-class:: classref-item-separator
  95. ----
  96. .. _class_Shader_method_get_mode:
  97. .. rst-class:: classref-method
  98. :ref:`Mode<enum_Shader_Mode>` **get_mode**\ (\ ) |const| :ref:`🔗<class_Shader_method_get_mode>`
  99. Returns the shader mode for the shader.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_Shader_method_get_shader_uniform_list:
  103. .. rst-class:: classref-method
  104. :ref:`Array<class_Array>` **get_shader_uniform_list**\ (\ get_groups\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Shader_method_get_shader_uniform_list>`
  105. Get the list of shader uniforms that can be assigned to a :ref:`ShaderMaterial<class_ShaderMaterial>`, for use with :ref:`ShaderMaterial.set_shader_parameter<class_ShaderMaterial_method_set_shader_parameter>` and :ref:`ShaderMaterial.get_shader_parameter<class_ShaderMaterial_method_get_shader_parameter>`. The parameters returned are contained in dictionaries in a similar format to the ones returned by :ref:`Object.get_property_list<class_Object_method_get_property_list>`.
  106. If argument ``get_groups`` is true, parameter grouping hints will be provided.
  107. .. rst-class:: classref-item-separator
  108. ----
  109. .. _class_Shader_method_set_default_texture_parameter:
  110. .. rst-class:: classref-method
  111. |void| **set_default_texture_parameter**\ (\ name\: :ref:`StringName<class_StringName>`, texture\: :ref:`Texture2D<class_Texture2D>`, index\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_Shader_method_set_default_texture_parameter>`
  112. Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the :ref:`ShaderMaterial<class_ShaderMaterial>`.
  113. \ **Note:** ``name`` must match the name of the uniform in the code exactly.
  114. \ **Note:** If the sampler array is used use ``index`` to access the specified texture.
  115. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  116. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  117. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  118. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  119. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  120. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  121. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  122. .. |void| replace:: :abbr:`void (No return value.)`