Class reference

Shader

Inherits Resource

A shader implemented in the Redot shading language.

Description

A custom shader program implemented in the Redot shading language, saved with the .gdshader extension. This class is used by a 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.

Properties

String code = ""

Returns the shader's code as the user has written it, not the full generated code used internally.

Methods

Texture get_default_texture_parameter(StringName name, 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.

int get_mode() const

Returns the shader mode for the shader.

void inspect_native_shader_code()

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 Material.inspect_native_shader_code().

void set_default_texture_parameter(StringName name, Texture texture, 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 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.

Constants

MODE_SPATIAL = 0

Enum: Mode

Mode used to draw all 3D objects.

MODE_CANVAS_ITEM = 1

Enum: Mode

Mode used to draw all 2D objects.

MODE_PARTICLES = 2

Enum: Mode

Mode used to calculate particle information on a per-particle basis. Not used for drawing.

MODE_SKY = 3

Enum: Mode

Mode used for drawing skies. Only works with shaders attached to Sky objects.

MODE_FOG = 4

Enum: Mode

Mode used for setting the color and density of volumetric fog effect.

Tutorials

Source revision 4f5b14abade2
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.