Skip to main content

Shader

Inherits: Resource < RefCounted < Object

Description

A shader implemented in the Godot shading language. A custom shader program saved with the .gdshader extension.

Properties

code
String
default:""
Returns the shader’s code as the user has written it.

Methods

get_mode

Mode get_mode()
Returns the shader mode for the shader.

get_shader_uniform_list

Array get_shader_uniform_list(get_groups: bool = false)
Returns the list of shader uniforms that can be assigned to a ShaderMaterial.

set_default_texture_parameter

void set_default_texture_parameter(name: StringName, texture: Texture, index: int = 0)
Sets the default texture to be used with a texture uniform.

Constants

  • MODE_SPATIAL = 0 - Mode used to draw all 3D objects
  • MODE_CANVAS_ITEM = 1 - Mode used to draw all 2D objects
  • MODE_PARTICLES = 2 - Mode used to calculate particle information
  • MODE_SKY = 3 - Mode used for drawing skies
  • MODE_FOG = 4 - Mode used for volumetric fog effect

Example Usage

var shader = Shader.new()
shader.code = """
shader_type spatial;

void fragment() {
    ALBEDO = vec3(1.0, 0.0, 0.0);
}
"""

var material = ShaderMaterial.new()
material.shader = shader

Build docs developers (and LLMs) love