class_shader.rst 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/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:`Texture<class_Texture>` | :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:`inspect_native_shader_code<class_Shader_method_inspect_native_shader_code>`\ (\ ) |
  42. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | |void| | :ref:`set_default_texture_parameter<class_Shader_method_set_default_texture_parameter>`\ (\ name\: :ref:`StringName<class_StringName>`, texture\: :ref:`Texture<class_Texture>`, index\: :ref:`int<class_int>` = 0\ ) |
  44. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. .. rst-class:: classref-section-separator
  46. ----
  47. .. rst-class:: classref-descriptions-group
  48. Enumerations
  49. ------------
  50. .. _enum_Shader_Mode:
  51. .. rst-class:: classref-enumeration
  52. enum **Mode**: :ref:`🔗<enum_Shader_Mode>`
  53. .. _class_Shader_constant_MODE_SPATIAL:
  54. .. rst-class:: classref-enumeration-constant
  55. :ref:`Mode<enum_Shader_Mode>` **MODE_SPATIAL** = ``0``
  56. Mode used to draw all 3D objects.
  57. .. _class_Shader_constant_MODE_CANVAS_ITEM:
  58. .. rst-class:: classref-enumeration-constant
  59. :ref:`Mode<enum_Shader_Mode>` **MODE_CANVAS_ITEM** = ``1``
  60. Mode used to draw all 2D objects.
  61. .. _class_Shader_constant_MODE_PARTICLES:
  62. .. rst-class:: classref-enumeration-constant
  63. :ref:`Mode<enum_Shader_Mode>` **MODE_PARTICLES** = ``2``
  64. Mode used to calculate particle information on a per-particle basis. Not used for drawing.
  65. .. _class_Shader_constant_MODE_SKY:
  66. .. rst-class:: classref-enumeration-constant
  67. :ref:`Mode<enum_Shader_Mode>` **MODE_SKY** = ``3``
  68. Mode used for drawing skies. Only works with shaders attached to :ref:`Sky<class_Sky>` objects.
  69. .. _class_Shader_constant_MODE_FOG:
  70. .. rst-class:: classref-enumeration-constant
  71. :ref:`Mode<enum_Shader_Mode>` **MODE_FOG** = ``4``
  72. Mode used for setting the color and density of volumetric fog effect.
  73. .. rst-class:: classref-section-separator
  74. ----
  75. .. rst-class:: classref-descriptions-group
  76. Property Descriptions
  77. ---------------------
  78. .. _class_Shader_property_code:
  79. .. rst-class:: classref-property
  80. :ref:`String<class_String>` **code** = ``""`` :ref:`🔗<class_Shader_property_code>`
  81. .. rst-class:: classref-property-setget
  82. - |void| **set_code**\ (\ value\: :ref:`String<class_String>`\ )
  83. - :ref:`String<class_String>` **get_code**\ (\ )
  84. Returns the shader's code as the user has written it, not the full generated code used internally.
  85. .. rst-class:: classref-section-separator
  86. ----
  87. .. rst-class:: classref-descriptions-group
  88. Method Descriptions
  89. -------------------
  90. .. _class_Shader_method_get_default_texture_parameter:
  91. .. rst-class:: classref-method
  92. :ref:`Texture<class_Texture>` **get_default_texture_parameter**\ (\ name\: :ref:`StringName<class_StringName>`, index\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_Shader_method_get_default_texture_parameter>`
  93. Returns the texture that is set as default for the specified parameter.
  94. \ **Note:** ``name`` must match the name of the uniform in the code exactly.
  95. \ **Note:** If the sampler array is used use ``index`` to access the specified texture.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_Shader_method_get_mode:
  99. .. rst-class:: classref-method
  100. :ref:`Mode<enum_Shader_Mode>` **get_mode**\ (\ ) |const| :ref:`🔗<class_Shader_method_get_mode>`
  101. Returns the shader mode for the shader.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_Shader_method_get_shader_uniform_list:
  105. .. rst-class:: classref-method
  106. :ref:`Array<class_Array>` **get_shader_uniform_list**\ (\ get_groups\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Shader_method_get_shader_uniform_list>`
  107. Returns 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>`.
  108. If argument ``get_groups`` is ``true``, parameter grouping hints are also included in the list.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_Shader_method_inspect_native_shader_code:
  112. .. rst-class:: classref-method
  113. |void| **inspect_native_shader_code**\ (\ ) :ref:`🔗<class_Shader_method_inspect_native_shader_code>`
  114. Only available when running in the editor. Opens a popup that visualizes the generated shader code, including all variants and internal shader code. See also :ref:`Material.inspect_native_shader_code<class_Material_method_inspect_native_shader_code>`.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_Shader_method_set_default_texture_parameter:
  118. .. rst-class:: classref-method
  119. |void| **set_default_texture_parameter**\ (\ name\: :ref:`StringName<class_StringName>`, texture\: :ref:`Texture<class_Texture>`, index\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_Shader_method_set_default_texture_parameter>`
  120. 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>`.
  121. \ **Note:** ``name`` must match the name of the uniform in the code exactly.
  122. \ **Note:** If the sampler array is used use ``index`` to access the specified texture.
  123. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  124. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  125. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  126. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  127. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  128. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  129. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  130. .. |void| replace:: :abbr:`void (No return value.)`