Kaiju Night
của MusicBar, thanh tiến trình
Quái vật sừng to lừng lững dậm chân qua thành phố về đêm tới chỗ đang phát, phía sau chỉ còn đống đổ nát với mấy đám cháy, nhà cửa phía trước rung lên theo nhịp còn lõi lửa trên ngực nó bừng sáng theo tiếng bass.
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 4ea27300588f7b35144cf3bf60ecad301375a105e4ebdb4a65430f5988860657
//! name: Kaiju Night
//! author: MusicBar
//! kind: progress
//! description: A hulking horned beast stomps through a night city to the playhead, leaving rubble and small fires behind, while the lit skyline ahead shakes on the beat and the core in its chest flares with the bass.
float hash1(float n) { return frac(sin(n * 127.1 + 311.7) * 43758.5453); }
// Smooth value noise, for flames, smoke, hide and rubble.
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); }
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); }
float ellipse(float2 p, float2 r) { float k0 = length(p / r); return k0 * (k0 - 1.0) / max(length(p / (r * r)), 0.0001); }
// A capsule from a to b whose radius tapers from ra to rb: limbs, horns, claws.
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); }
// The middle joint (knee or elbow) of a two-bone limb from a to b, bones of length l, bent to one side.
float2 joint(float2 a, float2 b, float l, float side) { float2 d = b - a; float len = max(length(d), 0.001); return (a + b) * 0.5 + float2(-d.y, d.x) / len * side * sqrt(max(l * l - len * len * 0.25, 0.0)); }
// Fire light: deep red, orange, yellow, near white.
float3 heat(float t) { return lerp(lerp(float3(0.55, 0.06, 0.02), float3(1.0, 0.45, 0.08), saturate(t * 2.0)), float3(1.0, 0.92, 0.65), saturate(t * 2.0 - 1.0)); }
// A searchlight from o along dir (bar heights): a cone that widens and fades.
float spot(float2 p, float2 o, float2 dir) { float2 v = p - o; float a = dot(v, dir); return step(0.0, a) * smoothstep(0.02 + a * 0.13, 0.0, abs(v.x * dir.y - v.y * dir.x)) * exp(-a / 2.5); }
// 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 beast in bar heights, feet at the origin, facing right: x = near side, y = far limbs and far horn.
// ph is the stride (a foot lands every half turn), bob the body's dip, jaw how far the mouth hangs open.
float2 beast(float2 p, float ph, float bob, float jaw)
{
float2 B = float2(-0.07, 0.5 + bob), Hd = float2(0.17, 0.69 + bob), J = Hd + float2(-0.06, -0.035);
float d = smin(ellipse(rot(p - B, 0.35), float2(0.21, 0.27)), ellipse(p - float2(-0.06, 0.36 + bob), float2(0.2, 0.14)), 0.05);
d = smin(d, ellipse(rot(p - B - float2(0.02, 0.2), 0.5), float2(0.16, 0.1)), 0.06); // the hunched shoulders
d = smin(d, ellipse(rot(p - Hd, 0.2), float2(0.12, 0.075)), 0.06); // the head, low on a thick neck
d = min(d, ellipse(rot(p - J, jaw) - float2(0.1, -0.012), float2(0.1, 0.035))); // the jaw, hinged at the back
d = min(d, min(taper(p, Hd + float2(-0.04, 0.04), Hd + float2(-0.02, 0.16), 0.038, 0.02), taper(p, Hd + float2(-0.02, 0.16), Hd + float2(0.08, 0.24), 0.02, 0.003)));
d = min(d, taper(p, Hd + float2(0.09, 0.035), Hd + float2(0.13, 0.095), 0.022, 0.002)); // a stubby nose horn
// The tail: thick at the hips, sweeping down to the ground and swaying.
float t = saturate((-0.17 - p.x) / 0.68);
float ty = 0.34 + bob - 0.3 * pow(t, 0.8) + 0.03 * sin(time * 1.6 + t * 4.0) * t;
d = smin(d, max(max((abs(p.y - ty) - 0.11 * (1.0 - t) - 0.012) * 0.85, -0.87 - p.x), p.x + 0.1), 0.06);
// Legs like pillars: the feet swap every step, lifted high and slammed down.
float2 hip = float2(-0.08, 0.3 + bob), hip2 = hip + float2(0.03, 0.02);
float2 f1 = float2(-0.13 * cos(ph), 0.04 + 0.1 * saturate(sin(ph))), f2 = float2(0.13 * cos(ph) - 0.03, 0.04 + 0.1 * saturate(-sin(ph)));
float2 k1 = joint(hip, f1, 0.17, 1.0), k2 = joint(hip2, f2, 0.17, 1.0);
d = smin(d, smin(taper(p, hip, k1, 0.12, 0.085), taper(p, k1, f1, 0.08, 0.065), 0.03), 0.04);
d = smin(d, ellipse(p - f1 - float2(0.035, -0.01), float2(0.095, 0.04)), 0.02);
// Arms hanging forward with hooked claws, swinging against the stride.
float2 S = B + float2(0.11, 0.14), hand = S + float2(0.12 + 0.04 * sin(ph), -0.21);
float2 el = joint(S, hand, 0.14, -1.0);
d = smin(d, smin(taper(p, S, el, 0.075, 0.055), taper(p, el, hand, 0.055, 0.04), 0.02), 0.04);
d = min(d, min(taper(p, hand, hand + float2(0.05, -0.04), 0.022, 0.003), taper(p, hand, hand + float2(0.012, -0.065), 0.02, 0.003)));
float2 S2 = S + float2(-0.07, 0.02), hand2 = S2 + float2(0.12 - 0.04 * sin(ph), -0.2);
float2 el2 = joint(S2, hand2, 0.14, -1.0);
// The far arm, leg and horn, drawn darker behind.
float df = min(smin(taper(p, S2, el2, 0.065, 0.05), taper(p, el2, hand2, 0.05, 0.035), 0.02), smin(taper(p, hip2, k2, 0.11, 0.08), taper(p, k2, f2, 0.075, 0.06), 0.03));
df = min(df, ellipse(p - f2 - float2(0.035, -0.01), float2(0.09, 0.038)));
df = min(df, min(taper(p, Hd + float2(-0.09, 0.03), Hd + float2(-0.08, 0.14), 0.032, 0.018), taper(p, Hd + float2(-0.08, 0.14), Hd + float2(-0.01, 0.21), 0.018, 0.003)));
return float2(d, df);
}
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 city always stands upright
float head = progress * size.x;
float3 acc = float3(0, 0, 0);
float cover = 0, bass = spectrum(0.04);
// The stride: a footfall every half turn. The ground quakes with each one, and harder on the beat.
float ph = time * 2.4, since = frac(ph / 3.14159), stomp = exp(-since * 7.0), quake = max(beat, 0.6 * stomp);
float ahead = smoothstep(head + 0.2 * u, head + 0.4 * u, px.x), behind = 1.0 - smoothstep(head - 0.6 * u, head - 0.2 * u, px.x);
// The fire glow on the haze behind, and searchlights from the city ahead hunting for the beast.
layer(acc, cover, float3(1.0, 0.4, 0.12), exp(-px.y / (0.3 * u)) * 0.18 * behind);
float2 sp = px / u, o1 = float2(head / u + 2.6, 0.05), o2 = float2(head / u + 4.3, 0.05), tg = float2(head / u, 0.75);
float beams = spot(sp, o1, normalize(tg - o1 + float2(0.0, 0.5 * sin(time * 0.9)))) + spot(sp, o2, normalize(tg - o2 + float2(0.3, 0.8 + 0.6 * sin(time * 0.7 + 2.0))));
layer(acc, cover, lerp(colorB.rgb, float3(1, 1, 1), 0.6), beams * 0.16);
// Far towers in the haze, only where the city still stands.
float fw = 0.36 * u, fk = floor(px.x / fw), fd = max(abs(px.x - (fk + 0.5) * fw) - fw * 0.42, px.y - u * (0.36 + 0.36 * hash1(fk * 7.7)));
layer(acc, cover, colorB.rgb * 0.25 + 0.03, smoothstep(0.5, -0.5, fd) * 0.4 * ahead);
// The city ahead: towers with lit windows, shaking with every quake (the nearest ones most).
float bw = 0.52 * u, kb = floor(px.x / bw), hb = hash1(kb * 3.1 + 1.0);
float shake = quake * exp(-max(px.x - head, 0.0) / (5.0 * u)) * 0.035 * u * sin(time * 75.0 + kb * 2.0);
float2 bp = px - float2((kb + 0.5) * bw + shake, 0.0);
float bH = u * (0.22 + 0.34 * hb), bW = bw * (0.3 + 0.12 * hash1(kb * 5.3)), crownH = 0.08 * u * step(0.6, hb);
float db = min(max(abs(bp.x) - bW, bp.y - bH), max(abs(bp.x) - bW * 0.5, bp.y - bH - crownH));
float2 wg = float2((bp.x + bW) / (0.075 * u), bp.y / (0.085 * u)), wc = floor(wg), wf = frac(wg);
float lit = step(hash1(wc.x * 13.0 + wc.y * 7.0 + kb * 31.0), 0.42) * step(0.3, wf.x) * step(wf.x, 0.75) * step(0.3, wf.y) * step(wf.y, 0.78);
lit *= step(0.5, wc.y) * step(bp.y, bH - 0.04 * u) * step(abs(bp.x), bW - 0.02 * u) * (1.0 - step(0.55, quake * hash1(wc.x + wc.y * 3.0 + floor(time * 20.0))));
float3 bc = float3(0.04, 0.05, 0.09) + colorB.rgb * (0.12 * saturate(bp.y / bH) + 0.35 * smoothstep(-1.5, 0.0, db));
layer(acc, cover, lerp(bc, colorC.rgb * (0.85 + 0.3 * level), lit), smoothstep(0.5, -0.5, db) * 0.9 * ahead);
float blink = step(0.5, frac(time * 0.7 + hb * 3.0)) * step(0.6, hb);
layer(acc, cover, float3(1.0, 0.2, 0.15), exp(-length(bp - float2(0.0, bH + crownH + 0.02 * u)) / (0.03 * u)) * blink * ahead);
// Behind: small fires dot the wreck. fq is this pixel seen from its cell's fire, in bar heights.
float fc = floor(px.x / (0.95 * u)), fr = hash1(fc * 2.7 + 5.0);
float2 fq = (px - float2((fc + 0.35 + 0.3 * fr) * 0.95 * u, 0.05 * u)) / u;
float burns = behind * step(0.3, fr), fl = 0.75 + 0.25 * sin(time * 11.0 + fc) * sin(time * 7.3 + fc * 2.0);
float warm = pow(saturate(1.0 - length(fq * float2(1.0, 1.3)) / 0.32), 2.0) * burns * fl;
// A ridge of rubble and broken stumps with jagged tops, black against the glow, edged in firelight.
float rx = px.x / u;
float rh = u * (0.035 + 0.08 * vnoise(float2(rx * 6.0, 1.0)) + 0.035 * vnoise(float2(rx * 25.0, 3.0)));
float sH = u * (0.12 + 0.24 * hash1(kb * 9.1)) + 0.07 * u * (vnoise(float2(rx * 30.0, 5.0)) - 0.5);
float dr = min(px.y - rh, max(max(abs(px.x - (kb + 0.5) * bw) - bw * (0.18 + 0.15 * hash1(kb * 6.2)), px.y - sH), 0.45 - hash1(kb * 4.4)));
float3 rc = float3(0.05, 0.045, 0.05) + float3(1.0, 0.38, 0.1) * (warm * 0.9 + 0.6 * smoothstep(-0.05 * u, 0.0, dr) * (0.35 + warm));
layer(acc, cover, rc, smoothstep(0.5, -0.5, dr) * behind * 0.92);
// The fires: flickering tongues, a warm glow, and smoke curling up and back.
float fht = (0.12 + 0.22 * (fr - 0.3) + 0.08 * bass) * fl;
float tongue = (vnoise(float2(fq.x * 22.0, fq.y * 9.0 - time * 8.0)) - 0.5) * 1.2 + (vnoise(float2(fq.x * 9.0 + 4.0, fq.y * 5.0 - time * 5.0)) - 0.5) * 0.6;
float I = (1.0 - fq.y / fht) * 1.1 - abs(fq.x) / ((0.07 + 0.05 * fr) * (1.0 - 0.5 * saturate(fq.y / fht))) + tongue;
float sy = fq.y - fht * 0.6;
float smoke = smoothstep(0.05 + 0.25 * sy, 0.0, abs(fq.x + 0.35 * sy)) * step(0.0, sy) * smoothstep(0.3, 0.75, vnoise(float2(fq.x * 7.0 + time * 0.4, fq.y * 6.0 - time * 1.3)));
layer(acc, cover, float3(0.2, 0.17, 0.17) + float3(0.3, 0.1, 0.02) * exp(-sy / 0.15), smoke * exp(-sy / 0.55) * 0.5 * burns);
layer(acc, cover, heat(0.3), warm * 0.4);
layer(acc, cover, heat(I), smoothstep(0.0, 0.2, I) * step(-0.03, fq.y) * burns);
// The beast, dipping as each foot lands. Only pixels near it pay for drawing it.
float2 q = (px - float2(head, 0.0)) / u;
float bob = -0.025 * stomp + 0.012 * sin(ph * 2.0), jaw = 0.06 + 0.45 * beat;
[branch] if (q.x > -1.0 && q.x < 0.45)
{
float2 D = beast(q, ph, bob, jaw);
float d0 = min(D.x, D.y), band = smoothstep(-0.05, -0.006, d0);
float facing = smoothstep(-0.12, 0.12, q.x + 0.02 - 0.3 * (q.y - 0.5)); // the front faces the city, the back the fires
float2 core = float2(0.07, 0.52 + bob);
float cr = 0.045 * (1.0 + 0.5 * bass + 0.5 * beat), dc = length(q - core), flare = 0.4 + 0.7 * bass + 0.6 * beat;
// The core's light spills around the body.
layer(acc, cover, colorA.rgb, exp(-max(dc - cr, 0.0) / (0.1 + 0.08 * beat)) * flare * 0.55);
// Dark hide: lit by the core, cracked with glowing veins, a cool rim from the city and a warm one from the fires.
float3 hide = float3(0.07, 0.065, 0.08) * (0.75 + 0.5 * vnoise(q * 34.0)) + colorA.rgb * exp(-dc / 0.12) * flare * 0.8;
float vein = smoothstep(0.07, 0.0, abs(vnoise(q * 14.0 + 3.0) - 0.5)) * exp(-dc / 0.15) * flare;
hide = lerp(hide, lerp(colorA.rgb, float3(1, 1, 1), 0.25), saturate(vein));
hide += (colorB.rgb * facing * 0.85 + float3(1.0, 0.45, 0.15) * (1.0 - facing) * 0.45) * band;
layer(acc, cover, hide * 0.55, smoothstep(0.5, -0.5, D.y * u));
layer(acc, cover, hide, smoothstep(0.5, -0.5, D.x * u));
// The glowing maw when it roars, a burning eye, and the white-hot core itself.
float2 mq = rot(q - float2(0.16, 0.648 + bob), 0.15 - jaw * 0.5);
layer(acc, cover, lerp(colorA.rgb, float3(1.0, 0.9, 0.6), beat), smoothstep(0.5, -0.5, ellipse(mq, float2(0.09, 0.006 + 0.045 * jaw)) * u) * step(0.0, D.x + 0.004) * saturate(jaw * 3.0));
float de = ellipse(rot(q - float2(0.225, 0.715 + bob), -0.3), float2(0.026, 0.012));
layer(acc, cover, lerp(colorA.rgb, float3(1.0, 0.9, 0.5), 0.6), exp(-max(de, 0.0) / 0.025) * 0.7 + smoothstep(0.5, -0.5, de * u));
layer(acc, cover, lerp(colorA.rgb, float3(1.0, 0.97, 0.9), smoothstep(cr, cr * 0.2, dc)), smoothstep(0.5, -0.5, (dc - cr) * u));
}
return paint(acc / max(cover, 0.001), cover);
}