VHS Scanline Glitch

A fullscreen VHS-style glitch shader for 2D games and UI overlays. It combines random horizontal jitter, subtle RGB channel split, and thin animated scanlines to mimic unstable analog video playback. Apply it to a fullscreen `CanvasItem` such as a `ColorRect` with a `ShaderMaterial`. Adjust `shake` to control how often the horizontal distortion appears.

Shader code
shader_type canvas_item;

uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
uniform float shake : hint_range(0.0, 1.0) = 0.1;

float rand(vec2 co) {
    return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}

void fragment() {
    vec2 uv = SCREEN_UV;
    
    if (rand(vec2(TIME, 0.0)) < shake) {
        uv.x += rand(vec2(TIME, uv.y)) * 0.01;
    }

    float r = texture(SCREEN_TEXTURE, uv + vec2(0.003, 0.0)).r;
    float g = texture(SCREEN_TEXTURE, uv).g;
    float b = texture(SCREEN_TEXTURE, uv - vec2(0.003, 0.0)).b;
    
    float scanline = sin(uv.y * 400.0) * 0.04;
    COLOR = vec4(r - scanline, g - scanline, b - scanline, 1.0);
}
Live Preview
Tags
2d, chromatic aberration, CRT, glitch, post process, rgb split, scanlines, screen effect, VHS
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments