class_shadermaterial.rst 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/ShaderMaterial.xml.
  6. .. _class_ShaderMaterial:
  7. ShaderMaterial
  8. ==============
  9. **Inherits:** :ref:`Material<class_Material>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A material that uses a custom :ref:`Shader<class_Shader>` program.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A material that uses a custom :ref:`Shader<class_Shader>` program to render either items to screen or process particles. You can create multiple materials for the same shader but configure different values for the uniforms defined in the shader.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`Shaders documentation index <../tutorials/shaders/index>`
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +-----------------------------+-----------------------------------------------------+
  25. | :ref:`Shader<class_Shader>` | :ref:`shader<class_ShaderMaterial_property_shader>` |
  26. +-----------------------------+-----------------------------------------------------+
  27. .. rst-class:: classref-reftable-group
  28. Methods
  29. -------
  30. .. table::
  31. :widths: auto
  32. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Variant<class_Variant>` | :ref:`get_shader_parameter<class_ShaderMaterial_method_get_shader_parameter>` **(** :ref:`StringName<class_StringName>` param **)** |const| |
  34. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`set_shader_parameter<class_ShaderMaterial_method_set_shader_parameter>` **(** :ref:`StringName<class_StringName>` param, :ref:`Variant<class_Variant>` value **)** |
  36. +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. .. rst-class:: classref-section-separator
  38. ----
  39. .. rst-class:: classref-descriptions-group
  40. Property Descriptions
  41. ---------------------
  42. .. _class_ShaderMaterial_property_shader:
  43. .. rst-class:: classref-property
  44. :ref:`Shader<class_Shader>` **shader**
  45. .. rst-class:: classref-property-setget
  46. - void **set_shader** **(** :ref:`Shader<class_Shader>` value **)**
  47. - :ref:`Shader<class_Shader>` **get_shader** **(** **)**
  48. The :ref:`Shader<class_Shader>` program used to render this material.
  49. .. rst-class:: classref-section-separator
  50. ----
  51. .. rst-class:: classref-descriptions-group
  52. Method Descriptions
  53. -------------------
  54. .. _class_ShaderMaterial_method_get_shader_parameter:
  55. .. rst-class:: classref-method
  56. :ref:`Variant<class_Variant>` **get_shader_parameter** **(** :ref:`StringName<class_StringName>` param **)** |const|
  57. Returns the current value set for this material of a uniform in the shader.
  58. .. rst-class:: classref-item-separator
  59. ----
  60. .. _class_ShaderMaterial_method_set_shader_parameter:
  61. .. rst-class:: classref-method
  62. void **set_shader_parameter** **(** :ref:`StringName<class_StringName>` param, :ref:`Variant<class_Variant>` value **)**
  63. Changes the value set for this material of a uniform in the shader.
  64. \ **Note:** ``param`` is case-sensitive and must match the name of the uniform in the code exactly (not the capitalized name in the inspector).
  65. \ **Note:** Changes to the shader uniform will be effective on all instances using this **ShaderMaterial**. To prevent this, use per-instance uniforms with :ref:`GeometryInstance3D.set_instance_shader_parameter<class_GeometryInstance3D_method_set_instance_shader_parameter>` or duplicate the **ShaderMaterial** resource using :ref:`Resource.duplicate<class_Resource_method_duplicate>`. Per-instance uniforms allow for better shader reuse and are therefore faster, so they should be preferred over duplicating the **ShaderMaterial** when possible.
  66. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  67. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  68. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  69. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  70. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  71. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`