Dragon Dance
của MusicBar, thanh tiến trình
Rồng vàng dài từ đầu thanh tới chỗ đang phát, khúc nào cũng có sào đỡ, thân uốn lượn theo nhạc, đầu rồng đuổi theo viên ngọc sáng, tới nhịp là há miệng và một gợn sóng chạy dọc thân.
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 bfc9df227ec616d1d9964ba01f8e6070130da7384f92ec1eaf17ef96261fbee3
//! name: Dragon Dance
//! author: MusicBar
//! kind: progress
//! description: A long festival dragon held up on poles undulates from the start of the bar to the playhead, its body rolling in waves with the music while its head chases a glowing pearl.
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 ellipse(float2 p, float2 r) { float k0 = length(p / r); return k0 * (k0 - 1.0) / max(length(p / (r * r)), 0.0001); }
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); }
// Distance to a tapered stroke from a (radius ra) to b (radius rb).
float taper(float2 p, float2 a, float2 b, float ra, float rb)
{
float2 pa = p - a, ba = b - a;
float h = saturate(dot(pa, ba) / dot(ba, ba));
return length(pa - ba * h) - lerp(ra, rb, h);
}
// 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);
}
// A shape with a dark rim round it, so it holds on a light taskbar too; m masks it.
void ink(inout float3 acc, inout float cover, float3 rgb, float d, float m, float aa)
{
layer(acc, cover, colorB.rgb * 0.15, smoothstep(aa, -aa, d - aa * 1.3) * m);
layer(acc, cover, rgb, smoothstep(aa, -aa, d) * m);
}
// How strongly the body swings at s bar heights behind the head: bass near the head, treble toward the tail.
float swing(float s) { return (0.07 + 0.06 * level + 0.14 * spectrum(saturate(s / 24.0) * 0.7)) * smoothstep(0.0, 1.8, s); }
// Height of the body's center line: a wave rolling back from the head, plus a ripple that runs down it on each beat.
float spineY(float s, float A)
{
float bump = 0.14 * beat * exp(-pow((s - 0.7 - (1.0 - beat) * 4.5) / 0.7, 2.0));
return 0.5 + 0.08 * sin(time * 1.9 - 0.7) * exp(-s / 2.0) + A * sin(s * 1.5 - time * 3.4) + bump;
}
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 poles always stand
float head = progress * size.x;
float2 q = float2(px.x - head, px.y) / u; // bar heights, head at x = 0
float aa = 1.0 / u, s = -q.x; // one pixel; how far back along the dragon
float sEnd = head / u - 0.55; // where the body meets the tail fin, near the start of the bar
float3 acc = float3(0, 0, 0);
float cover = 0;
// The pearl ahead, bobbing on its own pole, and its glow.
float2 P = float2(0.95, 0.56 + 0.1 * sin(time * 1.9));
float pr = 0.1 * (1.0 + 0.25 * beat), dp = length(q - P);
layer(acc, cover, colorC.rgb, exp(-max(dp - pr, 0.0) / (0.12 + 0.1 * beat)) * (0.35 + 0.25 * level + 0.4 * beat));
// Poles: one under every hoop and one under the pearl, rising and falling with the body.
float sp = 0.9;
float si = clamp(floor((s - 0.45) / sp + 0.5), 0.0, floor((sEnd - 0.45) / sp)) * sp + 0.45;
float topY = spineY(si, swing(si)), held = step(0.0, sEnd - si);
float dPole = abs(s - si) * u - 0.022 * u;
float3 wood = lerp(float3(0.35, 0.05, 0.04), colorB.rgb * 0.8, 0.3) * (0.7 + 0.5 * smoothstep(0.02, -0.02, s - si));
layer(acc, cover, float3(0.04, 0.02, 0.02), smoothstep(1.6, 0.4, dPole) * step(q.y, topY) * held * 0.7);
layer(acc, cover, wood, smoothstep(0.5, -0.5, dPole) * step(q.y, topY) * held);
layer(acc, cover, wood, smoothstep(0.5, -0.5, abs(q.x - P.x) * u - 0.02 * u) * step(q.y, P.y));
// The body: a cloth tube on hoops, bulging between them, rolling with the wave.
float A = swing(s), ph = s * 1.5 - time * 3.4;
float yc = spineY(s, A), slope = A * 1.5 * cos(ph);
float hoop = frac((s - 0.45) / sp + 0.5) - 0.5; // -0.5..0.5 between hoops, 0 at a hoop
float w = (0.135 + 0.012 * cos(hoop * 6.283)) * lerp(0.75, 1.0, smoothstep(sEnd, sEnd - 1.5, s));
float dist = (q.y - yc) / sqrt(1.0 + slope * slope), v = dist / w;
float inside = step(0.05, s) * step(s, sEnd + 0.05);
float dBody = max(abs(dist) - w, max(0.05 - s, s - sEnd - 0.05));
// A fringe of tassels hanging under the belly, swaying.
float fy = (yc - w + 0.01 - q.y) / (0.09 + 0.02 * sin(s * 31.0));
float fs = abs(frac((s + 0.03 * fy * sin(time * 5.0 + s * 3.0)) * 14.0) - 0.5) - 0.34 + 0.22 * fy * fy;
layer(acc, cover, lerp(colorB.rgb, float3(1, 0.85, 0.4), 0.25 + 0.5 * fy), smoothstep(0.08, -0.08, fs) * step(0.0, fy) * step(fy, 1.0) * inside);
// A crest of little flame tufts along the back, flickering and leaning toward the tail.
float ft = frac(s / 0.13 + 0.15 * sin(time * 5.0 + s * 2.0) * (dist - w) / 0.07);
float dFin = (dist - w) - 0.07 * pow(sin(3.1416 * pow(ft, 0.6)), 1.5);
ink(acc, cover, lerp(colorB.rgb, float3(1, 0.85, 0.4), saturate((dist - w) / 0.07) * 0.7), dFin, step(0.0, dist) * inside, aa);
// Scales wrap round the tube; a cream belly with plates; dark hoops ringed in gold; a sheen along the back.
float2 sc = float2(s / 0.11, asin(clamp(v, -1.0, 1.0)) * 2.2);
sc.x += 0.5 * floor(sc.y);
float scl = length((frac(sc) - float2(0.5, 0.0)) * float2(1.0, 1.3));
float round = sqrt(saturate(1.0 - v * v)), ring = abs(hoop) * sp;
float3 hide = colorA.rgb * (0.4 + 0.7 * round) * (0.75 + 0.45 * smoothstep(0.5, 0.1, scl));
hide = lerp(hide, colorA.rgb * 0.35, smoothstep(0.09, 0.02, abs(scl - 0.5)) * 0.8);
float3 belly = lerp(colorA.rgb, float3(1, 0.95, 0.8), 0.6) * (0.55 + 0.45 * round) * (0.8 + 0.2 * step(0.3, frac(s / 0.07)));
hide = lerp(hide, belly, smoothstep(-0.35, -0.5, v)) + float3(1, 0.95, 0.8) * exp(-abs(v - 0.45) / 0.12) * 0.25;
hide = lerp(hide, colorB.rgb * 0.5 * (0.5 + 0.5 * round), smoothstep(0.035, 0.02, ring));
ink(acc, cover, lerp(hide, lerp(colorA.rgb, float3(1, 0.9, 0.5), 0.5), smoothstep(0.012, 0.0, abs(ring - 0.035))), dBody, 1.0, aa);
// The tail fin at the start of the bar, a flame fan that waves.
float2 tq = rot(q - float2(-sEnd + 0.04, spineY(sEnd, swing(sEnd))), 0.25 * sin(time * 3.0));
float tang = atan2(tq.y, -tq.x + 0.0001), tr = length(tq);
float lobes = 0.4 * (0.72 + 0.28 * cos(tang * 6.0 + 0.6 * sin(time * 4.0 + tr * 8.0)));
ink(acc, cover, lerp(colorB.rgb, float3(1, 0.85, 0.4), smoothstep(0.1, 0.4, tr) * 0.7) * (0.75 + 0.25 * sin(tang * 30.0)), max(tr - lobes, (abs(tang) - 1.05) * tr), step(0.0, sEnd), aa);
// The head at the playhead: rides the front of the wave, tilts up toward the pearl, snaps its jaw on the beat.
float2 hq = rot(q - float2(0.02, spineY(0.0, 0.0)), -(0.12 * sin(time * 1.9 + 0.3) + 0.08 * beat));
float jaw = 0.18 + 0.4 * beat + 0.06 * sin(time * 4.0);
float2 J = float2(0.15, -0.03);
float2 jq = rot(hq - J, jaw) + J; // the pixel seen in the jaw's closed pose
// A long whisker from the far side of the nose, streaming back over the head and waving.
float wx = 0.62 - hq.x;
ink(acc, cover, lerp(colorC.rgb, float3(1, 1, 1), 0.4), abs(hq.y - 0.05 - wx * 0.3 - 0.06 * wx * sin(wx * 8.0 - time * 7.0)) * 0.95 - lerp(0.02, 0.007, saturate(wx)), step(0.0, wx) * step(wx, 1.0), aa);
// Mane: flames of fur behind the skull, licking backward.
float2 mq = hq - float2(0.02, 0.03);
float ma = atan2(mq.y, mq.x + 0.0001);
float dMane = ellipse(mq - float2(-0.04, 0.0), float2(0.26, 0.16)) - 0.07 * pow(abs(sin(ma * 4.0 + time * 4.0 + length(mq) * 10.0)), 0.6) * smoothstep(0.05, -0.15, mq.x);
ink(acc, cover, lerp(colorB.rgb * 0.85, float3(1, 0.85, 0.4), smoothstep(-0.07, 0.03, dMane + 0.05) * 0.8) * (0.8 + 0.2 * sin(ma * 30.0)), dMane, 1.0, aa);
// Antler: a tapered horn sweeping back with one tine.
float dHorn = min(taper(hq, float2(0.2, 0.12), float2(-0.02, 0.27), 0.045, 0.03), taper(hq, float2(-0.02, 0.27), float2(-0.22, 0.3), 0.03, 0.012));
dHorn = min(dHorn, taper(hq, float2(0.05, 0.22), float2(0.07, 0.35), 0.022, 0.01));
ink(acc, cover, lerp(float3(1, 0.95, 0.8), colorA.rgb, 0.4) * (0.75 + 0.25 * step(0.5, frac(hq.x * 20.0))), dHorn, 1.0, aa);
// Mouth: a white beard, a dark cavity, the lower jaw with its teeth.
float2 kq = rot(hq - J, 0.5 * jaw) - float2(0.24, -0.04);
float2 bq = rot(jq - float2(0.2, -0.15), 0.15 * sin(time * 3.0));
float bang = atan2(bq.y, bq.x + 0.0001);
float dBeard = ellipse(bq, float2(0.1, 0.075)) - 0.03 * abs(sin(bang * 6.0 + time * 4.0)) * smoothstep(0.0, -0.05, bq.y);
ink(acc, cover, lerp(float3(1, 0.97, 0.88), colorA.rgb, 0.25) * (0.8 + 0.2 * sin(bang * 25.0)), dBeard, 1.0, aa);
ink(acc, cover, lerp(float3(0.3, 0.02, 0.04), float3(0.85, 0.2, 0.25), saturate(kq.y / 0.1 + 0.5)), ellipse(kq, float2(0.24, 0.02 + 0.17 * jaw)), 1.0, aa);
float3 jawC = lerp(colorA.rgb * (0.5 + 0.4 * saturate((jq.y + 0.12) / 0.07)), float3(1, 0.98, 0.92), step(-0.05 - 0.03 * (1.0 - abs(frac(jq.x / 0.05) - 0.5) * 2.0), jq.y) * step(0.24, jq.x));
ink(acc, cover, jawC, ellipse(jq - float2(0.4, -0.085), float2(0.25, 0.05)), 1.0, aa);
// Upper head: skull and a long snout with a raised nose, a brow, teeth and a fang.
float dHead = smin(ellipse(hq - float2(0.2, 0.05), float2(0.17, 0.13)), ellipse(hq - float2(0.45, 0.02), float2(0.24, 0.07)), 0.06);
dHead = smin(dHead, length(hq - float2(0.64, 0.07)) - 0.055, 0.04);
ink(acc, cover, colorA.rgb * (0.5 + 0.6 * saturate((hq.y + 0.05) / 0.2)) + float3(1, 0.95, 0.8) * exp(-abs(hq.y - 0.08 - 0.15 * (hq.x - 0.4) * (hq.x - 0.4)) / 0.02) * 0.2, dHead, 1.0, aa);
float tu = abs(frac(hq.x / 0.05) - 0.5) * 2.0;
float teeth = step(hq.y, -0.03) * step(-0.05 - 0.03 * tu, hq.y) * step(0.28, hq.x) * step(hq.x, 0.6);
layer(acc, cover, float3(1, 0.98, 0.92), max(teeth, smoothstep(aa, -aa, taper(hq, float2(0.57, -0.03), float2(0.58, -0.12), 0.018, 0.004))));
ink(acc, cover, lerp(colorB.rgb, float3(1, 0.85, 0.4), 0.3), ellipse(rot(hq - float2(0.3, 0.17), -0.35), float2(0.1, 0.035)), 1.0, aa);
layer(acc, cover, colorB.rgb * 0.9, smoothstep(aa, -aa, length(hq - float2(0.64, 0.07)) - 0.025));
// The eye: white, a fierce pupil looking at the pearl, a glint.
float2 E = float2(0.3, 0.1);
float dEye = length(hq - E) - 0.058;
float3 eyeC = lerp(float3(1, 1, 0.9), float3(0.05, 0.03, 0.03), smoothstep(aa, -aa, length(hq - E - float2(0.02, 0.006)) - 0.032));
eyeC = lerp(eyeC, float3(1, 1, 1), smoothstep(aa, -aa, length(hq - E - float2(0.032, 0.02)) - 0.012));
layer(acc, cover, float3(0.05, 0.02, 0.02), smoothstep(aa, -aa, dEye - 0.015));
layer(acc, cover, eyeC, smoothstep(aa, -aa, dEye));
// The pearl: a hot white core, the accent color, and a swirl of flame round it.
layer(acc, cover, lerp(colorC.rgb, float3(1, 0.95, 0.8), 0.3), smoothstep(0.02, -0.02, dp - pr * (1.35 + 0.25 * sin(atan2(q.y - P.y, q.x - P.x + 0.0001) * 3.0 - time * 8.0 + dp * 40.0))) * 0.55);
layer(acc, cover, lerp(colorC.rgb, float3(1, 1, 1), smoothstep(pr, 0.0, dp) * 0.85), smoothstep(aa, -aa, dp - pr));
return paint(acc / max(cover, 0.001), cover);
}