Frog Choir
by MusicBar, visualizer
A choir of little frogs sits on lily pads, each one singing its own band of the music with a throat sac that swells as it gets louder, blinking now and then, while ripples roll out under the pads on every beat.
How it installs, its SHA-256 and its code
Click Apply: MusicBar downloads it, checks its SHA-256 and puts it on the taskbar, or just puts it on if it already has it. Needs MusicBar 1.8 or newer.
SHA-256 b00e49d4d026bc48a3874ce6339c0c4a82035cbc3bd56a213e7d824f2c46a132
//! name: Frog Choir
//! author: MusicBar
//! kind: visualizer
//! description: A choir of little frogs sits on lily pads along the bar, each one singing its own band of the music with a throat sac that swells as it gets louder, blinking now and then, with ripples rolling out under the pads on every beat.
float hash1(float n) { return frac(sin(n * 127.1 + 311.7) * 43758.5453); }
// Signed distance to an ellipse with radii r (close enough near the edge).
float ellipse(float2 p, float2 r) { float k0 = length(p / r); return k0 * (k0 - 1.0) / max(length(p / (r * r)), 0.0001); }
float smin(float a, float b, float k) { float h = saturate(0.5 + 0.5 * (b - a) / k); return lerp(b, a, h) - k * h * (1.0 - h); }
// Lays a color over what is there (premultiplied light, and how much of the pixel it covers).
void layer(inout float3 acc, inout float cover, float3 rgb, float a)
{
a = saturate(a);
acc = rgb * a + acc * (1.0 - a);
cover = a + cover * (1.0 - a);
}
float4 main(float2 uv : TEXCOORD) : COLOR
{
float u = size.y;
float2 p = float2(uv.x * size.x, (1.0 - uv.y) * u) / u; // bar heights, up the screen so the frogs sit upright
float aa = 1.0 / u;
float cw = 1.3; // one frog per cell
float k = floor(p.x / cw);
float h = hash1(k * 3.1 + 7.0);
float cx = (k + 0.5) * cw + (h - 0.5) * 0.12;
float band = spectrum(abs(cx * u / size.x - 0.5) * 2.0); // bass in the middle of the bar, treble out to the ends
float3 acc = float3(0, 0, 0);
float cover = 0;
// Ripples rolling out from under each pad on the beat, and a slow idle ring.
float2 w = p - float2(cx, 0.1);
float rb = 1.0 - sqrt(beat);
float rr = length(w / float2(1.0, 0.22));
float ring = min(abs(rr - (0.5 + 0.75 * rb)), abs(rr - (0.5 + 0.45 * rb))) * 0.22 - 0.008;
float idle = frac(time * 0.25 + h);
float ring2 = abs(rr - (0.45 + 0.4 * idle)) * 0.22 - 0.005;
float3 rc = lerp(colorB.rgb, float3(0.85, 1.0, 0.95), 0.55);
layer(acc, cover, rc, smoothstep(aa, -aa, ring) * sqrt(beat) * step(abs(w.x), cw * 0.5));
layer(acc, cover, rc, smoothstep(aa, -aa, ring2) * (1.0 - idle) * 0.3);
// The lily pad, seen low across the water, with its notch toward us and veins.
float bob = 0.012 * sin(time * 1.3 + h * 6.0) - 0.02 * beat;
float2 lq = w - float2(0.0, bob);
float pad = ellipse(lq, float2(0.52, 0.1));
float notch = abs(lq.x - 0.12 * (h - 0.5)) - 0.12 * saturate(-lq.y / 0.1);
pad = max(pad, -max(notch, lq.y + 0.0));
float vein = smoothstep(0.15, 0.0, abs(frac(atan2(lq.y * 5.0, lq.x) / 6.2832 * 10.0) - 0.5)) * 0.25;
float3 padC = lerp(float3(0.05, 0.2, 0.13), float3(0.2, 0.45, 0.28), saturate(lq.y / 0.1 + 0.5)) * (1.0 - vein);
layer(acc, cover, float3(0.02, 0.1, 0.05), smoothstep(aa, -aa, pad - 1.2 * aa));
layer(acc, cover, padC, smoothstep(aa, -aa, pad));
layer(acc, cover, float3(0.6, 0.9, 0.5), smoothstep(aa * 1.5, 0.0, abs(pad + 0.012)) * step(0.0, lq.y) * 0.5);
// The frog, facing us: f is in bar heights from the middle of its seat; it sways a little and bounces on the beat.
float s = 0.92 + 0.12 * h;
float2 f = (lq - float2(0.0, 0.05 + 0.03 * beat)) / s;
f.x += 0.02 * sin(time * 1.7 + h * 9.0) * f.y;
float body = smin(ellipse(f - float2(0.0, 0.19), float2(0.29, 0.19)), ellipse(f - float2(0.0, 0.37), float2(0.25, 0.14)), 0.08);
float2 ef = float2(abs(f.x) - 0.135, f.y - 0.5);
float eyes = length(ef) - 0.095;
float2 lf = float2(abs(f.x), f.y);
float thigh = ellipse(lf - float2(0.27, 0.12), float2(0.12, 0.09));
float foot = ellipse(lf - float2(0.37, 0.02), float2(0.1, 0.03));
float hand = ellipse(lf - float2(0.15, 0.03), float2(0.06, 0.035));
float frog = min(min(smin(body, eyes, 0.04), min(thigh, foot)), hand);
float3 skin = lerp(colorA.rgb, colorB.rgb, smoothstep(0.2, 0.8, frac(h * 7.0)));
layer(acc, cover, skin, exp(-max(frog, 0.0) * s / 0.06) * (0.08 + 0.22 * band) * step(0.0, frog));
layer(acc, cover, skin * 0.22, smoothstep(aa, -aa, frog * s - 1.3 * aa));
float lit = saturate((f.y - 0.05) / 0.5);
float3 back = skin * (0.55 + 0.55 * lit);
layer(acc, cover, back * 0.8, smoothstep(aa, -aa, min(thigh, foot) * s));
layer(acc, cover, back * 0.9, smoothstep(aa, -aa, hand * s));
float belly = smoothstep(0.02, -0.02, ellipse(f - float2(0.0, 0.16), float2(0.18, 0.13)));
float3 bodyC = lerp(back, lerp(skin, float3(1.0, 0.98, 0.85), 0.6), belly);
bodyC += float3(1, 1, 1) * 0.25 * smoothstep(0.06, 0.0, length(f - float2(-0.1, 0.42)) - 0.03);
layer(acc, cover, bodyC, smoothstep(aa, -aa, smin(body, eyes, 0.04) * s));
// Eyes: white with a big pupil looking about, and lids that close now and then.
float blink = step(0.965, frac(time * 0.23 + h * 3.7));
float2 look = float2(0.02 * sin(time * 0.6 + h * 20.0), 0.01);
float eyeW = length(ef) - 0.07;
layer(acc, cover, float3(1, 1, 1), smoothstep(aa, -aa, eyeW * s));
float pup = length(ef - look) - 0.045;
layer(acc, cover, float3(0.04, 0.05, 0.04), smoothstep(aa, -aa, pup * s));
layer(acc, cover, float3(1, 1, 1), smoothstep(aa, -aa, (length(ef - look - float2(0.015, 0.018)) - 0.014) * s));
float lid = smoothstep(aa, -aa, eyeW * s) * smoothstep(-0.01, 0.01, ef.y - lerp(0.08, -0.08, blink));
layer(acc, cover, back, lid);
// The mouth opens to sing with its band; the throat sac under it swells like a bubble.
float m = saturate(smoothstep(0.22, 0.68, band) + 0.06 * sin(time * 2.5 + h * 10.0));
float sr = (0.035 + 0.165 * m) * (1.0 + 0.15 * beat);
float2 sq = f - float2(0.0, 0.34 - sr * 0.85);
float sac = length(sq / float2(1.12, 0.95)) - sr;
float2 sn = sq / max(sr, 0.01);
float3 sacC = lerp(colorC.rgb * 0.85, lerp(colorC.rgb, float3(1, 1, 1), 0.6), saturate(0.55 + 0.5 * sn.y - 0.2 * sn.x));
sacC += float3(1, 1, 1) * 0.7 * smoothstep(0.25, 0.0, length(sn - float2(-0.4, 0.38)) - 0.06);
sacC = lerp(sacC, bodyC, smoothstep(0.55, 1.05, sn.y) * 0.6);
layer(acc, cover, colorC.rgb, exp(-max(sac, 0.0) * s / 0.05) * 0.4 * m);
layer(acc, cover, colorC.rgb * 0.45, smoothstep(aa, -aa, sac * s - 1.0 * aa) * step(0.03, m) * smoothstep(0.5, 0.1, sn.y));
layer(acc, cover, sacC, smoothstep(aa, -aa, sac * s) * step(0.03, m) * 0.92);
// A little note floats up beside each frog that is singing loud.
float nt = frac(time * 0.45 + h * 5.0);
float2 nq = (f - float2(0.36 + 0.04 * sin(nt * 9.0 + h * 10.0), 0.42 + 0.5 * nt)) / 0.16;
float note = min(length((nq - float2(-0.12, -0.3)) / float2(1.0, 0.75)) - 0.2, max(abs(nq.x - 0.06) - 0.045, abs(nq.y - 0.1) - 0.42));
note = min(note, max(abs(nq.y - 0.45 + 0.4 * (nq.x - 0.06)) - 0.07, abs(nq.x - 0.2) - 0.14));
layer(acc, cover, lerp(colorC.rgb, float3(1, 1, 1), 0.3), smoothstep(aa, -aa, note * 0.16 * s) * smoothstep(0.25, 0.6, band) * sin(nt * 3.1416));
float mouthY = 0.37;
float smile = f.y - (mouthY - 0.25 * f.x * f.x);
float mouthD = max(abs(smile + 0.02 * m) - (0.006 + 0.035 * m) * (1.0 - f.x * f.x / 0.03), abs(f.x) - 0.15);
layer(acc, cover, lerp(skin * 0.2, float3(0.45, 0.08, 0.12), m), smoothstep(aa, -aa, mouthD * s));
// Some pads hold a water lily at the edge: a cup of pointed petals that opens a little with the music.
float2 fl = lq - float2(0.47 * sign(frac(h * 17.0) - 0.5), 0.02);
float open = 0.04 + 0.03 * band;
float bloom = max(ellipse(fl, float2(0.09, 0.07)), fl.y - 0.008 - open * (1.0 - abs(frac(fl.x / 0.04 + 0.5) - 0.5) * 2.0));
float3 lily = lerp(float3(1.0, 0.45, 0.68), float3(1.0, 0.93, 0.96), saturate(fl.y / 0.05 + 0.5));
lily = lerp(lily, float3(1.0, 0.85, 0.3), smoothstep(0.03, 0.0, length(fl - float2(0.0, 0.012))) * 0.8);
layer(acc, cover, float3(0.35, 0.05, 0.15), smoothstep(aa, -aa, bloom - aa) * step(0.55, frac(h * 5.3)));
layer(acc, cover, lily, smoothstep(aa, -aa, bloom) * step(0.55, frac(h * 5.3)));
layer(acc, cover, float3(1.0, 0.55, 0.6), smoothstep(0.05, 0.0, length(float2(abs(f.x) - 0.19, f.y - 0.36))) * 0.45);
return paint(acc / max(cover, 0.001), cover);
}