Boot Sequence
by MusicBar, progress bar
An old green phosphor terminal loads the song in a bracketed bar of block characters, with a blinking cursor and a real percent counter riding the playhead, flickering and tearing 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 081f2cb99abff0a5a7b22af1abb3b1accb5ce7cd9a9d5c2751b3770855d41980
//! name: Boot Sequence
//! author: MusicBar
//! kind: progress
//! description: An old green phosphor terminal loads the song in a bracketed bar of block characters, with a blinking cursor and a real percent counter riding the playhead, flickering and tearing on every beat.
// 3x5 pixel digits and a percent sign, one number per glyph: five rows of three bits, top row first.
float glyph(float n)
{
return n < 0.5 ? 31599.0 : n < 1.5 ? 11415.0 : n < 2.5 ? 29671.0 : n < 3.5 ? 29391.0 : n < 4.5 ? 23497.0 :
n < 5.5 ? 31183.0 : n < 6.5 ? 31215.0 : n < 7.5 ? 29266.0 : n < 8.5 ? 31727.0 : n < 9.5 ? 31695.0 : 21157.0;
}
// Is pixel (col 0..2, row 0..4 from the top) of glyph n lit?
float bit(float n, float col, float row)
{
float idx = (4.0 - row) * 3.0 + (2.0 - col);
return step(0.5, frac(glyph(n) / exp2(idx + 1.0)));
}
float sdBox(float2 p, float2 b) { float2 d = abs(p) - b; return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); }
// 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;
float p = max(2.0, floor(u / 9.0)); // one character pixel, whole screen pixels so it stays crisp
float2 px = float2(uv.x * size.x, (1.0 - uv.y) * u - floor((u - 9.0 * p) * 0.5)); // screen-up, so digits never turn over
float row = floor(px.y / p);
// On the beat the picture flickers and a few scanlines tear sideways.
float rnd = frac(sin(row * 12.9 + floor(time * 24.0) * 7.3) * 4375.85);
px.x -= floor(beat * step(0.55, rnd) * p * (1.0 + 2.0 * rnd) + 0.5);
float cw = 4.0 * p; // a character cell: 3 pixels and a gap
float m = floor(0.4 * u);
float N = max(floor((size.x - 2.0 * m) / cw) - 2.0, 6.0); // block cells between the brackets
float j = floor((px.x - m) / cw);
float col = floor((px.x - m) / p) - j * 4.0;
float inCol = step(col, 2.5);
float F = floor(progress * N + 0.0001); // filled blocks
float pct = floor(progress * 100.0 + 0.0001);
float cs = min(F + 3.0, N - 3.0); // first cell of the counter
// What this cell holds: a filled block, the cursor, a placeholder, a bracket, or a counter glyph.
float isBlock = step(0.5, j) * step(j, F + 0.1);
float isCursor = step(abs(j - F - 1.0), 0.1) * step(j, N + 0.1);
float k = j - cs;
float isCount = step(-0.1, k) * step(k, 3.1);
float digit = k < 0.5 ? floor(pct / 100.0) : (k < 1.5 ? fmod(floor(pct / 10.0), 10.0) : (k < 2.5 ? fmod(pct, 10.0) : 10.0));
float shown = k < 0.5 ? step(99.5, pct) : (k < 1.5 ? step(9.5, pct) : 1.0);
float isEmpty = step(F + 1.9, j) * step(j, N + 0.1) * (1.0 - isCount);
// Pixels: a block fills 3 x 7, the digits sit in the middle 3 x 5; over filled blocks the counter shows inverted.
float tall = step(0.5, row) * step(row, 7.5);
float gr = 6.0 - row;
float gOn = bit(digit, col, gr) * step(-0.1, gr) * step(gr, 4.1) * inCol * shown * isCount;
float blockOn = isBlock * tall * inCol;
float on = lerp(blockOn, abs(blockOn - gOn), isCount);
float blink = saturate(step(0.45, frac(time * 1.9)) + beat);
float cur = isCursor * tall * inCol * blink;
// Brackets: as tall as the screen row, with two-pixel serifs.
float cap = step(row, 0.5) + step(7.5, row);
float full = step(-0.5, row) * step(row, 8.5);
float lb = step(abs(j), 0.1) * full * saturate(step(col, 0.5) + step(col, 1.5) * cap);
float rb = step(abs(j - N - 1.0), 0.1) * full * saturate(step(1.5, col) * step(col, 2.5) + step(0.5, col) * step(col, 2.5) * cap);
// Placeholders ahead: a sparse light-shade dither, barely there.
float dith = isEmpty * tall * inCol * step(0.5, frac((col + row) * 0.5)) * step(0.5, frac(row * 0.5 + 0.25));
// The look of a phosphor screen: scanlines, a little mains hum, a flash on the beat, and newly filled
// blocks still glowing hot; filled blocks shimmer with the spectrum.
float s = spectrum(frac(j / 20.0));
float flick = (0.93 + 0.07 * sin(time * 53.0)) * (1.0 + 0.5 * beat);
float scan = 0.68 + 0.32 * step(0.5, frac(px.y * 0.5));
float heat = 0.5 + 0.3 * s * s + 0.35 * exp(-(F - j) / 8.0) + 0.5 * exp(-(F - j) / 1.5) * isBlock;
float3 phos = colorA.rgb;
float3 hot = lerp(colorA.rgb, colorC.rgb, 0.7);
float3 acc = float3(0, 0, 0);
float cover = 0;
// Bloom: a soft halo above and below the filled run, the cursor and the counter.
float run = sdBox(float2(px.x - m - (0.5 + 0.5 * (F + 1.0)) * cw, px.y - 4.5 * p), float2(0.5 * F * cw, 3.5 * p));
float cd = sdBox(float2(px.x - m - (F + 1.0 + 0.4) * cw, px.y - 4.5 * p), float2(1.5 * p, 3.5 * p));
float bloom = exp(-max(run, 0.0) / (0.14 * u)) * step(0.5, F) * 0.22 + exp(-max(cd, 0.0) / (0.16 * u)) * 0.4 * blink;
layer(acc, cover, phos, bloom * (0.6 + 0.4 * level) * flick);
// A dark readout patch behind the counter, so the digits hold up on a light taskbar too.
float plate = sdBox(float2(px.x - m - (cs + 2.0) * cw + 0.5 * p, px.y - 4.5 * p), float2(2.0 * cw + 0.5 * p, 3.5 * p)) - 0.5 * p;
layer(acc, cover, colorB.rgb * 0.08, smoothstep(0.5, -0.5, plate) * 0.6);
layer(acc, cover, colorB.rgb, dith * 0.45 * scan);
layer(acc, cover, phos * heat * flick * scan + hot * 0.25 * isCount * (1.0 - isBlock), on);
layer(acc, cover, phos * flick * scan, saturate(lb + rb) * 0.9);
layer(acc, cover, lerp(hot, float3(1, 1, 1), 0.3) * flick * scan, cur);
return paint(acc / max(cover, 0.001), cover);
}