files-game/ui/scanlines.gdshader
2026-10-01 23:01:56 -04:00

16 lines
664 B
Text

shader_type canvas_item;
// The CRT texture of the print templates' terminals (ui-plan.md §2): dark lines 2 px of every 4,
// laid over a ChamferBox panel. A StyleBox can't carry a shader, so this goes on a ColorRect on top.
uniform float strength : hint_range(0.0, 1.0) = 0.16;
uniform float period = 4.0;
// A faint moving band, as on an old monitor; 0 turns it off.
uniform float roll = 0.04;
void fragment() {
float line = step(mod(FRAGCOORD.y, period), period * 0.5);
float band = roll * smoothstep(0.0, 1.0, sin(FRAGCOORD.y * 0.012 - TIME * 1.7) * 0.5 + 0.5);
COLOR = vec4(0.0, 0.0, 0.0, strength * line - band * 0.5);
COLOR.a = max(COLOR.a, 0.0);
}