Gallop
by MusicBar, progress bar
A horse and jockey gallop to the playhead in sepia after Muybridge's 1878 photographs, leaving a row of glass negatives of the stride behind, reaching further and kicking up more dust as the music gets louder, with a shutter flash 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 7385ba19ba5f2a7d78c6233659e9cc4458687d965b8071caae71fcaa7fc4f426
//! name: Gallop
//! author: MusicBar
//! kind: progress
//! description: A horse and rider gallop to the playhead in sepia, after Muybridge's 1878 motion photographs, over a faint measuring grid with dust flying, the stride and the dust growing as the music gets louder.
float hash1(float n) { return frac(sin(n * 127.1 + 311.7) * 43758.5453); }
float vnoise(float2 p)
{
float2 i = floor(p), f = frac(p);
f = f * f * (3.0 - 2.0 * f);
float n = i.x + i.y * 57.0;
return lerp(lerp(hash1(n), hash1(n + 1.0), f.x), lerp(hash1(n + 57.0), hash1(n + 58.0), f.x), f.y);
}
float2 rot(float2 p, float a) { float c = cos(a), s = sin(a); return float2(c * p.x - s * p.y, s * p.x + c * p.y); }
// A capsule from a to b whose radius goes from ra to rb.
float cone(float2 p, float2 a, float2 b, float ra, float rb) { float2 pa = p - a, ba = b - a; float h = saturate(dot(pa, ba) / dot(ba, ba)); return length(pa - ba * h) - lerp(ra, rb, h); }
float ellipse(float2 p, float2 r) { float k0 = length(p / r); return k0 * (k0 - 1.0) / max(length(p / (r * r)), 0.0001); }
// Signed distance to a rounded box (half size b, corner r).
float boxD(float2 p, float2 b, float r) { float2 d = abs(p) - b + r; return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r; }
// A union that melts two shapes together over a width k.
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);
}
// One leg from its top joint j at stride phase f (on the ground for the first 30%): the fetlock follows a stance-and-swing
// path, two bones reach it (knees bend forward on the forelegs, hocks back on the hind legs), then pastern and hoof.
float leg(float2 q, float2 j, float f, float fore, float reach)
{
float s = saturate((f - 0.3) / 0.7), st = step(f, 0.3);
float x = lerp(-reach + 2.0 * reach * smoothstep(0.25, 1.0, s), reach * (1.0 - 2.0 * f / 0.3), st);
float lift = (1.0 - st) * pow(sin(3.1416 * s), 0.8) * lerp(0.14, 0.24, fore);
float2 dv = float2(x + lerp(-0.03, 0.04, fore), 0.08 + lift - j.y);
float l1 = lerp(0.2, 0.19, fore), l2 = lerp(0.18, 0.16, fore);
float D = min(length(dv), l1 + l2 - 0.002);
float2 dn = normalize(dv), fet = j + dn * D;
float a = (l1 * l1 - l2 * l2 + D * D) / (2.0 * D);
float2 k = j + dn * a + float2(-dn.y, dn.x) * sqrt(max(l1 * l1 - a * a, 0.0)) * (fore * 2.0 - 1.0);
float2 hoof = fet + normalize(lerp(float2(0.4, -1.0), float2(-0.9, -0.3), saturate(lift / 0.1))) * 0.06;
float d = min(cone(q, j, k, lerp(0.055, 0.042, fore), 0.03), cone(q, k, fet, 0.024, 0.021));
return min(d, cone(q, fet, hoof, 0.02, 0.026));
}
// The horse and jockey at stride phase p, in bar heights, origin on the ground under the girth.
// Returns the distance to the near side, to the far legs, and to the rider.
float3 horse(float2 q, float p, float reach)
{
q.y -= 0.025 * cos(6.2832 * (p - 0.85)); // up in the flight, down on the forehand
q = rot(q - float2(0.0, 0.45), 0.05 * sin(6.2832 * (p - 0.6))) + float2(0.0, 0.45);
float farL = min(leg(q, float2(0.17, 0.42), frac(p - 0.32), 1.0, reach), leg(q, float2(-0.2, 0.44), frac(p), 0.0, reach));
float nearL = min(leg(q, float2(0.2, 0.42), frac(p - 0.42), 1.0, reach), leg(q, float2(-0.16, 0.44), frac(p - 0.1), 0.0, reach));
float body = smin(ellipse(q - float2(0.0, 0.47), float2(0.25, 0.105)), ellipse(q - float2(0.18, 0.475), float2(0.11, 0.115)), 0.04);
body = smin(body, ellipse(q - float2(-0.18, 0.485), float2(0.14, 0.115)), 0.05);
body = smin(body, cone(q, float2(-0.17, 0.46), float2(-0.19, 0.36), 0.075, 0.05), 0.04); // the hind thigh
float ang = 0.9 + 0.13 * sin(6.2832 * (p - 0.2)); // the neck pumps with the stride
float2 poll = float2(0.2, 0.53) + 0.25 * float2(cos(ang), sin(ang));
float2 muzzle = poll + 0.17 * float2(cos(ang - 1.5), sin(ang - 1.5));
body = smin(body, cone(q, float2(0.15, 0.5), poll, 0.1, 0.045), 0.04);
body = min(body, smin(cone(q, poll, muzzle, 0.05, 0.03), cone(q, poll, poll + float2(-0.035, 0.065), 0.017, 0.006), 0.01));
float2 t1 = float2(-0.44, 0.5 + 0.025 * sin(time * 13.0)), t2 = float2(-0.58, 0.48 + 0.045 * sin(time * 13.0 - 1.5));
body = smin(body, min(cone(q, float2(-0.29, 0.55), t1, 0.028, 0.04), cone(q, t1, t2, 0.04, 0.01)), 0.02);
float rider = min(cone(q, float2(0.02, 0.66), float2(0.16, 0.74), 0.048, 0.042), length(q - float2(0.215, 0.79)) - 0.038);
rider = min(rider, min(cone(q, float2(0.03, 0.64), float2(0.15, 0.62), 0.04, 0.03), cone(q, float2(0.15, 0.62), float2(0.09, 0.53), 0.028, 0.022)));
rider = min(rider, min(cone(q, float2(0.15, 0.735), float2(0.23, 0.675), 0.022, 0.018), cone(q, float2(0.23, 0.675), float2(0.31, 0.67), 0.018, 0.016)));
rider = min(rider, max(ellipse(q - float2(0.215, 0.805), float2(0.045, 0.03)), 0.8 - q.y));
rider = min(rider, cone(q, float2(0.31, 0.67), lerp(poll, muzzle, 0.75), 0.006, 0.006)); // the reins
return float3(min(body, nearL), farL, rider);
}
float4 main(float2 uv : TEXCOORD) : COLOR
{
float u = size.y;
float2 px = float2(uv.x * size.x, (1.0 - uv.y) * u); // pixels, y up the screen
float head = progress * size.x;
float p = frac(time * 2.1) + 0.06 * beat; // stride phase, lurching ahead on the beat
float reach = 0.13 + 0.06 * level;
float3 acc = float3(0, 0, 0);
float cover = 0;
// Sepia from the palette: paper (light), ink (dark) and a mid tone.
float3 paper = lerp(float3(0.95, 0.87, 0.72), colorC.rgb, 0.25);
float3 ink = lerp(float3(0.16, 0.1, 0.05), colorB.rgb * 0.25, 0.3);
float3 mid = lerp(float3(0.5, 0.35, 0.2), colorA.rgb * 0.7, 0.35);
// Film grain, flicker, and the measuring grid of the backdrop (fine lines, a heavier one every bar height).
float grain = vnoise(px * 0.9 + floor(time * 24.0) * 17.0) - 0.5;
float flick = 1.0 + 0.05 * sin(time * 37.0) * sin(time * 23.0);
float2 gq = abs(frac(px / (0.2 * u) + 0.5) - 0.5) * 0.2 * u;
float big = step(abs(frac(px.x / u + 0.5) - 0.5) * u, 0.015 * u + 0.6);
float grid = max(smoothstep(0.9, 0.2, gq.x) * lerp(0.5, 1.0, big), smoothstep(0.9, 0.2, gq.y) * 0.45);
layer(acc, cover, paper, grid * 0.05 * step(head, px.x)); // a faint promise of the grid ahead
// Behind the playhead, a row of glass negatives: each holds a frozen frame of the stride, light on dark,
// developing in as the playhead passes.
float P = 1.45 * u, k = floor(px.x / P), pcx = (k + 0.5) * P;
float pd = boxD(float2(px.x - pcx, px.y - 0.5 * u), float2(0.68, 0.46) * u, 0.05 * u);
float dev = smoothstep(head + 0.3 * u, head - 0.5 * u, pcx);
float plate = smoothstep(0.5, -0.5, pd) * dev;
layer(acc, cover, ink * 0.6, smoothstep(0.5, -0.5, pd - 1.2) * dev * 0.8);
layer(acc, cover, lerp(ink, mid, 0.35 + 0.2 * grain) * flick, plate * 0.75);
layer(acc, cover, paper, grid * plate * 0.16);
float3 gh = horse((px - float2(pcx - 0.02 * u, 0.04 * u)) / (0.95 * u), frac(k * 0.0833), 0.15);
layer(acc, cover, lerp(paper, mid, 0.2), smoothstep(0.5, -0.5, min(min(gh.x, gh.y), gh.z) * 0.95 * u) * plate * 0.5);
// The live plate at the playhead: a positive print on cream paper that flashes like a shutter on every beat.
float ld = boxD(float2(px.x - head + 0.03 * u, px.y - 0.5 * u), float2(0.74, 0.47) * u, 0.04 * u);
float live = smoothstep(0.5, -0.5, ld);
float vig = 1.0 - 0.35 * pow(saturate(length(float2((px.x - head) / (0.8 * u), (px.y - 0.5 * u) / (0.55 * u)))), 3.0);
layer(acc, cover, ink * 0.7, smoothstep(0.5, -0.5, ld - 1.4) * 0.9);
layer(acc, cover, paper * (vig + 0.08 * grain) * flick * (1.0 + 0.2 * beat), live * 0.94);
layer(acc, cover, ink, grid * live * 0.22);
layer(acc, cover, ink, smoothstep(1.2, 0.3, abs(px.y - 0.045 * u)) * live * 0.5);
float sx = head + (hash1(floor(time * 12.0)) - 0.5) * 1.4 * u;
layer(acc, cover, ink, smoothstep(0.8, 0.2, abs(px.x - sx)) * step(0.6, hash1(floor(time * 12.0) + 3.0)) * live * 0.25);
// Dust kicked up by the hooves, drifting back and spreading; more of it when the song is loud.
for (int i = 0; i < 6; i++)
{
float fi = i;
float age = frac(time * 1.4 + fi / 6.0);
float2 dc = float2(head - (0.1 + 0.35 * hash1(fi + floor(time * 1.4 + fi / 6.0))) * u - age * 0.6 * u, (0.05 + 0.12 * age) * u);
float dr = (0.06 + 0.15 * age) * u;
float puff = smoothstep(dr, dr * 0.3, length(px - dc)) * (0.6 + 0.6 * vnoise((px - dc) / (0.05 * u) + fi * 9.0));
layer(acc, cover, lerp(mid, ink, 0.3), puff * (1.0 - age) * (0.5 + 0.5 * level) * live);
}
// The horse and rider, a dark photographic silhouette with a soft sheen along the top.
float2 q = (px - float2(head, 0.04 * u)) / u;
float3 h = horse(q, p, reach);
float dn = min(h.x, h.z);
float2 g = float2(ddx(dn), -ddy(dn));
float rim = smoothstep(-0.035, -0.006, dn) * saturate(dot(g / max(length(g), 0.00001), float2(-0.3, 0.95)));
layer(acc, cover, ink * 0.85, smoothstep(0.5, -0.5, h.y * u));
float3 coat = ink * (1.0 + 0.9 * saturate((q.y - 0.36) / 0.2)) + mid * rim * 0.6;
layer(acc, cover, coat, smoothstep(0.5, -0.5, h.x * u));
layer(acc, cover, lerp(ink, mid, 0.55 + 0.3 * saturate((q.y - 0.6) / 0.2)) + paper * rim * 0.25, smoothstep(0.5, -0.5, h.z * u));
return paint(acc / max(cover, 0.001), cover);
}