class_shader.rst 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 custom shader program.
  12. Description
  13. -----------
  14. 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.
  15. Tutorials
  16. ---------
  17. - :doc:`Shaders documentation index <../tutorials/shaders/index>`
  18. Properties
  19. ----------
  20. +-----------------------------+-----------------------------------------+--------+
  21. | :ref:`String<class_String>` | :ref:`code<class_Shader_property_code>` | ``""`` |
  22. +-----------------------------+-----------------------------------------+--------+
  23. Methods
  24. -------
  25. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Texture2D<class_Texture2D>` | :ref:`get_default_texture_param<class_Shader_method_get_default_texture_param>` **(** :ref:`StringName<class_StringName>` param, :ref:`int<class_int>` index=0 **)** |const| |
  27. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Mode<enum_Shader_Mode>` | :ref:`get_mode<class_Shader_method_get_mode>` **(** **)** |const| |
  29. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`has_param<class_Shader_method_has_param>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  31. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_default_texture_param<class_Shader_method_set_default_texture_param>` **(** :ref:`StringName<class_StringName>` param, :ref:`Texture2D<class_Texture2D>` texture, :ref:`int<class_int>` index=0 **)** |
  33. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. Enumerations
  35. ------------
  36. .. _enum_Shader_Mode:
  37. .. _class_Shader_constant_MODE_SPATIAL:
  38. .. _class_Shader_constant_MODE_CANVAS_ITEM:
  39. .. _class_Shader_constant_MODE_PARTICLES:
  40. .. _class_Shader_constant_MODE_SKY:
  41. .. _class_Shader_constant_MODE_FOG:
  42. enum **Mode**:
  43. - **MODE_SPATIAL** = **0** --- Mode used to draw all 3D objects.
  44. - **MODE_CANVAS_ITEM** = **1** --- Mode used to draw all 2D objects.
  45. - **MODE_PARTICLES** = **2** --- Mode used to calculate particle information on a per-particle basis. Not used for drawing.
  46. - **MODE_SKY** = **3** --- Mode used for drawing skies. Only works with shaders attached to :ref:`Sky<class_Sky>` objects.
  47. - **MODE_FOG** = **4** --- Mode used for setting the color and density of volumetric fog effect.
  48. Property Descriptions
  49. ---------------------
  50. .. _class_Shader_property_code:
  51. - :ref:`String<class_String>` **code**
  52. +-----------+-----------------+
  53. | *Default* | ``""`` |
  54. +-----------+-----------------+
  55. | *Setter* | set_code(value) |
  56. +-----------+-----------------+
  57. | *Getter* | get_code() |
  58. +-----------+-----------------+
  59. Returns the shader's code as the user has written it, not the full generated code used internally.
  60. Method Descriptions
  61. -------------------
  62. .. _class_Shader_method_get_default_texture_param:
  63. - :ref:`Texture2D<class_Texture2D>` **get_default_texture_param** **(** :ref:`StringName<class_StringName>` param, :ref:`int<class_int>` index=0 **)** |const|
  64. Returns the texture that is set as default for the specified parameter.
  65. \ **Note:** ``param`` must match the name of the uniform in the code exactly.
  66. \ **Note:** If the sampler array is used use ``index`` to access the specified texture.
  67. ----
  68. .. _class_Shader_method_get_mode:
  69. - :ref:`Mode<enum_Shader_Mode>` **get_mode** **(** **)** |const|
  70. 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>`.
  71. ----
  72. .. _class_Shader_method_has_param:
  73. - :ref:`bool<class_bool>` **has_param** **(** :ref:`StringName<class_StringName>` name **)** |const|
  74. Returns ``true`` if the shader has this param defined as a uniform in its code.
  75. \ **Note:** ``param`` must match the name of the uniform in the code exactly.
  76. ----
  77. .. _class_Shader_method_set_default_texture_param:
  78. - void **set_default_texture_param** **(** :ref:`StringName<class_StringName>` param, :ref:`Texture2D<class_Texture2D>` texture, :ref:`int<class_int>` index=0 **)**
  79. 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>`.
  80. \ **Note:** ``param`` must match the name of the uniform in the code exactly.
  81. \ **Note:** If the sampler array is used use ``index`` to access the specified texture.
  82. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  83. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  84. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  85. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  86. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  87. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`