Rewind
by MusicBar, progress bar
A glowing tape playback line runs to a bright tape head at the playhead, with red and cyan fringing, scanlines and tracking noise rolling through like an old video tape, and the picture jolts 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 06cdd996fe4d4df8ed5f3bfaf21c8d7aa294cca5169a44b8f32d854d5297e217
//! name: Rewind
//! author: MusicBar
//! kind: progress
//! description: A glowing tape playback line runs to a bright tape head at the playhead, through old video tape scanlines, color fringes and tracking noise rolling down the picture, which jumps on every beat.
float hash2(float2 p) { float3 q = frac(float3(p.x, p.y, p.x) * 0.1031); q += dot(q, q.yzx + 33.33); return frac((q.x + q.y) * q.z); }
// 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 clean picture before the tape mangles it, at (x, y) in pixels with y down the bar:
// returns premultiplied color and coverage.
float4 picture(float x, float y, float head, float u)
{
float3 acc = float3(0, 0, 0);
float cover = 0;
float cy = 0.5 * u;
float played = smoothstep(0.5, -0.5, x - head);
// The counter scale under the line: a tick every bar height, a longer one every five.
float t1 = abs(frac(x / u + 0.5) - 0.5) * u;
float t5 = abs(frac(x / (5.0 * u) + 0.5) - 0.5) * 5.0 * u;
float tk = smoothstep(max(0.6, 0.025 * u) + 0.5, max(0.6, 0.025 * u) - 0.5, min(t1, t5));
float tLen = lerp(0.1, 0.2, step(t5, t1 + 0.01)) * u;
layer(acc, cover, lerp(colorB.rgb, float3(1, 1, 1), 0.3), tk * step(cy + 0.2 * u, y) * step(y, cy + 0.2 * u + tLen) * lerp(0.35, 0.8, played));
// The empty tape ahead: a thin dim guide line.
layer(acc, cover, colorB.rgb, smoothstep(max(0.6, 0.02 * u) + 0.5, max(0.6, 0.02 * u) - 0.5, abs(y - cy)) * 0.35);
// The played line: a bloom, then a neon core streaked with tape grain sliding toward the head.
float hb = 0.085 * u * (1.0 + 0.2 * level);
float dy = abs(y - cy) - hb;
float3 c = lerp(colorB.rgb, colorA.rgb, smoothstep(head - 9.0 * u, head - 0.5 * u, x));
layer(acc, cover, c, exp(-max(dy, 0.0) / (0.16 * u)) * played * (0.35 + 0.3 * level));
float grain = hash2(float2(floor((x - time * u * 2.5) / (0.45 * u)), floor(y / max(1.0, 0.04 * u))));
float3 core = c * (0.75 + 0.45 * grain);
core = lerp(core, float3(1, 1, 1), 0.6 * exp(-abs(y - cy) / (0.035 * u)));
layer(acc, cover, core, smoothstep(0.5, -0.5, dy) * played);
// The tape head: a white-hot upright with a halo, and a play mark riding just ahead of it.
float dHead = max(abs(x - head) - 0.045 * u, abs(y - cy) - 0.36 * u);
float2 q = float2(x - head - 0.13 * u, y - 0.18 * u);
float dPlay = max(-q.x, (q.x * 0.13 + abs(q.y) * 0.2 - 0.026 * u) / 0.2385);
float dMark = min(dHead, dPlay);
layer(acc, cover, lerp(colorC.rgb, colorA.rgb, 0.3), exp(-max(dMark, 0.0) / (0.1 * u)) * (0.6 + 0.4 * beat));
layer(acc, cover, float3(0.05, 0.02, 0.08), smoothstep(0.5, -0.5, dMark - 1.2) * 0.8);
layer(acc, cover, lerp(colorC.rgb, float3(1, 1, 1), 0.5), smoothstep(0.5, -0.5, dMark));
return float4(acc, cover);
}
float4 main(float2 uv : TEXCOORD) : COLOR
{
float u = size.y;
float2 px = uv * size; // pixels, y down the bar
float head = progress * size.x;
float frame = floor(time * 30.0);
float p = max(2.0, floor(u / 12.0)); // scanline pitch
float row = floor(px.y / p);
// Two tracking bands roll down the picture: a wide slow one and a thin quick one.
float yb1 = (frac(time * 0.21) * 2.2 - 0.6) * u;
float yb2 = (frac(time * 0.43 + 0.5) * 2.2 - 0.6) * u;
float band = max(smoothstep(0.13 * u, 0.0, abs(px.y - yb1)), 0.7 * smoothstep(0.05 * u, 0.0, abs(px.y - yb2)));
// The picture hops on the beat, every line shivers, and inside a band the lines tear sideways.
float y = px.y + beat * 0.07 * u;
float tear = (hash2(float2(row, frame)) - 0.5) * u * (0.02 + 0.16 * beat) + band * u * (0.12 + 0.1 * hash2(float2(row, frame + 3.0)));
tear += wave(uv.y) * u * 0.04 * level; // the sound itself wobbles the lines a little
float x = px.x + tear;
// Color fringes: red reads the picture a little to one side, green and blue to the other, wider on the beat;
// and a faint ghost of the picture trails to the right, like a worn tape.
float ca = u * (0.018 + 0.025 * level + 0.08 * beat);
float4 r = picture(x + ca, y, head, u);
float4 gb = picture(x - ca, y, head, u);
float4 ghost = picture(x - 0.3 * u, y, head, u) * 0.22;
float3 acc = float3(r.r, gb.g, gb.b);
float cover = max(r.a, gb.a);
acc += ghost.rgb * (1.0 - cover);
cover += ghost.a * (1.0 - cover);
// Scanlines and grain.
float scan = lerp(0.5, 1.0, step(frac(px.y / p), 0.55));
acc *= scan * (0.85 + 0.3 * hash2(floor(px) + frame * 1.7));
cover *= lerp(0.75, 1.0, scan);
// Tracking noise: fine white specks of random length in the bands, strong over the played part.
float near = smoothstep(head + 1.5 * u, head - 0.5 * u, px.x);
float fine = floor(px.y / max(1.0, floor(p * 0.5)));
float len = u * (0.04 + 0.25 * hash2(float2(fine, 7.0)));
float n = hash2(float2(floor((x + frame * 5.0) / len), fine + frame * 13.0));
float3 lit = acc;
layer(lit, cover, float3(0.95, 0.95, 1.0) * (0.6 + 0.4 * n), step(0.74, n) * band * lerp(0.06, 0.9, near));
// Dropouts: now and then a thin bright scratch flicks across the played tape.
float drop = step(0.995, hash2(float2(floor(x / (0.3 * u)), fine + frame * 7.0))) * step(abs(px.y - 0.5 * u), 0.3 * u) * near;
layer(lit, cover, float3(1, 1, 1), drop * 0.75);
return paint(lit / max(cover, 0.001), cover);
}