Laser Heist

by MusicBar, progress bar

A sleek thief in black sneaks, crouches and rolls under sweeping red security lasers to the playhead; the beams pulse on every beat and switch off once the thief is past.

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 1ac3fc2e7f8ac504a5d6095f9e280f29feb82c419df80bde75ac742ed5765266

//! name: Laser Heist
//! author: MusicBar
//! kind: progress
//! description: A sleek thief in a black catsuit sneaks, crouches and rolls to the playhead under sweeping red security lasers that pulse on the beat, and every beam behind is switched off.

float hash1(float n) { return frac(sin(n * 127.1 + 311.7) * 43758.5453); }

// Smooth value noise, for the haze the beams shine through.
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); }
float sdSeg(float2 p, float2 a, float2 b) { float2 pa = p - a, ba = b - a; return length(pa - ba * saturate(dot(pa, ba) / dot(ba, ba))); }
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; }

// Smooth union, so limbs flow into the body instead of meeting like tubes.
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); }

// The middle joint (knee or elbow) of a two-bone limb from a to b, bones of length l, bent to one side.
float2 joint(float2 a, float2 b, float l, float side)
{
    float2 d = b - a;
    float len = max(length(d), 0.001);
    return (a + b) * 0.5 + float2(-d.y, d.x) / len * side * sqrt(max(l * l - len * len * 0.25, 0.0));
}

// Distance from a laser beam: the line through emitter e leaving at angle a.
float beamD(float2 p, float2 e, float a) { return abs(dot(p - e, float2(-sin(a), cos(a)))); }

// 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); }

// The thief in bar heights, feet at the origin, facing right: x = near body, y = far limbs, z = goggles.
// w is the stride; tuck curls the body into a ball and spin turns that ball for the roll.
float3 thief(float2 p, float w, float tuck, float spin, float dip)
{
    float2 C = float2(0.03, 0.25);
    p = C + rot(p - C, -spin);
    float2 h = lerp(float2(0.0, 0.34 - dip), C + float2(-0.06, -0.06), tuck);
    float2 n = lerp(h + float2(0.2, 0.14), C + float2(0.07, 0.07), tuck);
    float2 f1 = lerp(float2(0.04 + 0.16 * sin(w), 0.03 + 0.08 * saturate(cos(w))), C + float2(-0.04, -0.13), tuck);
    float2 f2 = lerp(float2(0.04 - 0.16 * sin(w), 0.03 + 0.08 * saturate(-cos(w))), C + float2(-0.08, -0.12), tuck);
    float2 sh = n + float2(-0.02, -0.03);
    float2 a1 = lerp(sh + float2(0.16, -0.08 + 0.03 * sin(w)), C + float2(0.15, -0.06), tuck);
    float2 a2 = lerp(sh + float2(0.03, -0.17 - 0.03 * sin(w)), C + float2(0.11, -0.1), tuck);
    float2 sp = normalize(n - h);
    float2 hd = n + normalize(sp + float2(0.6, 0.0)) * 0.085;
    float2 bk = float2(-sp.y, sp.x) * 0.075;
    float2 k1 = joint(h, f1, 0.21, 1.0), k2 = joint(h, f2, 0.21, 1.0);
    float2 e1 = joint(sh, a1, 0.12, -1.0), e2 = joint(sh, a2, 0.12, -1.0);

    // Near side: head, torso, the pack on the back, the near leg and arm, blended at the joints.
    float dn = smin(length(p - hd) - 0.068, sdSeg(p, h, n) - 0.064, 0.025);
    dn = smin(dn, sdSeg(p, lerp(h, n, 0.3) + bk, lerp(h, n, 0.85) + bk) - 0.048, 0.02);
    dn = smin(dn, smin(sdSeg(p, h, k1) - 0.045, sdSeg(p, k1, f1) - 0.032, 0.015), 0.03);
    dn = min(dn, sdSeg(p, f1, f1 + float2(0.06, 0.0)) - 0.024);
    dn = smin(dn, smin(sdSeg(p, sh, e1) - 0.032, sdSeg(p, e1, a1) - 0.025, 0.012), 0.02);
    // Far side: the other leg and arm, drawn darker behind.
    float df = smin(sdSeg(p, h, k2) - 0.043, sdSeg(p, k2, f2) - 0.031, 0.015);
    df = min(df, min(sdSeg(p, f2, f2 + float2(0.06, 0.0)) - 0.023, smin(sdSeg(p, sh, e2) - 0.03, sdSeg(p, e2, a2) - 0.024, 0.012)));
    // Night-vision goggles on the face.
    float2 face = normalize(float2(1.0, -0.15) + sp * 0.3);
    float2 gc = hd + face * 0.05, gs = float2(-face.y, face.x) * 0.02;
    return float3(dn, df, sdSeg(p, gc - gs, gc + gs) - 0.022);
}

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 so the thief never hangs upside down
    float head = progress * size.x;
    float3 red = colorA.rgb, acc = float3(0, 0, 0);
    float cover = 0, pulse = 0.7 + 0.3 * level + 0.9 * beat;

    // Beams are armed ahead of the thief and dead behind; the last ones stutter as they cut out.
    float armed = smoothstep(head + 0.3 * u, head + 0.9 * u, px.x);
    armed *= lerp(step(0.3, hash1(floor(time * 18.0) + floor(px.x / u))), 1.0, smoothstep(head + 0.9 * u, head + 1.6 * u, px.x));

    // The laser grid: emitters on the top and bottom edges throw beams that cross in X's, each sweeping on its own.
    float cw = 1.6 * u, k = floor(px.x / cw), j = floor(px.x / cw - 0.5), sw = time * 0.7;
    float d1 = beamD(px, float2(k * cw, u), -0.95 + 0.28 * sin(sw + k * 1.9));
    float d2 = beamD(px, float2((k - 1.0) * cw, u), -0.95 + 0.28 * sin(sw + (k - 1.0) * 1.9));
    float d3 = beamD(px, float2((j + 0.5) * cw, 0.0), 0.95 + 0.28 * sin(sw * 1.3 + j * 2.3));
    float d4 = beamD(px, float2((j - 0.5) * cw, 0.0), 0.95 + 0.28 * sin(sw * 1.3 + (j - 1.0) * 2.3));
    float dm = min(min(d1, d2), min(d3, d4));
    float gr = 0.06 * u * (1.0 + 0.8 * beat), wd = max(0.5, 0.014 * u) * (1.0 + 0.8 * beat);
    float haze = 0.5 + 0.5 * vnoise(px / (0.3 * u) + float2(time * 0.8, time * 0.3));
    float glowB = exp(-d1 / gr) + exp(-d2 / gr) + exp(-d3 / gr) + exp(-d4 / gr);
    float core = smoothstep(wd + 0.7, wd - 0.3, dm);
    layer(acc, cover, red, glowB * haze * pulse * 0.3 * armed);
    layer(acc, cover, red * 1.1, core * armed * (0.7 + 0.3 * haze) * min(pulse, 1.2));
    layer(acc, cover, lerp(red, float3(1, 1, 1), 0.75), smoothstep(wd * 0.45 + 0.5, wd * 0.45 - 0.5, dm) * armed * saturate(pulse - 0.2));
    layer(acc, cover, red * 0.4, core * (1.0 - armed) * 0.2);

    // The emitters: small dark housings, red light while armed, green once disarmed.
    float ek = floor(px.x / cw + 0.5) * cw, ej = (floor(px.x / cw) + 0.5) * cw;
    float2 te = px - float2(ek, u * 0.965), be = px - float2(ej, u * 0.035);
    float dE = min(boxD(te, float2(0.075, 0.035) * u, 0.015 * u), boxD(be, float2(0.075, 0.035) * u, 0.015 * u));
    float onT = smoothstep(head + 0.3 * u, head + 0.9 * u, ek), onB = smoothstep(head + 0.3 * u, head + 0.9 * u, ej);
    float3 led = te.x * te.x + te.y * te.y < be.x * be.x + be.y * be.y ? lerp(colorC.rgb, red, onT) : lerp(colorC.rgb, red, onB);
    float dL = min(length(te), length(be));
    layer(acc, cover, float3(0.16, 0.17, 0.2), smoothstep(0.5, -0.5, dE));
    layer(acc, cover, led, exp(-dL / (0.05 * u)) * 0.6 + smoothstep(0.022 * u + 0.5, 0.022 * u - 0.5, dL));

    // The prize at the far end: a cut gem on a slim pedestal, throwing a sparkle on the beat.
    float2 g = (px - float2(size.x - 0.6 * u, 0.6 * u)) / u;
    float crown = max(max(g.y - 0.07, -g.y), (abs(g.x) - 0.15 + 0.857 * g.y) * 0.76);
    float pav = max(g.y, (abs(g.x) - 0.15 - 0.882 * g.y) * 0.75);
    float dGem = min(crown, pav) * u;
    float hwG = g.y > 0.0 ? 0.15 - 0.857 * g.y : 0.15 + 0.882 * g.y;
    float fac = floor(g.x / max(hwG, 0.01) * 2.5 + 2.5) + step(0.0, g.y) * 7.0;
    float fs = hash1(fac + floor(time * 2.0 + fac * 0.3) * 0.1);
    float3 gemC = lerp(lerp(colorB.rgb, float3(0.7, 0.9, 1.0), 0.6) * 0.55, float3(1, 1, 1), fs);
    gemC += 0.25 * (0.5 + 0.5 * cos(6.2832 * (fs + time * 0.4 + float3(0.0, 0.33, 0.67))));
    float dPed = min(boxD(g - float2(0.0, -0.36), float2(0.055, 0.23), 0.01), boxD(g - float2(0.0, -0.15), float2(0.1, 0.022), 0.01)) * u;
    layer(acc, cover, colorB.rgb, exp(-length(g - float2(0.0, -0.02)) / 0.18) * 0.25);
    layer(acc, cover, float3(0.12, 0.13, 0.16) + colorB.rgb * 0.35 * smoothstep(-0.04, 0.05, g.x), smoothstep(0.5, -0.5, dPed));
    layer(acc, cover, gemC, smoothstep(0.5, -0.5, dGem));
    float2 sq = abs(g - float2(-0.06, 0.04));
    float star = (exp(-sq.x / 0.008 - sq.y / 0.12) + exp(-sq.y / 0.008 - sq.x / 0.12)) * (0.35 + 0.4 * sin(time * 3.0) * sin(time * 3.0) + beat);
    layer(acc, cover, float3(1, 1, 1), star);

    // The thief: q in bar heights from the playhead. Every few seconds it tucks and rolls; it dips low on the beat.
    float S = 1.25 * u;                                        // the thief's scale: a bit taller than the bar when standing
    float2 q = (px - float2(head, 0.0)) / S;
    float cyc = frac(time / 3.4 + 0.15);
    float tuck = smoothstep(0.5, 0.6, cyc) * smoothstep(1.0, 0.9, cyc);
    float spin = -6.2832 * smoothstep(0.56, 0.92, cyc);
    float w = time * 4.6, dip = 0.06 * beat + 0.02 * abs(sin(w));
    [branch] if (abs(q.x) < 0.7)                               // only pixels near the thief pay for drawing it
    {
        float3 T = thief(q, w, tuck, spin, dip), To = thief(q + float2(0.012, 0.012), w, tuck, spin, dip);
        float d0 = min(T.x, T.y);
        float lit = saturate((min(To.x, To.y) - d0) / 0.017);  // how much the outline faces the beams, up ahead

        // A floor shadow, a faint cool halo so the dark suit reads on any taskbar, and the swoosh of the roll.
        layer(acc, cover, float3(0, 0, 0), exp(-length(float2(q.x * 0.7, q.y * 4.0)) / 0.12) * 0.35);
        layer(acc, cover, colorB.rgb, exp(-max(d0, 0.0) / 0.04) * 0.22);
        float2 rq = q - float2(0.03, 0.25);
        float trailA = frac((atan2(rq.y, rq.x) - spin) / 6.2832 + 0.02);
        float swoosh = smoothstep(0.03, 0.0, abs(length(rq) - 0.29)) * smoothstep(0.55, 0.0, trailA) * tuck * step(0.6, cyc) * step(cyc, 0.93);
        layer(acc, cover, lerp(colorB.rgb, float3(1, 1, 1), 0.3), swoosh * 0.7);

        // The suit: near black, laser red rim light from the beams ahead, a cool rim elsewhere.
        float band = smoothstep(-0.05, -0.008, d0);
        float3 suit = float3(0.045, 0.045, 0.06) + (red * lit * (0.75 + 0.3 * pulse) + colorB.rgb * (1.0 - lit) * 0.45) * band;
        layer(acc, cover, suit * 0.55, smoothstep(0.5, -0.5, T.y * S));
        layer(acc, cover, suit, smoothstep(0.5, -0.5, T.x * S));

        // The goggles glow, a little brighter on the beat.
        layer(acc, cover, colorC.rgb, exp(-max(T.z, 0.0) / 0.035) * (0.55 + 0.4 * beat));
        layer(acc, cover, lerp(colorC.rgb, float3(1, 1, 1), 0.5), smoothstep(0.5, -0.5, T.z * S));
    }
    return paint(acc / max(cover, 0.001), cover);
}