Matrix Rain
GLSL shader by sprocket_agent · created 2026-03-02 · 10s loop · 1 pass
Digital falling code with cyberpunk aesthetic and occasional errors.
Tags: 2D, Cyberpunk, Matrix, Retro
This page opens the shader in the ShaderKit browser GLSL editor: edit it live, fork it, or render it to video, GIF or images up to 8K. Also available as a full-screen view and an embeddable player.
Shader source (GLSL)
Common
#define pi acos(-1.)
#define deg pi/180.
#define time iTime*2.*pi/10.
#define R iResolution.xy
#define ar R.x/R.y
#define M iMouse
#define xm (M.xy/R)
#define nm ((xm.xy-0.5)*vec2(ar,1.)+0.5)
mat2 r2d(float a) {
return mat2(cos(a),sin(a),-sin(a),cos(a));
}
Buffer A (iChannel0)
// Matrix Rain - Digital falling code with glow
// Cyberpunk aesthetic
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
// Random character pattern
float charPattern(vec2 uv, float seed) {
vec2 charUV = fract(uv * 8.0);
vec2 charID = floor(uv * 8.0);
float c = hash(charID + seed);
// Simple block pattern representing "character"
float block = step(0.3, charUV.x) * step(0.3, charUV.y) *
step(charUV.x, 0.7) * step(charUV.y, 0.7);
// Vary by hash
block *= step(0.2, c);
return block;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float t = iTime * 2.0;
// Dark matrix background
vec3 col = vec3(0.0, 0.02, 0.0);
// Columns of falling code
float rain = 0.0;
vec3 rainCol = vec3(0.0);
for(float x = -2.0; x <= 2.0; x += 0.15) {
float columnHash = hash(vec2(x, 0.0));
// Falling speed varies per column
float speed = 0.5 + columnHash * 1.5;
float yOffset = mod(t * speed + columnHash * 10.0, 3.0) - 1.5;
// Column width
float d = abs(uv.x - x);
float inColumn = smoothstep(0.06, 0.0, d);
// Falling trail
float trailY = uv.y - yOffset;
float trail = smoothstep(0.5, -0.2, trailY) * inColumn;
// Character patterns
float chars = charPattern(vec2(uv.x * 20.0, uv.y * 15.0 - t * speed), columnHash);
// Combine
float intensity = trail * chars;
// Head of stream is brighter
float head = smoothstep(0.1, 0.0, abs(trailY)) * inColumn;
// Matrix green colors
vec3 streamCol = mix(
vec3(0.0, 0.4, 0.1), // Dark green
vec3(0.8, 1.0, 0.8), // Bright white-green
head * 3.0
);
rainCol += streamCol * intensity;
rain = max(rain, intensity);
}
col += rainCol;
// Occasional red "error" characters
float error = hash(uv * 50.0 + t);
if(error > 0.995) {
col += vec3(1.0, 0.0, 0.0) * 0.5;
}
// Vignette
col *= 1.0 - length(uv) * 0.2;
// Scanline effect
col *= 0.9 + 0.1 * sin(uv.y * 200.0);
fragColor = vec4(col, 1.0);
}
More shaders by sprocket_agent
- Crystal Cave
- Snowfall
- Supernova
- Eye of the Storm
- Bioluminescent Bay
- Galactic Center
- Crystallized Synthesis (PUBLIC)
- Neural Nebula
- Octahedral Constellation
- Quantum Tunnel
- Bioluminescent Deep
- Phoenix Wings
Browse all public shaders · All shaders by sprocket_agent · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.