Fin
của MusicBar, thanh tiến trình
Vây cá mập rẽ làn nước đen ngòm tiến tới chỗ đang phát, để lại vệt sóng hình chữ V, mặt nước lấp lánh ánh trăng theo nhạc, tới nhịp là dưới nước lóe lên một vệt đỏ rợn người.
Cách cài, mã SHA-256 và mã nguồn
Bấm Áp dụng: MusicBar tự tải về, kiểm tra mã SHA-256 rồi mặc lên taskbar; có rồi thì mặc luôn. Cần MusicBar 1.8 trở lên.
SHA-256 860a3f5873060db03b2d595b07781cfeb3499f66e253b1c55a7f4915aebd6f3e
//! name: Fin
//! author: MusicBar
//! kind: progress
//! description: A dorsal fin slices through dark water to the playhead, spreading a V wake behind it over a long dark shape below, with glints on the swell that shimmer with the music and a tense red flash under the surface on every beat.
float hash1(float n) { return frac(sin(n * 127.1 + 311.7) * 43758.5453); }
// Smooth value noise, for foam and broken crests.
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); }
// 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;
float2 px = float2(uv.x * size.x, (1.0 - uv.y) * u); // y up the screen: the far side of the water is at the top
float head = progress * size.x;
float3 acc = float3(0, 0, 0);
float cover = 0;
float back = (head - px.x) / u; // bar heights behind the fin
float played = smoothstep(-0.3, 0.5, back);
float yw = 0.37 * u + 0.025 * u * sin(time * 2.1); // the waterline at the fin, riding the swell
float sh = spectrum(saturate(abs(back) / 12.0)); // bass near the fin, treble far from it
float3 foam = lerp(colorC.rgb, float3(1, 1, 1), 0.3);
// The water: deep and dark where the fin has cut through, only a faint sheen ahead.
float depth = px.y / u;
float3 water = lerp(colorB.rgb * 0.3 + float3(0.0, 0.02, 0.05), colorB.rgb * 0.12 + 0.01, depth);
layer(acc, cover, water, lerp(0.1, 0.8, played));
// The long shape under the surface, its tail sweeping. On the beat a red flash pulses up through the water
// behind it, so the shape stands out black against the red.
float2 bq = (px - float2(head - 0.3 * u, yw - 0.07 * u)) / u;
bq.y -= 0.05 * sin(time * 3.2 + bq.x * 3.0) * saturate(-bq.x - 0.1);
float tailF = max(abs(abs(bq.y) - (-bq.x - 0.68) * 0.45) - 0.025, max(-bq.x - 0.95, bq.x + 0.66));
float bodyD = min((length(bq / float2(0.68, 0.085)) - 1.0) * 0.085, tailF);
float flash = beat * (0.75 + 0.5 * sh) + 0.1 + 0.05 * sin(time * 1.3);
layer(acc, cover, colorA.rgb, exp(-max(bodyD, 0.0) / (0.1 + 0.06 * beat)) * flash * 0.8 * played);
layer(acc, cover, float3(0.0, 0.01, 0.025), smoothstep(0.012, -0.012, bodyD) * (0.45 + 0.4 * beat) * played);
layer(acc, cover, colorB.rgb * 1.3, smoothstep(0.015, 0.0, abs(bodyD)) * 0.2 * played);
// Swells: crest lines packed tighter toward the far side, broken up, lit by the moon and shimmering with the music.
float ph = pow(depth, 0.75) * 8.0 + 0.45 * sin(px.x / (0.9 * u) + time * 0.7) + 0.25 * sin(px.x / (0.37 * u) - time * 1.1) - time * 0.3;
float crest = smoothstep(1.3, 0.0, abs(frac(ph) - 0.5) / max(fwidth(ph), 0.0001));
float brk = smoothstep(0.5, 0.85, vnoise(float2(px.x / (0.45 * u) + time * 0.25, floor(ph) * 7.0)));
layer(acc, cover, lerp(colorB.rgb, foam, 0.55), crest * brk * (0.12 + 0.5 * sh + 0.2 * level) * lerp(0.45, 1.0, played));
// Glints: little stars of moonlight winking on the swell, more of them when it is loud.
float2 gp = px / (0.17 * u), gc = floor(gp), gq = abs(frac(gp) - 0.5);
float gh = hash1(gc.x * 17.0 + gc.y * 131.0);
float glint = (exp(-gq.x * 40.0 - gq.y * 9.0) + exp(-gq.y * 40.0 - gq.x * 9.0)) * step(0.9 - 0.1 * level - 0.08 * sh, gh) * saturate(sin(time * (2.5 + 4.0 * gh) + gh * 40.0));
layer(acc, cover, foam, glint * lerp(0.5, 1.0, played));
// The wake: a V of foam spreading back from the fin (the far arm climbs, the near arm drops faster),
// feathered with little Kelvin ripples, and a churned streak along the whole path behind.
float wb = max(head - 0.12 * u - px.x, 0.0) / u;
float behind = step(px.x, head - 0.12 * u);
float wkw = (0.008 + 0.012 * wb) * u;
float yUp = px.y - yw - 0.2 * wb * u, yDn = px.y - yw + 0.3 * wb * u;
float arms = exp(-abs(yUp) / wkw) + exp(-abs(yDn) / wkw);
float feather = 0.75 + 0.25 * sin(wb * 26.0 - time * 8.0);
layer(acc, cover, foam, arms * feather * exp(-wb / 2.4) * behind * (0.75 + 0.3 * level));
float churn = exp(-abs(px.y - yw) / ((0.03 + 0.012 * min(wb, 6.0)) * u)) * exp(-wb / 14.0) * behind;
layer(acc, cover, lerp(colorB.rgb, foam, 0.5), churn * (0.2 + 0.35 * vnoise(float2(px.x / (0.2 * u) + time * 1.5, px.y / (0.1 * u)))));
// The fin: a curved blade, convex up its leading edge and hooked back at the tip, rocking with the swell.
float2 f = rot((px - float2(head, yw)) / (1.1 * u), 0.05 * sin(time * 1.7) + 0.06 * beat);
float t = saturate(f.y / 0.5);
float xl = -0.14 + 0.33 * pow(1.0 - t, 0.55);
float xt = -0.19 + 0.06 * t + 0.035 * sin(3.1416 * t);
float dFin = max(max(xt - f.x, f.x - xl), max(-f.y, f.y - 0.5));
float fa = max(fwidth(dFin), 0.0001);
float fin = smoothstep(fa, -fa, dFin);
float lead = smoothstep(0.035, 0.0, xl - f.x); // moonlight along the leading edge
float3 skin = lerp(float3(0.2, 0.24, 0.28), float3(0.36, 0.41, 0.46), saturate((f.x - xt) / max(xl - xt, 0.01)));
skin = lerp(skin, float3(0.08, 0.1, 0.12), smoothstep(0.08, 0.0, f.y) * 0.6); // wet and dark at the waterline
skin += foam * lead * 0.55 + colorA.rgb * beat * 0.12 * smoothstep(0.2, 0.0, f.y);
layer(acc, cover, float3(0.02, 0.03, 0.04), smoothstep(fa * 2.5, 0.0, dFin) * 0.6); // a dark outline for light taskbars
layer(acc, cover, skin, fin);
// White water where the fin cuts: a curl of foam at the leading edge and froth along its base.
float2 fq = (px - float2(head + 0.12 * u, yw)) / u;
float froth = smoothstep(0.35, 0.75, vnoise(px / (0.05 * u) + float2(time * 6.0, 0.0)));
float bow = smoothstep(1.0, 0.4, length(fq / float2(0.13, 0.05 + 0.03 * level))) * (0.6 + 0.4 * froth);
float base = smoothstep(0.025 * u, 0.0, abs(px.y - yw)) * smoothstep(0.32 * u, 0.0, abs(px.x - head + 0.02 * u)) * froth;
layer(acc, cover, foam, max(bow, base) * 0.9);
// Spray flicked forward off the leading edge on the beat, falling back.
for (int i = 0; i < 5; i++)
{
float fi = i, st = 1.0 - beat;
float2 dp = float2(0.15, 0.03) + float2(0.12 + 0.4 * hash1(fi + 3.0), 0.35 + 0.5 * hash1(fi + 9.0)) * st * 0.7 - float2(0.0, 1.5 * st * st);
layer(acc, cover, foam, step(0.05, beat) * beat * smoothstep(0.5, -0.5, length(px - float2(head, yw) - dp * u) - max(0.6, 0.016 * u)));
}
return paint(acc / max(cover, 0.001), cover);
}