class_shader.rst 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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/Shader.xml.
  6. .. _class_Shader:
  7. Shader
  8. ======
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`VisualShader<class_VisualShader>`
  11. A custom shader program.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. This class allows you to define a custom shader program that can be used by a :ref:`ShaderMaterial<class_ShaderMaterial>`. Shaders allow you to write your own custom behavior for rendering objects or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`../tutorials/shaders/index`
  20. - :doc:`../tutorials/shaders/introduction_to_shaders`
  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. | :ref:`String<class_String>` | :ref:`custom_defines<class_Shader_property_custom_defines>` | ``""`` |
  30. +-----------------------------+-------------------------------------------------------------+--------+
  31. .. rst-class:: classref-reftable-group
  32. Methods
  33. -------
  34. .. table::
  35. :widths: auto
  36. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Texture<class_Texture>` | :ref:`get_default_texture_param<class_Shader_method_get_default_texture_param>` **(** :ref:`String<class_String>` param **)** |const| |
  38. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Mode<enum_Shader_Mode>` | :ref:`get_mode<class_Shader_method_get_mode>` **(** **)** |const| |
  40. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`has_param<class_Shader_method_has_param>` **(** :ref:`String<class_String>` name **)** |const| |
  42. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`set_default_texture_param<class_Shader_method_set_default_texture_param>` **(** :ref:`String<class_String>` param, :ref:`Texture<class_Texture>` texture **)** |
  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**:
  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. .. rst-class:: classref-section-separator
  66. ----
  67. .. rst-class:: classref-descriptions-group
  68. Property Descriptions
  69. ---------------------
  70. .. _class_Shader_property_code:
  71. .. rst-class:: classref-property
  72. :ref:`String<class_String>` **code** = ``""``
  73. .. rst-class:: classref-property-setget
  74. - void **set_code** **(** :ref:`String<class_String>` value **)**
  75. - :ref:`String<class_String>` **get_code** **(** **)**
  76. Returns the shader's code as the user has written it, not the full generated code used internally.
  77. .. rst-class:: classref-item-separator
  78. ----
  79. .. _class_Shader_property_custom_defines:
  80. .. rst-class:: classref-property
  81. :ref:`String<class_String>` **custom_defines** = ``""``
  82. .. rst-class:: classref-property-setget
  83. - void **set_custom_defines** **(** :ref:`String<class_String>` value **)**
  84. - :ref:`String<class_String>` **get_custom_defines** **(** **)**
  85. Returns the shader's custom defines. Custom defines can be used in Godot to add GLSL preprocessor directives (e.g: extensions) required for the shader logic.
  86. \ **Note:** Custom defines are not validated by the Godot shader parser, so care should be taken when using them.
  87. .. rst-class:: classref-section-separator
  88. ----
  89. .. rst-class:: classref-descriptions-group
  90. Method Descriptions
  91. -------------------
  92. .. _class_Shader_method_get_default_texture_param:
  93. .. rst-class:: classref-method
  94. :ref:`Texture<class_Texture>` **get_default_texture_param** **(** :ref:`String<class_String>` param **)** |const|
  95. Returns the texture that is set as default for the specified parameter.
  96. \ **Note:** ``param`` must match the name of the uniform in the code exactly.
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_Shader_method_get_mode:
  100. .. rst-class:: classref-method
  101. :ref:`Mode<enum_Shader_Mode>` **get_mode** **(** **)** |const|
  102. Returns the shader mode for the shader, either :ref:`MODE_CANVAS_ITEM<class_Shader_constant_MODE_CANVAS_ITEM>`, :ref:`MODE_SPATIAL<class_Shader_constant_MODE_SPATIAL>` or :ref:`MODE_PARTICLES<class_Shader_constant_MODE_PARTICLES>`.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_Shader_method_has_param:
  106. .. rst-class:: classref-method
  107. :ref:`bool<class_bool>` **has_param** **(** :ref:`String<class_String>` name **)** |const|
  108. Returns ``true`` if the shader has this param defined as a uniform in its code.
  109. \ **Note:** ``param`` must match the name of the uniform in the code exactly.
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_Shader_method_set_default_texture_param:
  113. .. rst-class:: classref-method
  114. void **set_default_texture_param** **(** :ref:`String<class_String>` param, :ref:`Texture<class_Texture>` texture **)**
  115. 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>`.
  116. \ **Note:** ``param`` must match the name of the uniform in the code exactly.
  117. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  118. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  119. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  120. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`