class_shader.rst 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Shader.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Shader:
  6. Shader
  7. ======
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`VisualShader<class_VisualShader>`
  10. A custom shader program.
  11. Description
  12. -----------
  13. 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.
  14. Tutorials
  15. ---------
  16. - :doc:`../tutorials/shading/index`
  17. - :doc:`../tutorials/shading/your_first_shader/what_are_shaders`
  18. Properties
  19. ----------
  20. +-----------------------------+-----------------------------------------+--------+
  21. | :ref:`String<class_String>` | :ref:`code<class_Shader_property_code>` | ``""`` |
  22. +-----------------------------+-----------------------------------------+--------+
  23. Methods
  24. -------
  25. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Texture<class_Texture>` | :ref:`get_default_texture_param<class_Shader_method_get_default_texture_param>` **(** :ref:`String<class_String>` param **)** 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:`String<class_String>` name **)** const |
  31. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_default_texture_param<class_Shader_method_set_default_texture_param>` **(** :ref:`String<class_String>` param, :ref:`Texture<class_Texture>` texture **)** |
  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. enum **Mode**:
  41. - **MODE_SPATIAL** = **0** --- Mode used to draw all 3D objects.
  42. - **MODE_CANVAS_ITEM** = **1** --- Mode used to draw all 2D objects.
  43. - **MODE_PARTICLES** = **2** --- Mode used to calculate particle information on a per-particle basis. Not used for drawing.
  44. Property Descriptions
  45. ---------------------
  46. .. _class_Shader_property_code:
  47. - :ref:`String<class_String>` **code**
  48. +-----------+-----------------+
  49. | *Default* | ``""`` |
  50. +-----------+-----------------+
  51. | *Setter* | set_code(value) |
  52. +-----------+-----------------+
  53. | *Getter* | get_code() |
  54. +-----------+-----------------+
  55. Returns the shader's code as the user has written it, not the full generated code used internally.
  56. Method Descriptions
  57. -------------------
  58. .. _class_Shader_method_get_default_texture_param:
  59. - :ref:`Texture<class_Texture>` **get_default_texture_param** **(** :ref:`String<class_String>` param **)** const
  60. Returns the texture that is set as default for the specified parameter.
  61. **Note:** ``param`` must match the name of the uniform in the code exactly.
  62. ----
  63. .. _class_Shader_method_get_mode:
  64. - :ref:`Mode<enum_Shader_Mode>` **get_mode** **(** **)** const
  65. 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>`
  66. ----
  67. .. _class_Shader_method_has_param:
  68. - :ref:`bool<class_bool>` **has_param** **(** :ref:`String<class_String>` name **)** const
  69. Returns ``true`` if the shader has this param defined as a uniform in its code.
  70. **Note:** ``param`` must match the name of the uniform in the code exactly.
  71. ----
  72. .. _class_Shader_method_set_default_texture_param:
  73. - void **set_default_texture_param** **(** :ref:`String<class_String>` param, :ref:`Texture<class_Texture>` texture **)**
  74. 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>`.
  75. **Note:** ``param`` must match the name of the uniform in the code exactly.