Skip to main content Svelte Highlight v7.21.1

Godot Shading Language preview

1. A basic spatial shader

shader_type, render_mode, and vertex/fragment functions
horizon-dark
shader_type spatial;
render_mode blend_mix, depth_draw_opaque;

uniform float intensity : hint_range(0, 1) = 0.5;

void vertex() {
    VERTEX.y += sin(TIME) * 0.1;
}

void fragment() {
    vec3 color = ALBEDO.rgb * intensity;
    ALBEDO = color;
}
atom-one-dark
shader_type spatial;
render_mode blend_mix, depth_draw_opaque;

uniform float intensity : hint_range(0, 1) = 0.5;

void vertex() {
    VERTEX.y += sin(TIME) * 0.1;
}

void fragment() {
    vec3 color = ALBEDO.rgb * intensity;
    ALBEDO = color;
}
github-dark
shader_type spatial;
render_mode blend_mix, depth_draw_opaque;

uniform float intensity : hint_range(0, 1) = 0.5;

void vertex() {
    VERTEX.y += sin(TIME) * 0.1;
}

void fragment() {
    vec3 color = ALBEDO.rgb * intensity;
    ALBEDO = color;
}
dracula
shader_type spatial;
render_mode blend_mix, depth_draw_opaque;

uniform float intensity : hint_range(0, 1) = 0.5;

void vertex() {
    VERTEX.y += sin(TIME) * 0.1;
}

void fragment() {
    vec3 color = ALBEDO.rgb * intensity;
    ALBEDO = color;
}
nord
shader_type spatial;
render_mode blend_mix, depth_draw_opaque;

uniform float intensity : hint_range(0, 1) = 0.5;

void vertex() {
    VERTEX.y += sin(TIME) * 0.1;
}

void fragment() {
    vec3 color = ALBEDO.rgb * intensity;
    ALBEDO = color;
}
github
shader_type spatial;
render_mode blend_mix, depth_draw_opaque;

uniform float intensity : hint_range(0, 1) = 0.5;

void vertex() {
    VERTEX.y += sin(TIME) * 0.1;
}

void fragment() {
    vec3 color = ALBEDO.rgb * intensity;
    ALBEDO = color;
}

2. Textures and hints

sampler uniforms with hints and swizzles
horizon-dark
shader_type canvas_item;

uniform sampler2D noise_tex : hint_default_black, filter_linear_mipmap;
uniform vec4 tint : source_color = vec4(1.0);

void fragment() {
    vec4 tex_color = texture(noise_tex, UV);
    COLOR = tex_color * tint;
    COLOR.a = clamp(COLOR.a, 0.0, 1.0);
}
atom-one-dark
shader_type canvas_item;

uniform sampler2D noise_tex : hint_default_black, filter_linear_mipmap;
uniform vec4 tint : source_color = vec4(1.0);

void fragment() {
    vec4 tex_color = texture(noise_tex, UV);
    COLOR = tex_color * tint;
    COLOR.a = clamp(COLOR.a, 0.0, 1.0);
}
github-dark
shader_type canvas_item;

uniform sampler2D noise_tex : hint_default_black, filter_linear_mipmap;
uniform vec4 tint : source_color = vec4(1.0);

void fragment() {
    vec4 tex_color = texture(noise_tex, UV);
    COLOR = tex_color * tint;
    COLOR.a = clamp(COLOR.a, 0.0, 1.0);
}
dracula
shader_type canvas_item;

uniform sampler2D noise_tex : hint_default_black, filter_linear_mipmap;
uniform vec4 tint : source_color = vec4(1.0);

void fragment() {
    vec4 tex_color = texture(noise_tex, UV);
    COLOR = tex_color * tint;
    COLOR.a = clamp(COLOR.a, 0.0, 1.0);
}
nord
shader_type canvas_item;

uniform sampler2D noise_tex : hint_default_black, filter_linear_mipmap;
uniform vec4 tint : source_color = vec4(1.0);

void fragment() {
    vec4 tex_color = texture(noise_tex, UV);
    COLOR = tex_color * tint;
    COLOR.a = clamp(COLOR.a, 0.0, 1.0);
}
github
shader_type canvas_item;

uniform sampler2D noise_tex : hint_default_black, filter_linear_mipmap;
uniform vec4 tint : source_color = vec4(1.0);

void fragment() {
    vec4 tex_color = texture(noise_tex, UV);
    COLOR = tex_color * tint;
    COLOR.a = clamp(COLOR.a, 0.0, 1.0);
}

3. Light function

the light() entry point and built-in lighting variables
horizon-dark
shader_type spatial;

void light() {
    DIFFUSE_LIGHT += ALBEDO * LIGHT_COLOR * ATTENUATION;
    SPECULAR_LIGHT += LIGHT_COLOR * pow(max(dot(NORMAL, LIGHT), 0.0), 32.0);
}
atom-one-dark
shader_type spatial;

void light() {
    DIFFUSE_LIGHT += ALBEDO * LIGHT_COLOR * ATTENUATION;
    SPECULAR_LIGHT += LIGHT_COLOR * pow(max(dot(NORMAL, LIGHT), 0.0), 32.0);
}
github-dark
shader_type spatial;

void light() {
    DIFFUSE_LIGHT += ALBEDO * LIGHT_COLOR * ATTENUATION;
    SPECULAR_LIGHT += LIGHT_COLOR * pow(max(dot(NORMAL, LIGHT), 0.0), 32.0);
}
dracula
shader_type spatial;

void light() {
    DIFFUSE_LIGHT += ALBEDO * LIGHT_COLOR * ATTENUATION;
    SPECULAR_LIGHT += LIGHT_COLOR * pow(max(dot(NORMAL, LIGHT), 0.0), 32.0);
}
nord
shader_type spatial;

void light() {
    DIFFUSE_LIGHT += ALBEDO * LIGHT_COLOR * ATTENUATION;
    SPECULAR_LIGHT += LIGHT_COLOR * pow(max(dot(NORMAL, LIGHT), 0.0), 32.0);
}
github
shader_type spatial;

void light() {
    DIFFUSE_LIGHT += ALBEDO * LIGHT_COLOR * ATTENUATION;
    SPECULAR_LIGHT += LIGHT_COLOR * pow(max(dot(NORMAL, LIGHT), 0.0), 32.0);
}