:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Shader.xml. .. _class_Shader: Shader ====== **Inherits:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` **Inherited By:** :ref:`VisualShader` A shader implemented in the Godot shading language. .. rst-class:: classref-introduction-group Description ----------- A custom shader program implemented in the Godot shading language, saved with the ``.gdshader`` extension. This class is used by a :ref:`ShaderMaterial` and allows you to write your own custom behavior for rendering visual items 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:`Texture` | :ref:`get_default_texture_parameter`\ (\ name\: :ref:`StringName`, index\: :ref:`int` = 0\ ) |const| | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Mode` | :ref:`get_mode`\ (\ ) |const| | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_shader_uniform_list`\ (\ get_groups\: :ref:`bool` = false\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`inspect_native_shader_code`\ (\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_default_texture_parameter`\ (\ name\: :ref:`StringName`, texture\: :ref:`Texture`, index\: :ref:`int` = 0\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_Shader_Mode: .. rst-class:: classref-enumeration enum **Mode**: :ref:`🔗` .. _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** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_code**\ (\ value\: :ref:`String`\ ) - :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:`Texture` **get_default_texture_parameter**\ (\ name\: :ref:`StringName`, index\: :ref:`int` = 0\ ) |const| :ref:`🔗` 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| :ref:`🔗` Returns the shader mode for the shader. .. rst-class:: classref-item-separator ---- .. _class_Shader_method_get_shader_uniform_list: .. rst-class:: classref-method :ref:`Array` **get_shader_uniform_list**\ (\ get_groups\: :ref:`bool` = false\ ) :ref:`🔗` Returns 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 are also included in the list. .. rst-class:: classref-item-separator ---- .. _class_Shader_method_inspect_native_shader_code: .. rst-class:: classref-method |void| **inspect_native_shader_code**\ (\ ) :ref:`🔗` Only available when running in the editor. Opens a popup that visualizes the generated shader code, including all variants and internal shader code. See also :ref:`Material.inspect_native_shader_code`. .. rst-class:: classref-item-separator ---- .. _class_Shader_method_set_default_texture_parameter: .. rst-class:: classref-method |void| **set_default_texture_parameter**\ (\ name\: :ref:`StringName`, texture\: :ref:`Texture`, index\: :ref:`int` = 0\ ) :ref:`🔗` 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.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`