CRT Screen: Scanlines, Curvature, RGB Mask, Vignette

A lightweight full-screen CRT look for retro, arcade and pixel-art games: rolling or static scanlines, barrel curvature with a border, an RGB aperture (phosphor) mask, small red/blue colour fringing, vignette, flicker and noise. Every effect has its own slider, so you can go from a subtle “soft TV” to a full 90s arcade monitor. One canvas_item shader, no textures needed.

USAGE:

Add a CanvasLayer above your game, add a ColorRect inside it, set its anchors to Full Rect and Mouse Filter to Ignore, then give it a ShaderMaterial with this shader. It reads the screen behind it (hint_screen_texture), so everything drawn below it gets the CRT look. Works in 2D and on top of 3D.

Uniforms:

– `curvature` – barrel distortion of the screen (0 = flat)

– `scanline_strength` – how dark the scanlines are

– `scanline_count` – number of scanlines over the screen height (match your game’s vertical resolution for pixel art, e.g. 240 or 360)

– `scanline_speed` – scroll speed of the lines (0 = static, small values give a rolling TV feel)

– `mask_strength` – strength of the RGB aperture / phosphor stripes

– `mask_size` – width of each mask stripe in screen pixels

– `chroma_offset` – red/blue fringe in pixels

– `vignette_strength` – darkening towards the corners

– `brightness` – brightens the result to make up for scanline and mask darkening

– `flicker` – subtle brightness flicker

– `noise_amount` – animated grain

– `border_color` – colour outside the curved screen

Works in Godot 4.3+ (Compatibility, Forward+, Mobile).

AI-assisted (code + text)

Make your retro game sound as good as it looks: free Combat SFX sampler: https://crtforge.pages.dev/combat-sfx-sampler/ and the full Fantasy RPG Combat SFX pack: https://assetsmithpixels.itch.io/fantasy-rpg-combat-sfx

Shader code
// CRT Screen: Scanlines, Curvature, RGB Mask, Vignette (Godot 4, canvas_item)
// MIT License - free for commercial and non-commercial use.
// Put this on a full-screen ColorRect (on a CanvasLayer above your game).
shader_type canvas_item;

uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;

uniform float curvature : hint_range(0.0, 0.5) = 0.12;       // barrel distortion amount
uniform float scanline_strength : hint_range(0.0, 1.0) = 0.35; // darkness of scanlines
uniform float scanline_count : hint_range(50.0, 1200.0) = 360.0; // lines over the screen height
uniform float scanline_speed : hint_range(-10.0, 10.0) = 0.0;  // scroll speed (0 = static)
uniform float mask_strength : hint_range(0.0, 1.0) = 0.2;      // RGB aperture/phosphor mask
uniform float mask_size : hint_range(1.0, 8.0) = 3.0;          // mask stripe width in pixels
uniform float chroma_offset : hint_range(0.0, 5.0) = 1.0;      // red/blue fringe in pixels
uniform float vignette_strength : hint_range(0.0, 2.0) = 0.6;
uniform float brightness : hint_range(0.5, 2.0) = 1.15;        // compensates darkening
uniform float flicker : hint_range(0.0, 0.2) = 0.02;
uniform float noise_amount : hint_range(0.0, 0.3) = 0.03;
uniform vec4 border_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); // outside the curved screen

vec2 barrel(vec2 uv) {
	vec2 c = uv * 2.0 - 1.0;
	c *= 1.0 + curvature * dot(c.yx, c.yx) * 0.5;
	return c * 0.5 + 0.5;
}

float hash(vec2 p) {
	return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
}

void fragment() {
	vec2 uv = barrel(SCREEN_UV);
	if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
		COLOR = border_color;
	} else {
		vec2 px = SCREEN_PIXEL_SIZE;
		vec3 col;
		col.r = textureLod(screen_texture, uv + vec2(chroma_offset * px.x, 0.0), 0.0).r;
		col.g = textureLod(screen_texture, uv, 0.0).g;
		col.b = textureLod(screen_texture, uv - vec2(chroma_offset * px.x, 0.0), 0.0).b;

		// scanlines
		float s = sin((uv.y * scanline_count + TIME * scanline_speed) * 3.14159265);
		col *= 1.0 - scanline_strength * (1.0 - (s * 0.5 + 0.5));

		// RGB aperture mask
		float m = mod(floor(FRAGCOORD.x / mask_size), 3.0);
		vec3 mask = vec3(m == 0.0 ? 1.0 : 0.0, m == 1.0 ? 1.0 : 0.0, m == 2.0 ? 1.0 : 0.0);
		col *= mix(vec3(1.0), mask * 1.5 + 0.25, mask_strength);

		// vignette
		vec2 v = uv * (1.0 - uv.yx);
		col *= mix(1.0, pow(clamp(v.x * v.y * 16.0, 0.0, 1.0), 0.25), vignette_strength);

		// flicker + noise
		col *= 1.0 - flicker * (0.5 + 0.5 * sin(TIME * 60.0));
		col += (hash(uv * 1000.0 + fract(TIME)) - 0.5) * noise_amount;

		COLOR = vec4(col * brightness, 1.0);
	}
}
Live Preview
Tags
2d, arcade, chromatic aberration, CRT, curvature, godot 4, Post processing, retro, scanlines, screen
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from assetsmith

Related shaders

Comments 1