#version 330 core
out vec4 FragColor; in vec2 vUV; uniform vec2 iResolution; uniform float iTime; uniform sampler2D iChannel0; uniform vec2 uCells; uniform float uFallers; uniform float uFallerHeight; uniform float uAlpha; uniform float uGreenGain;

vec2 rand2(vec2 uv){ return floor(abs(mod(cos(uv * 652.6345 + uv.yx * 534.375 + iTime * 0.0000005 * dot(uv, vec2(0.364, 0.934))), 0.001)) * 16000.0); }
float fallerSpeed(float col, float faller){ return mod(cos(col * 363.435 + faller * 234.323), 0.1) * 1.0 + 0.3; }

void main(){ vec2 fragCoord = gl_FragCoord.xy; vec2 uv = fragCoord / iResolution; vec2 pix = mod(uv, 1.0 / uCells); vec2 cell = (uv - pix) * uCells; pix *= uCells * vec2(0.8, 1.0) + vec2(0.1, 0.0); float c = texture(iChannel0, (rand2(cell) + pix) / 16.0).x; float b = 0.0; for(float i=0.0;i<64.0;i++){ if(i>=uFallers) break; float f = 3.0 - cell.y * 0.05 - mod((iTime + i * 3534.34) * fallerSpeed(cell.x, i), uFallerHeight); if(f > 0.0 && f < 1.0) b += f; } float g = c * b * uGreenGain; FragColor = vec4(0.0, g, 0.0, uAlpha); }