Particle Fountain
Sparks thrown up from the floor and falling back, each spark tied to a frequency band. Lows throw from the middle, high…
Free to use for anything. No credit needed.
// Dot Matrix: a grid of round LEDs, like a club display. Each column is a slice of the spectrum, lit from the bottom up.
// The kick lights the bottom rows white, the hats make single dots sparkle at the top.
// P1 sensitivity, P2 number of columns, P3 glow, P4 colour range (shifts the whole palette).
float hash21(vec2 p)
{
p = fract(p * vec2(123.34, 456.21));
p += dot(p, p + 45.32);
return fract(p.x * p.y);
}
float spec(float x)
{
return texture(iChannel0, vec2(x, 0.25)).x;
}
float band(float lo, float hi)
{
float s = 0.0;
for (int i = 0; i < 4; i++)
s += spec(mix(lo, hi, (float(i) + 0.5) / 4.0));
return s * 0.25;
}
vec3 pal(float x)
{
return 0.5 + 0.5 * cos(6.28318 * (x + P4 + vec3(0.0, 0.33, 0.67)));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 q = fragCoord / iResolution.xy;
float aspect = iResolution.x / iResolution.y;
float gain = 0.6 + P1 * 1.4;
float k = 0.5 + P3 * 1.5;
float bass = band(0.0, 0.06);
float hi = band(0.40, 0.90);
float cols = 16.0 + floor(P2 * 32.0);
float rows = floor(cols / aspect);
vec2 cell = vec2(q.x * cols, q.y * rows);
vec2 id = floor(cell);
vec2 f = fract(cell) - 0.5;
float f0 = pow(id.x / cols, 2.0) * 0.9;
float f1 = pow((id.x + 1.0) / cols, 2.0) * 0.9;
float lv = pow(clamp(band(f0, max(f1, f0 + 0.004)) * gain, 0.0, 1.0), 1.2);
float h = (id.y + 0.5) / rows; // 0 bottom .. 1 top
float lit = step(h, lv * 0.95);
float tip = step(h, lv * 0.95 + 1.5 / rows) * (1.0 - lit); // the dot just above the bar glows a little
float spark = step(0.97 - hi * 0.1, hash21(id + floor(iTime * 10.0))) * hi * step(0.6, h);
float px = cols / iResolution.x;
float d = length(f) - 0.36;
float dotShape = smoothstep(px, -px, d);
float halo = exp(-max(d, 0.0) * (6.0 - P3 * 3.0));
vec3 c = pal(h * 0.6 + id.x / cols * 0.2);
c = mix(c, vec3(1.0), smoothstep(0.2, 0.0, h) * bass);
float on = lit + tip * 0.3 + spark;
vec3 col = vec3(0.012, 0.013, 0.02);
col += vec3(0.03, 0.035, 0.05) * dotShape; // unlit LEDs
col += c * (dotShape * on * 1.4 + halo * on * 0.12 * k);
col = col / (1.0 + 0.5 * col);
col *= 1.0 - 0.15 * dot(q - 0.5, q - 0.5);
fragColor = vec4(col, 1.0);
}
Made for MNodes: paste it in a Shader Code node and wire it to a Shader or Scene. The P values are the sliders above the code.
Comments
No comments yet.
Log in or create an account to place a comment.