Strike
by MusicBar, progress bar
A glossy marbled bowling ball rolls down a polished wooden lane to the playhead, mirrored in the varnish, while the neon arrows pulse with the music and the ten pins at the end wobble 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 d00c53c1c5456dc8e9271c2c73783295dcdc21fe2fef0b591d3082fa60f6763a
//! name: Strike
//! author: MusicBar
//! kind: progress
//! description: A glossy marbled bowling ball rolls down a polished wooden lane to the playhead, mirrored in the varnish, while ten pins wait at the far end and wobble on every beat.
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 a = hash1(i.x + i.y * 57.0), b = hash1(i.x + 1.0 + i.y * 57.0), c = hash1(i.x + (i.y + 1.0) * 57.0), d = hash1(i.x + 1.0 + (i.y + 1.0) * 57.0);
return lerp(lerp(a, b, f.x), lerp(c, d, 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); }
// 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 pin's half width at height h (in pin heights): a fat belly, a slim neck, a round head.
float pinR(float h) { return 0.05 + 0.13 * exp(-pow((h - 0.3) / 0.2, 2.0)) + 0.06 * exp(-pow((h - 0.82) / 0.09, 2.0)); }
float pinD(float2 p) { return min(max(abs(p.x) - pinR(p.y), max(-p.y, p.y - 0.84)), length(p - float2(0.0, 0.84)) - 0.11); }
// The ball seen at s (offset over radius): marbled resin, three finger holes riding the spin, glossy highlights.
float4 ballLook(float2 s, float spin, float r)
{
float d = length(s);
float3 n = float3(s, sqrt(saturate(1.0 - d * d)));
float3 b = n;
b.yz = rot(b.yz, 0.9); // the spin axis leans toward us, so the holes come and go
b.xy = rot(b.xy, spin);
float m = sin(b.x * 7.0 + 3.0 * sin(b.y * 6.0 + b.z * 4.0) + 2.0 * sin(b.z * 8.0 - b.x * 3.0));
float3 col = lerp(colorA.rgb * 0.3, colorA.rgb * 0.85, smoothstep(-0.7, 0.5, m));
col = lerp(col, lerp(colorB.rgb, float3(1, 1, 1), 0.15), smoothstep(0.16, 0.0, abs(m - 0.3)) * 0.85); // swirling veins
float aw = 1.0 / r;
float3 hd = float3(acos(dot(b, normalize(float3(0.95, -0.3, 0.1)))), acos(dot(b, normalize(float3(0.8, 0.45, 0.3)))), acos(dot(b, normalize(float3(0.7, 0.55, -0.15)))));
float3 hr = float3(0.22, 0.17, 0.17);
float3 hm = smoothstep(hr + aw, hr - aw, hd);
float holes = max(hm.x, max(hm.y, hm.z));
float lip = max(smoothstep(aw * 2.0, 0.0, abs(hd.x - hr.x)), max(smoothstep(aw * 2.0, 0.0, abs(hd.y - hr.y)), smoothstep(aw * 2.0, 0.0, abs(hd.z - hr.z))));
col = lerp(col, float3(0.02, 0.02, 0.03), holes * 0.95) + lip * 0.25 * saturate(r / 12.0 - 0.5);
float dif = saturate(dot(n, normalize(float3(-0.5, 0.65, 0.6))));
float fres = pow(1.0 - n.z, 2.0);
float3 env = lerp(float3(0.1, 0.1, 0.14), float3(0.85, 0.55, 0.28), smoothstep(0.1, -0.5, n.y)); // dark hall above, warm lane below
col = col * (0.25 + 0.85 * dif) + env * fres * 0.6;
col += pow(saturate(dot(n, normalize(float3(-0.35, 0.5, 1.0)))), 70.0) * 1.2 + pow(saturate(dot(n, normalize(float3(-0.35, 0.5, 1.0)))), 8.0) * 0.18;
col += lerp(colorB.rgb, float3(1, 1, 1), 0.3) * smoothstep(0.82, 1.0, d) * saturate(n.x + 0.2) * 0.6; // rim light from the pins' end
return float4(col, smoothstep(0.5, -0.5, (d - 1.0) * r));
}
static const float2 PINS[10] = { float2(3, 1.5), float2(2, 1), float2(1, 0.5), float2(3, 0.5), float2(0, 0), float2(2, 0), float2(1, -0.5), float2(3, -0.5), float2(2, -1), float2(3, -1.5) };
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 deckX = size.x - 1.55 * u; // the head pin's spot
float lit = max(smoothstep(head + 0.6 * u, head - 0.6 * u, px.x), smoothstep(deckX - 1.4 * u, deckX - 0.6 * u, px.x));
float3 acc = float3(0, 0, 0);
float cover = 0;
// The lane, seen low from the side: maple boards with grain and seams, warm where the lights are on.
float laneTop = 0.34 * u, t = px.y / laneTop;
float onLane = step(px.y, laneTop);
float bi = floor(t * 11.0), bf = frac(t * 11.0);
float grain = vnoise(float2(px.x / (1.3 * u) + bi * 13.0, bf * 2.0)) * 0.6 + vnoise(float2(px.x / (0.25 * u) + bi * 7.0, bf * 6.0)) * 0.4;
float3 wood = lerp(float3(0.62, 0.38, 0.18), float3(0.88, 0.64, 0.36), hash1(bi) * 0.6 + grain * 0.4);
wood *= (1.0 - 0.45 * smoothstep(0.12, 0.0, min(bf, 1.0 - bf))) * (1.0 - 0.25 * t);
float glossBand = exp(-abs(t - 0.62) / 0.08) * (0.55 + 0.45 * sin(px.x / u * 0.9 - time * 0.4)) + 0.6 * exp(-abs(t - 0.86) / 0.04);
wood += float3(1.0, 0.9, 0.75) * glossBand * 0.35 * lit; // overhead lights mirrored in the varnish
layer(acc, cover, wood * lerp(0.55, 1.0, lit), onLane * lerp(0.2, 0.95, lit));
// The far gutter: a dark rounded channel with a lit lip.
float gy = (px.y - laneTop) / (0.06 * u);
float3 gut = float3(0.1, 0.1, 0.12) * (0.6 + 0.8 * gy * gy) + float3(0.8, 0.82, 0.9) * exp(-abs(gy - 1.0) / 0.12) * 0.5;
layer(acc, cover, gut, step(0.0, gy) * step(gy, 1.0) * lerp(0.25, 0.9, lit));
// Target arrows in a V every few meters, glowing in the second color and pulsing with the music where the ball has been.
float as = 6.0 * u;
float ax = frac(px.x / as) * as - 0.5 * as;
float k = clamp(floor(t * 6.0 - 0.5), 0.0, 4.0);
float2 ap = float2(ax + abs(k - 2.0) * 0.45 * u, px.y - (k + 1.0) / 6.0 * laneTop);
float arrow = max(abs(ap.y) - 0.036 * u * saturate((0.13 * u - ap.x) / (0.26 * u)), max(abs(ap.x) - 0.13 * u, 0.4 * abs(ap.y) - ap.x - 0.1 * u));
float pulse = lit * (0.5 + 0.6 * level + 0.9 * beat);
layer(acc, cover, lerp(float3(0.25, 0.12, 0.05), colorB.rgb * (0.8 + 0.6 * pulse), lit), smoothstep(0.7, -0.7, arrow) * onLane * lerp(0.35, 1.0, lit));
layer(acc, cover, colorB.rgb, exp(-max(arrow, 0.0) / (0.04 * u)) * onLane * pulse * 0.4);
// The oil track the ball leaves: a bright sheen along its line behind it.
float back = max(head - px.x, 0.0);
layer(acc, cover, float3(1.0, 0.95, 0.85), exp(-abs(px.y - 0.17 * u) / (0.012 * u)) * step(px.x, head) * (0.15 + 0.5 * exp(-back / (4.0 * u))) * onLane);
// A soft spot of light on the pin deck at the far end.
float2 sp = (px - float2(deckX + 0.35 * u, 0.25 * u)) / float2(1.2 * u, 0.35 * u);
layer(acc, cover, lerp(colorC.rgb, float3(1, 0.95, 0.85), 0.6), exp(-dot(sp, sp) * 2.0) * 0.18);
// Ten pins, back rows first; each wobbles on the beat and shows in the varnish below.
float H = 0.58 * u;
for (int i = 0; i < 10; i++)
{
float2 pr = PINS[i];
float2 base = float2(deckX + pr.x * 0.22 * u + pr.y * 0.08 * u, 0.17 * u + pr.y * 0.07 * u);
float sc = H * (1.0 - 0.07 * pr.y);
float wob = beat * 0.42 * sin(time * 22.0 + i * 2.3) * (0.7 + 0.3 * hash1(i));
float2 p = rot(px - base, wob) / sc;
float2 pm = rot((px - base) * float2(1.0, -1.0), -wob) / sc;
float d = pinD(p) * sc;
layer(acc, cover, float3(0.9, 0.88, 0.85), smoothstep(0.5, -0.5, pinD(pm) * sc) * step(px.y, base.y) * 0.22 * saturate(1.0 + pm.y * 2.0));
float nx = clamp(p.x / pinR(p.y), -1.0, 1.0);
float3 pc = float3(0.97, 0.96, 0.93) * (0.5 + 0.5 * sqrt(1.0 - nx * nx) - 0.18 * nx) * (1.0 - 0.1 * pr.y);
pc = lerp(pc, colorC.rgb * (0.6 + 0.4 * sqrt(1.0 - nx * nx)), step(abs(abs(p.y - 0.68) - 0.04), 0.017));
pc += smoothstep(0.25, 0.0, abs(nx + 0.45)) * 0.25 + lerp(colorB.rgb, float3(1, 1, 1), 0.4) * smoothstep(0.65, 1.0, nx) * 0.35;
layer(acc, cover, float3(0.12, 0.1, 0.12), smoothstep(0.5, -0.5, d - 1.1));
layer(acc, cover, pc, smoothstep(0.5, -0.5, d));
}
// The ball: rolling at the playhead, spinning faster when the song is loud, mirrored in the lane.
float r = 0.27 * u;
float2 bc = float2(head, 0.17 * u + r);
float spin = time * 6.5 + head / r;
float4 mir = ballLook((float2(px.x, 0.34 * u - px.y) - bc) / r, spin, r);
layer(acc, cover, mir.rgb * 0.8, mir.a * step(px.y, 0.17 * u) * 0.4 * saturate(1.0 - (0.17 * u - px.y) / (0.2 * u)));
float2 shq = (px - float2(head, 0.17 * u)) / float2(r * 1.1, 0.05 * u);
layer(acc, cover, float3(0.05, 0.02, 0.0), exp(-dot(shq, shq) * 2.0) * 0.5);
float2 s = (px - bc) / r;
layer(acc, cover, colorA.rgb, exp(-max(length(s) - 1.0, 0.0) * r / (0.1 * u)) * (0.2 + 0.25 * level));
// Spin arcs whipping round the upper back of the ball, longer when the song is loud.
float sa = atan2(s.y, -s.x) - 0.75 - 0.15 * sin(time * 6.0);
float ring = min(abs(length(s) - 1.22), abs(length(s) - 1.42)) * r;
float arcs = smoothstep(max(0.7, 0.018 * u) + 0.6, max(0.7, 0.018 * u) - 0.4, ring) * smoothstep(0.5 + 0.5 * level, 0.0, abs(sa));
layer(acc, cover, lerp(colorB.rgb, float3(1, 1, 1), 0.5), arcs * (0.5 + 0.4 * level));
layer(acc, cover, float3(0.03, 0.03, 0.05), smoothstep(0.5, -0.5, (length(s) - 1.0) * r - 1.2));
float4 ball = ballLook(s, spin, r);
layer(acc, cover, ball.rgb, ball.a);
return paint(acc / max(cover, 0.001), cover);
}