class_shadermaterial.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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/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 defined by a custom :ref:`Shader<class_Shader>` program and the values of its shader parameters.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A material that uses a custom :ref:`Shader<class_Shader>` program to render visual items (canvas items, meshes, skies, fog), or to process particles. Compared to other materials, **ShaderMaterial** gives deeper control over the generated shader code. For more information, see the shaders documentation index below.
  15. Multiple **ShaderMaterial**\ s can use the same shader and configure different values for the shader uniforms.
  16. \ **Note:** For performance reasons, the :ref:`Resource.changed<class_Resource_signal_changed>` signal is only emitted when the :ref:`Resource.resource_name<class_Resource_property_resource_name>` changes. Only in editor, it is also emitted for :ref:`shader<class_ShaderMaterial_property_shader>` changes.
  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:`Shader<class_Shader>` | :ref:`shader<class_ShaderMaterial_property_shader>` |
  28. +-----------------------------+-----------------------------------------------------+
  29. .. rst-class:: classref-reftable-group
  30. Methods
  31. -------
  32. .. table::
  33. :widths: auto
  34. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Variant<class_Variant>` | :ref:`get_shader_parameter<class_ShaderMaterial_method_get_shader_parameter>`\ (\ param\: :ref:`StringName<class_StringName>`\ ) |const| |
  36. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | |void| | :ref:`set_shader_parameter<class_ShaderMaterial_method_set_shader_parameter>`\ (\ param\: :ref:`StringName<class_StringName>`, value\: :ref:`Variant<class_Variant>`\ ) |
  38. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. .. rst-class:: classref-section-separator
  40. ----
  41. .. rst-class:: classref-descriptions-group
  42. Property Descriptions
  43. ---------------------
  44. .. _class_ShaderMaterial_property_shader:
  45. .. rst-class:: classref-property
  46. :ref:`Shader<class_Shader>` **shader** :ref:`🔗<class_ShaderMaterial_property_shader>`
  47. .. rst-class:: classref-property-setget
  48. - |void| **set_shader**\ (\ value\: :ref:`Shader<class_Shader>`\ )
  49. - :ref:`Shader<class_Shader>` **get_shader**\ (\ )
  50. The :ref:`Shader<class_Shader>` program used to render this material.
  51. .. rst-class:: classref-section-separator
  52. ----
  53. .. rst-class:: classref-descriptions-group
  54. Method Descriptions
  55. -------------------
  56. .. _class_ShaderMaterial_method_get_shader_parameter:
  57. .. rst-class:: classref-method
  58. :ref:`Variant<class_Variant>` **get_shader_parameter**\ (\ param\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_ShaderMaterial_method_get_shader_parameter>`
  59. Returns the current value set for this material of a uniform in the shader.
  60. .. rst-class:: classref-item-separator
  61. ----
  62. .. _class_ShaderMaterial_method_set_shader_parameter:
  63. .. rst-class:: classref-method
  64. |void| **set_shader_parameter**\ (\ param\: :ref:`StringName<class_StringName>`, value\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_ShaderMaterial_method_set_shader_parameter>`
  65. Changes the value set for this material of a uniform in the shader.
  66. \ **Note:** ``param`` is case-sensitive and must match the name of the uniform in the code exactly (not the capitalized name in the inspector).
  67. \ **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.
  68. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  69. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  70. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  71. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  72. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  73. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  74. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  75. .. |void| replace:: :abbr:`void (No return value.)`