:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/Shader.xml. .. _class_Shader: Shader ====== **Inherits:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` **Inherited By:** :ref:`VisualShader` A custom shader program. .. rst-class:: classref-introduction-group Description ----------- This class allows you to define a custom shader program that can be used by a :ref:`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. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`Shaders documentation index <../tutorials/shaders/index>` .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-----------------------------+-----------------------------------------+--------+ | :ref:`String` | :ref:`code` | ``""`` | +-----------------------------+-----------------------------------------+--------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Texture2D` | :ref:`get_default_texture_parameter` **(** :ref:`StringName` name, :ref:`int` index=0 **)** |const| | +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Mode` | :ref:`get_mode` **(** **)** |const| | +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_shader_uniform_list` **(** :ref:`bool` get_groups=false **)** | +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_default_texture_parameter` **(** :ref:`StringName` name, :ref:`Texture2D` texture, :ref:`int` index=0 **)** | +-----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_Shader_Mode: .. rst-class:: classref-enumeration enum **Mode**: .. _class_Shader_constant_MODE_SPATIAL: .. rst-class:: classref-enumeration-constant :ref:`Mode` **MODE_SPATIAL** = ``0`` Mode used to draw all 3D objects. .. _class_Shader_constant_MODE_CANVAS_ITEM: .. rst-class:: classref-enumeration-constant :ref:`Mode` **MODE_CANVAS_ITEM** = ``1`` Mode used to draw all 2D objects. .. _class_Shader_constant_MODE_PARTICLES: .. rst-class:: classref-enumeration-constant :ref:`Mode` **MODE_PARTICLES** = ``2`` Mode used to calculate particle information on a per-particle basis. Not used for drawing. .. _class_Shader_constant_MODE_SKY: .. rst-class:: classref-enumeration-constant :ref:`Mode` **MODE_SKY** = ``3`` Mode used for drawing skies. Only works with shaders attached to :ref:`Sky` objects. .. _class_Shader_constant_MODE_FOG: .. rst-class:: classref-enumeration-constant :ref:`Mode` **MODE_FOG** = ``4`` Mode used for setting the color and density of volumetric fog effect. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_Shader_property_code: .. rst-class:: classref-property :ref:`String` **code** = ``""`` .. rst-class:: classref-property-setget - void **set_code** **(** :ref:`String` value **)** - :ref:`String` **get_code** **(** **)** Returns the shader's code as the user has written it, not the full generated code used internally. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_Shader_method_get_default_texture_parameter: .. rst-class:: classref-method :ref:`Texture2D` **get_default_texture_parameter** **(** :ref:`StringName` name, :ref:`int` index=0 **)** |const| Returns the texture that is set as default for the specified parameter. \ **Note:** ``name`` must match the name of the uniform in the code exactly. \ **Note:** If the sampler array is used use ``index`` to access the specified texture. .. rst-class:: classref-item-separator ---- .. _class_Shader_method_get_mode: .. rst-class:: classref-method :ref:`Mode` **get_mode** **(** **)** |const| Returns the shader mode for the shader, either :ref:`MODE_CANVAS_ITEM`, :ref:`MODE_SPATIAL` or :ref:`MODE_PARTICLES`. .. rst-class:: classref-item-separator ---- .. _class_Shader_method_get_shader_uniform_list: .. rst-class:: classref-method :ref:`Array` **get_shader_uniform_list** **(** :ref:`bool` get_groups=false **)** Get the list of shader uniforms that can be assigned to a :ref:`ShaderMaterial`, for use with :ref:`ShaderMaterial.set_shader_parameter` and :ref:`ShaderMaterial.get_shader_parameter`. The parameters returned are contained in dictionaries in a similar format to the ones returned by :ref:`Object.get_property_list`. If argument ``get_groups`` is true, parameter grouping hints will be provided. .. rst-class:: classref-item-separator ---- .. _class_Shader_method_set_default_texture_parameter: .. rst-class:: classref-method void **set_default_texture_parameter** **(** :ref:`StringName` name, :ref:`Texture2D` texture, :ref:`int` index=0 **)** 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`. \ **Note:** ``name`` must match the name of the uniform in the code exactly. \ **Note:** If the sampler array is used use ``index`` to access the specified texture. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`