// GODOT 4 : pixel-perfect retro pipelines

Achieve 8/16-bit looks using custom shaders, low-res viewports, and palette restrictions. CRT scanline shader snippet:

// Retro Shader : scanlines + green phosphor (Godot ShaderLang)
shader_type canvas_item;
void fragment() {
    vec4 col   = texture(TEXTURE, UV);
    float scan = sin(SCREEN_UV.y * 400.0) * 0.15;
    vec3 green_hue = vec3(0.2, 0.9, 0.2);
    COLOR.rgb = (col.rgb + green_hue) * (0.8 + scan);
    COLOR.r   = COLOR.r * 0.6;
    COLOR.g   = COLOR.g * 1.2;
}

>_ Use TileMapLayer + 256×224 resolution, sprite flickering for transparency effects. Export to HTML5 or desktop.


// RETRO SETUP CHECKLIST

retro@godot:~$ cat setup.md
[1] Project → Window → Viewport Width: 320, Height: 240
[2] Rendering → 2D → Snap 2D Transforms to Pixel
[3] Import pixel art sprites → Filter: Nearest
[4] Add CanvasLayer + ColorRect with CRT shader
[5] Use TileMapLayer for tilemaps, 16×16 tiles

Palette restriction shader

// Limit to N colours – dither to nearest palette entry
shader_type canvas_item;
uniform sampler2D palette;
uniform int palette_size = 16;
void fragment() {
    vec4 col = texture(TEXTURE, UV);
    float best_dist = 1e9;
    vec3 best_col   = col.rgb;
    for (int i = 0; i < palette_size; i++) {
        vec3 pc = texelFetch(palette, ivec2(i, 0), 0).rgb;
        float d = distance(col.rgb, pc);
        if (d < best_dist) { best_dist = d; best_col = pc; }
    }
    COLOR = vec4(best_col, col.a);
}