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.
// Glitch Strobe: a pulsing ring graphic that is torn apart by the music.
// The kick flashes (and inverts) the picture, the hats rip rows sideways and split the colour channels, the mids shift whole blocks.
// P1 glitch amount, P2 glitch speed and row count, P3 strobe, 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)));
}
// the picture that gets torn apart: concentric rings, a core and moving bars
vec3 scene(vec2 q, float bass, float mid)
{
vec2 uv = (2.0 * q - 1.0) * vec2(iResolution.x / iResolution.y, 1.0);
float d = length(uv);
float rings = pow(0.5 + 0.5 * sin(d * 16.0 - iTime * 2.0 - bass * 8.0), 6.0) * smoothstep(1.6, 0.2, d);
float coreR = 0.28 + bass * 0.18;
float core = 1.0 - smoothstep(coreR - 0.01, coreR, d);
float bars = step(0.5, fract(uv.x * 5.0 + iTime * 0.3)) * smoothstep(0.9, 0.0, abs(uv.y)) * (0.05 + mid * 0.8);
vec3 col = vec3(0.01, 0.01, 0.015);
col += pal(d * 0.3) * rings * 1.1;
col += pal(0.6) * core * (0.6 + bass);
col += pal(0.25) * bars;
return col;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 q = fragCoord / iResolution.xy;
float bass = band(0.0, 0.06);
float mid = band(0.10, 0.30);
float hi = band(0.40, 0.90);
float step_ = floor(iTime * (4.0 + P2 * 20.0)); // the glitch changes in steps, not smoothly
float rows = 6.0 + floor(P2 * 30.0);
float amount = P1 * (0.25 + 1.5 * hi + mid);
// rows that slip sideways
float rowId = floor(q.y * rows);
float rr = hash21(vec2(rowId, step_));
float slip = step(1.0 - 0.45 * amount, rr) * (hash21(vec2(rowId, step_ + 7.0)) - 0.5) * 0.35 * P1;
q.x += slip;
// blocks that jump to another place
vec2 blk = floor(q * vec2(8.0, 5.0));
float br = hash21(blk + step_ * 1.37);
float jump = step(1.0 - 0.12 * amount, br);
q += jump * (vec2(hash21(blk + 3.0), hash21(blk + 9.0)) - 0.5) * 0.25 * P1;
// now and then the whole picture rolls, or turns into big pixels
float big = hash21(vec2(step_, 5.0));
q.y = fract(q.y + step(0.88, big) * (hash21(vec2(step_, 2.0)) - 0.5) * 0.4 * P1);
float pix = step(0.93, hash21(vec2(step_, 8.0))) * P1;
if (pix > 0.0)
q = (floor(q * 48.0) + 0.5) / 48.0;
// colour channels pulled apart
float sp = 0.002 + 0.03 * P1 * (0.2 + hi * 3.0) + bass * 0.01;
vec3 col;
col.r = scene(q + vec2(sp, 0.0), bass, mid).r;
col.g = scene(q, bass, mid).g;
col.b = scene(q - vec2(sp, 0.0), bass, mid).b;
// strobe: the kick flashes the whole frame and, hard enough, inverts it
float flash = pow(bass, 3.0) * P3 * 1.5;
col += pal(0.1) * flash * 0.6;
col = mix(col, vec3(1.0) - col, smoothstep(0.75, 0.95, bass) * P3);
// scanlines and static
col *= 0.88 + 0.12 * sin(fragCoord.y * 3.14159);
col += (hash21(fragCoord + fract(iTime) * 100.0) - 0.5) * 0.08 * (0.2 + hi * 2.0);
col = col / (1.0 + 0.4 * col);
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.