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.
// Acid Scope: LED spectrum bars with a mirrored reflection, and an oscilloscope trace above them.
// Each bar is one slice of the spectrum (lows left, highs right); the scope line is built from the same bands, so it wobbles with the bass line.
// P1 sensitivity, P2 number of bars, P3 glow, P4 colour range (shifts the whole palette).
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)));
}
// one bar's LED blocks: how lit is the block at height y (from the baseline) for a bar that reaches barH
float blocks(float y, float barH, float px)
{
const float BL = 0.045;
float yy = y / BL;
float id = floor(yy);
float lit = step((id + 0.5) * BL, barH);
float cell = smoothstep(0.08, 0.08 + px / BL * 2.0, fract(yy)) * smoothstep(1.0, 1.0 - px / BL * 2.0, fract(yy));
return lit * cell * step(0.0, y);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 q = fragCoord / iResolution.xy;
vec2 uv = (2.0 * fragCoord - iResolution.xy) / iResolution.y;
float px = 2.0 / iResolution.y;
float gain = 0.6 + P1 * 1.4;
float k = 0.5 + P3 * 1.5;
float bass = band(0.0, 0.06);
float base = -0.45;
float n = 16.0 + floor(P2 * 48.0);
float bi = floor(q.x * n);
float fx = fract(q.x * n);
float f0 = pow(bi / n, 2.0) * 0.9;
float f1 = pow((bi + 1.0) / n, 2.0) * 0.9;
float lv = pow(clamp(band(f0, max(f1, f0 + 0.004)) * gain, 0.0, 1.0), 1.3);
float barH = lv * 0.85;
float xmask = smoothstep(0.08, 0.08 + 0.06, fx) * smoothstep(0.92, 0.92 - 0.06, fx);
vec3 col = vec3(0.012, 0.013, 0.02) + vec3(0.01, 0.015, 0.03) * (1.0 - abs(uv.y));
// the bars and their reflection
float y = uv.y - base;
float lit = blocks(y, barH, px) * xmask;
float top = step(barH - 0.045, y) * step(0.0, y);
vec3 bc = mix(pal(0.0 + q.x * 0.3), pal(0.5), clamp(y / 0.8, 0.0, 1.0));
bc = mix(bc, vec3(1.0), top * 0.6);
col += bc * lit * 1.1;
col += bc * (0.05 + 0.1 * lv) * xmask * step(0.0, y) * step(y, barH) * k; // glow behind the blocks
float yr = -(y) - 0.02;
float refl = blocks(yr, barH * 0.6, px) * xmask * exp(-yr * 4.0);
col += pal(0.0 + q.x * 0.3) * refl * 0.45;
// the floor line flashes on the kick
col += pal(0.25) * exp(-abs(y) / (px * (1.0 + P3 * 4.0))) * (0.3 + 2.5 * bass) * k;
// scope trace: low bands make the slow swells, high bands the ripples
float x = uv.x * 2.2;
float w = band(0.00, 0.04) * sin(x * 1.5 + iTime * 2.0)
+ band(0.05, 0.12) * sin(x * 3.1 - iTime * 3.1) * 0.7
+ band(0.12, 0.30) * sin(x * 7.3 + iTime * 5.3) * 0.45
+ band(0.30, 0.70) * sin(x * 17.0 - iTime * 9.0) * 0.25;
float sc = 0.62 + w * 0.16 * gain;
float slope = abs(cos(x * 3.1 - iTime * 3.1) * 0.3);
float d = abs(uv.y - sc) / sqrt(1.0 + slope * slope * 4.0);
float gw = px * (1.0 + P3 * 5.0);
col += pal(0.65) * (exp(-d / gw) * 1.2 + exp(-d / (gw * 6.0)) * 0.15) * k;
col += pal(0.65) * 0.04 * step(abs(uv.y - 0.62), 0.3) * (0.5 + 0.5 * cos(uv.y * 40.0)); // faint scope graticule
col = col / (1.0 + 0.5 * col);
col *= 1.0 - 0.15 * dot(uv, uv) * 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.