Katana Forge

của MusicBar, visualizer

Thanh cyber katana nằm vắt trên taskbar, lửa rèn bốc lên từ sống kiếm theo từng dải tần: bass ở chuôi, treble ở mũi, cam lò rèn ngả dần sang hồng plasma. Rãnh kiếm sáng dần theo bài, tới nhịp là tóe lửa, và lửa cháy tràn lên khỏi taskbar.

Cần MusicBar 2.0 trở lên: skin này dùng thứ bản cũ chưa có (vẽ tràn lên trên taskbar, hình động đi kèm). Bản cũ hơn không thấy nó trong kho, cập nhật app là có.

50 lượt tải Tải file, 29.0 KB
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 4ca4967dd34b3812730067d4b30a638a47c03af6d5d1a5aeebe36ad16057d9b7

//! name: Katana Forge
//! author: MusicBar
//! kind: visualizer
//! headroom: 170
//! description: Thanh cyber katana nằm trên mép taskbar, lửa rèn cam hồng bốc lên theo từng dải tần, rãnh kiếm sáng dần theo bài

// A cyber katana resting on the taskbar, fire rising off its spine: one glowing column per band (bass at the hilt,
// treble at the point), forge orange turning plasma magenta, sparks in the air.
// The sword follows the reference picture, measured pixel by pixel, then made a little slimmer and longer (blade
// 1000 units long): the spine flat for the first 30% then sweeping up 74 units to the point; 50 units deep, narrowing to 38 from 66% to 84%; a straight
// chisel point over the last 10%. Across the blade, from the spine: a fire-lit spine line and bevel, a double rail
// (the fuller) at 0.22-0.27 with an LED at each end, a dark panel with chevron engraving, a long armour plate whose
// top rim runs at 0.78, steps up to 0.53 at 29% (an LED ring) and notches back down at 67% (an LED), a thin line on to
// the point, and a cool cutting edge. Its colours are the picture's: dark steel stained red-brown by the orange fire
// near the hilt and violet by the magenta fire at the point. The rail is the song: its energy runs to the playhead.
// It asks for 170 DIPs of headroom (drawn on the desktop above the taskbar). While that is hidden (a window there, a
// preview tile) headroom() is 0 and a smaller sword lies in the bar instead.
// Hash and noise follow docs/skin-art/toolbox.hlsl (Hash without Sine, Dave Hoskins, MIT); the drawing is original.

float hash11(float p) { p = frac(p * 0.1031); p *= p + 33.33; p *= p + p; return frac(p); }
float hash12(float2 p) { float3 q = frac(p.xyx * 0.1031); q += dot(q, q.yzx + 33.33); return frac((q.x + q.y) * q.z); }
float2 hash22(float2 p) { float3 q = frac(p.xyx * float3(0.1031, 0.1030, 0.0973)); q += dot(q, q.yzx + 33.33); return frac((q.xx + q.yz) * q.zy); }
float vnoise(float2 p)
{
    float2 i = floor(p), f = frac(p);
    float2 u = f * f * (3.0 - 2.0 * f);
    float a = hash12(i), b = hash12(i + float2(1.0, 0.0)), c = hash12(i + float2(0.0, 1.0)), d = hash12(i + 1.0);
    return lerp(lerp(a, b, u.x), lerp(c, d, u.x), u.y);
}
float fill(float d, float w) { return saturate(0.5 - d / w); }
float beatAge() { return -0.12 * log(max(beat, 1e-4)); }
float luma(float3 c) { return dot(c, float3(0.299, 0.587, 0.114)); }
float3 aces(float3 x) { return saturate((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14)); }
float sdBox(float2 p, float2 b) { float2 d = abs(p) - b; return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); }
float sdSegment(float2 p, float2 a, float2 b) { float2 pa = p - a, ba = b - a; float h = saturate(dot(pa, ba) / max(dot(ba, ba), 1e-8)); return length(pa - ba * h); }

// Fire by temperature k (0 = cooling top, 1 = white-hot), forge orange (plasma 0) or plasma magenta (1).
float3 fireRamp(float k, float plasma)
{
    float3 a = lerp(float3(0.50, 0.06, 0.01), float3(0.34, 0.02, 0.42), plasma);
    float3 b = lerp(float3(1.00, 0.38, 0.04), float3(0.95, 0.12, 0.82), plasma);
    float3 c = lerp(float3(1.00, 0.78, 0.30), float3(1.00, 0.55, 0.96), plasma);
    float3 c3 = k < 0.45 ? lerp(a, b, k / 0.45) : lerp(b, c, (k - 0.45) / 0.4);
    return lerp(c3, float3(1.0, 0.96, 0.90), saturate((k - 0.85) / 0.15));
}

// The blade's spine height above the hilt's spine, and its depth, at u (0 at the collar, 1 at the point); k = units.
float spineRise(float u, float k) { return 74.4 * k * pow(saturate((u - 0.30) / 0.70), 1.8); }
float bladeDepth(float u, float k) { return 50.0 * k - 12.0 * k * smoothstep(0.66, 0.84, u); }

// Steel lit by the fire above: a dark metal grey pulled toward the fire's light (less saturated than the flames).
float3 steel(float3 tint, float amount) { return lerp(float3(0.30, 0.30, 0.34), tint, 0.65) * amount; }

// A thin line of width w (px) at signed distance d: 1 on it.
float line1(float d, float w) { return fill(abs(d) - 0.5 * w, 1.0); }

// The guard seen from the side: a tall rounded plate, straight on the blade side, gently lobed on the handle side
// (shallow bumps: never holes the desktop shows through).
float tsubaSD(float2 q, float k)
{
    float hw = 17.0 * k, hh = 60.0 * k;
    float left = -hw + 3.0 * k * (0.5 - 0.5 * cos(q.y / hh * 3.14159 * 4.0));        // four soft lobes
    float cx = 0.5 * (left + hw), hx = 0.5 * (hw - left);
    return sdBox(float2(q.x - cx, q.y), float2(hx - 9.0 * k, hh - 9.0 * k)) - 9.0 * k;
}

float4 main(float2 uv : TEXCOORD) : COLOR
{
    float W = size.x, barH = size.y;
    float room = headroom();                                  // on screen above the taskbar now (0: hidden)
    bool up = room > 1.0;
    float x = uv.x * W, y = rise(uv) * barH;                  // px; y > barH in the headroom
    float top = barH + room;
    float s = up ? room / 170.0 : barH / 150.0;

    // ------------------------------------------------------------------ layout, in the picture's units (k px each)
    float k = up ? min(0.68 * s, 0.36 * W / 1000.0) : 0.30 * barH / 50.0;   // one unit of the picture, in px
    float Lb = 1000.0 * k;                                    // blade
    float total = 290.0 * k + 73.0 * k + Lb;                  // handle, guard and collar, blade
    float xA = 0.5 * W - 0.5 * total;                         // the pommel's end
    float xb0 = xA + 363.0 * k;                               // the blade leaves the collar
    float xb1 = xb0 + Lb;                                     // the point
    float xT = xb0 - 55.5 * k;                                // guard centre
    float xHe = xT;                                           // the handle runs in under the guard (no gap)
    float yBase = up ? barH + 5.0 * s : 0.12 * barH;          // the cutting edge at the hilt
    float h0 = 50.0 * k;
    float yS0 = yBase + h0;                                   // the spine at the hilt
    float yc = yBase + 0.5 * h0;                              // the blade's centre at the hilt

    // ------------------------------------------------------------------ music, read once
    float u = (x - xb0) / Lb;
    float t = saturate(u);
    float colW = max(8.0 * k, 3.0);                           // flame columns sized to the sword
    float ci = floor(x / colW);
    float xcol = (ci + 0.5) * colW;
    float bcol = saturate((xcol - xb0) / Lb);
    float spC = spectrum(lerp(0.03, 0.86, bcol)) * (0.8 + 0.6 * bcol);
    float backW = max(11.5 * k, 4.0);
    float bi = floor(x / backW + 0.5);
    float xback = bi * backW;
    float bback = saturate((xback - xb0) / Lb);
    float spB = spectrum(lerp(0.03, 0.86, bback)) * (0.8 + 0.6 * bback);
    float spS = spectrum(lerp(0.03, 0.86, t)) * (0.8 + 0.6 * t);
    float on = lerp(0.16, 1.0, playing);
    float lv = lerp(0.2, 0.35 + 0.65 * level, playing);
    float age = beatAge();
    float plasma = smoothstep(0.36, 0.72, t + 0.08 * (vnoise(float2(x / (60.0 * s), time * 0.25)) - 0.5));
    float3 fireCol = lerp(float3(1.0, 0.40, 0.06), float3(0.95, 0.14, 0.82), plasma);
    float overBlade = smoothstep(xb0 - 2.0, xb0 + 10.0 * s, x) * (1.0 - smoothstep(xb1 - 24.0 * s, xb1, x));

    // ------------------------------------------------------------------ the blade's outline
    float yS = yS0 + spineRise(u, k);                         // spine (top)
    float hU = bladeDepth(u, k);
    float yE = yS - hU;                                       // cutting edge (bottom)
    float kk = saturate((u - 0.90) / 0.10);
    float yEk = lerp(yE, lerp(yS0 + spineRise(0.90, k) - bladeDepth(0.90, k), yS0 + spineRise(1.0, k), kk), step(0.90, u));
    float dBlade = max(max(yEk - y, y - yS), max(xb0 - x, x - xb1));
    float inB = fill(dBlade, 1.0);
    float f = (yS - y) / hU;                                  // across the blade: 0 at the spine, 1 at the edge
    float U = x - xb0;

    float3 light = float3(0.0, 0.0, 0.0);                    // emitted light (on the desktop: additive)
    float3 emis = float3(0.0, 0.0, 0.0);                     // light the sword itself gives off (LEDs, the rail)

    // ------------------------------------------------------------------ fire behind the blade
    float avail = max(0.92 * (top - yS) - 3.0 * s, 4.0);
    float hf = y - yS;
    float n1 = vnoise(float2(x / (6.0 * s), hf / (8.0 * s) - time * 4.2));
    float n2 = vnoise(float2(x / (19.0 * s) + 3.0, hf / (18.0 * s) - time * 2.0));
    float clumpB = 0.40 + 0.80 * vnoise(float2(bi / 5.0 + 11.0, time * 0.7));
    float hB = avail * saturate((0.08 + 1.15 * sqrt(spB) * clumpB * (0.25 + 0.9 * pow(hash11(bi * 3.31), 2.0))) * (0.8 + 0.4 * vnoise(float2(bi * 0.5, time * 5.0)))) * lerp(0.35, 1.0, playing);
    float qB = abs(x - xback) / (0.5 * backW - 0.8 * s);
    float inBack = fill((qB - 1.0) * 0.5 * backW, 1.2) * (1.0 - smoothstep(hB - 3.0 * s, hB + 0.5, hf)) * step(-4.0 * s, hf);
    float plasmaB = saturate(plasma + (hash11(bi * 7.7) - 0.5) * 0.6);
    float kB = 1.0 - saturate(hf / max(hB, 1.0));
    light += fireRamp(0.26 + 0.40 * pow(kB, 0.8), plasmaB) * inBack * (0.50 + 0.40 * qB * qB * qB * qB) * 0.75 * overBlade;   // back row: deeper orange, a step behind
    float clumpN = vnoise(float2(ci / 7.0, time * 0.8));
    float clump = 0.25 + 1.30 * clumpN * clumpN;
    float colRand = hash11(ci * 1.37);
    float flick = 0.75 + 0.5 * vnoise(float2(ci * 0.41, time * 7.0));
    // always burning: a low fire when paused or quiet, the spectrum lifting columns over it (spectrum is the app's
    // auto-gained 0..1, the loudest band near 1; square-rooted so quieter bands still rise)
    float burn = lerp(0.35, 1.0, playing);
    float hC = avail * saturate((0.10 + 1.25 * sqrt(spC) * clump * (0.30 + 0.9 * colRand * colRand)) * flick) * burn;
    float hRel = saturate(hf / max(hC, 1.0));
    float flameTop = smoothstep(0.62, 1.0, hRel);
    float sway = (vnoise(float2(ci * 1.7, hf / (9.0 * s) - time * 6.0)) - 0.5) * 3.0 * s * flameTop;
    float halfW = (0.5 * colW - 0.5 * s) * (1.0 - 0.65 * flameTop);
    float qx = (x - xcol - sway) / max(halfW, 0.3);
    float capY = hC - halfW;
    float2 capD = float2(x - xcol - sway, max(hf - capY, 0.0));
    float dCol = max(length(capD) - halfW, -hf - 4.0 * s);
    float inCol = fill(dCol, 1.0) * step(0.5, hC);
    float plasmaC = saturate(plasma + (colRand - 0.5) * 0.60 * smoothstep(0.30, 0.55, t) * (1.0 - smoothstep(0.75, 0.95, t)));   // mixed columns only mid-blade
    float kC = 1.0 - hRel;
    float rimTube = 0.62 + 0.55 * pow(saturate(abs(qx)), 5.0);                              // a glass tube: brighter at its edges
    float streak = 0.85 + 0.15 * sin(x / (1.3 * s));
    light += fireRamp(0.28 + 0.46 * pow(kC, 0.8), plasmaC) * inCol * rimTube * streak * 1.9 * overBlade;   // yellow at the root, orange (or magenta) up the column
    light += fireRamp(0.80, plasmaC) * inCol * pow(saturate(abs(qx)), 6.0) * 0.30 * (1.0 - 0.7 * hRel) * overBlade;   // the tube edges catch hot light, low down
    light += fireRamp(0.30 * kC + 0.15, plasmaC) * exp(-max(dCol, 0.0) / (4.5 * s)) * (1.0 - inCol) * 0.60 * step(0.5, hC) * overBlade;   // halo
    float bodyH = avail * 0.50 * (0.40 + 0.60 * saturate(sqrt(spS) * 1.2)) * (0.40 + 0.60 * n2) * burn;
    float tongue = saturate((n1 * 1.15 + n2 * 0.55 - max(hf, 0.0) / max(bodyH, 1.0) * 1.9 - 0.28) * 3.2) * smoothstep(-3.0, 1.0, hf);
    light += fireRamp(0.38 + 0.22 * tongue, plasma * 0.35) * tongue * 1.05 * overBlade;     // flame tongues stay yellow-orange, even under magenta columns
    float bedH = (10.0 + 14.0 * lv * (0.5 + spS)) * s * burn * (0.45 + 1.2 * n1 * n2 + 0.3 * n2);
    float bed = saturate(1.0 - (hf + 2.0 * s) / max(bedH, 0.5)) * step(-2.5 * s, hf);
    float3 bedLight = fireRamp(0.40 + 0.20 * bed, plasma * 0.35) * bed * 1.15 * overBlade;
    bedLight += float3(1.0, 0.92, 0.75) * fill(abs(hf - 0.8 * s) - 0.7 * s, 1.0) * (0.35 + 0.45 * lv) * burn * overBlade;   // a thin white-hot seam on the spine
    light += bedLight;
    light += fireCol * exp(-max(hf, 0.0) / (avail * 0.40)) * (0.02 + 0.15 * spS) * lv * on * overBlade * smoothstep(-2.0, 2.0, hf);

    // ------------------------------------------------------------------ the sword (display colours, solid)
    // the fire's light on the steel: its colour, a little toward neutral; stronger where the fire is high
    float3 tint = lerp(fireCol, float3(0.95, 0.55, 0.55), 0.45);
    float lit = lerp(0.55, 0.80 + 0.40 * spS, playing) * lerp(exp(-max(xb0 - x, 0.0) / (120.0 * k)), 1.0, step(xb0, x));
    float3 sw = float3(0.0, 0.0, 0.0);
    float cover = 0.0;

    // handle: a round grip (lit from above: a cool sheen along its upper third, dark underneath), black silk crossing
    // over grey ray skin in diamonds, a metal pommel cap and collar; the fire warms the end by the guard
    float yH = yc + 3.0 * k;
    float hh = 28.0 * k;
    float hv = (y - yH) / hh;
    float dHandle = max(abs(y - yH) - hh, max(xA - x, x - xHe));
    float inH = fill(dHandle, 1.0);
    float roundG = sqrt(saturate(1.0 - hv * hv));                                             // the cylinder's facing
    float shade = 0.30 + 0.70 * saturate(0.55 + 0.75 * hv) * roundG;                         // light from above
    float sheen = exp(-(hv - 0.52) * (hv - 0.52) / 0.012) * roundG;                          // a long highlight
    float P = 1.9 * hh;
    float ha = (x - xA) / P;
    float fa = frac(ha) - 0.5;
    float window = 1.0 - smoothstep(0.50, 0.62, abs(fa) * 2.0 + abs(hv) * 0.95);             // diamonds of ray skin
    float b1 = frac(ha + hv * 0.5), b2 = frac(ha - hv * 0.5);
    float rib = lerp(b1, b2, step(0.5, frac(ha + 0.25)));                                     // which ribbon is on top
    float ribbon = sin(rib * 3.14159);
    float pebble = 0.80 + 0.40 * vnoise(float2(x, y) / (1.2 * k));
    float3 silk = float3(0.075, 0.072, 0.082) * (0.55 + 0.65 * ribbon) * shade + float3(0.30, 0.33, 0.40) * sheen * ribbon * 0.55;
    float3 skin = float3(0.36, 0.35, 0.37) * pebble * shade + float3(0.25, 0.27, 0.32) * sheen * 0.4;
    float3 grip = lerp(silk, skin, window);
    grip *= 1.0 - 0.55 * fill(abs(abs(fa) * 2.0 + abs(hv) * 0.95 - 0.56) - 0.03, 0.04);     // the silk's edge shadow
    grip += tint * 0.30 * lit * saturate(hv * 1.6) * exp(-(xHe - x) / (70.0 * k));            // fire spill near the guard
    float3 capMetal = float3(0.16, 0.16, 0.19) * shade + float3(0.55, 0.58, 0.66) * sheen;
    float kash = fill(sdBox(float2(x - (xA + 8.0 * k), y - yH), float2(8.0 * k, hh * 1.05)) - 4.0 * k, 1.0);
    float fuchi = fill(sdBox(float2(x - (xHe - 6.0 * k), y - yH), float2(6.0 * k, hh * 1.06)) - 1.0 * k, 1.0);
    grip = lerp(grip, capMetal, saturate(kash + fuchi));
    grip = lerp(grip, float3(0.55, 0.56, 0.62), line1(abs(y - yH) - hh * 0.995, 1.0) * 0.6); // a thin rim on its edges
    sw = lerp(sw, grip, saturate(inH + kash)); cover = max(cover, saturate(inH + kash));

    // guard (tsuba): a thick dark metal plate: its face lit from above, a bright rim all round, the plate's thickness
    // showing as a lighter strip on the blade side, an engraved line inset from the edge
    float2 gq = float2(x - xT, y - (yc + 6.0 * k));
    float gd = tsubaSD(gq, k);
    float guard = fill(gd, 1.0);
    float gv = gq.y / (60.0 * k);
    float3 plateG = lerp(float3(0.07, 0.06, 0.075), lerp(float3(0.26, 0.25, 0.31), tint * 0.45, 0.30) * lit, saturate(gv * 0.55 + 0.50));
    plateG += float3(0.05, 0.05, 0.06) * (vnoise(float2(x, y) / (2.5 * k)) - 0.5);          // cast iron grain
    plateG = lerp(plateG, plateG * 0.45, line1(gd + 5.0 * k, 1.2 * k));                     // engraved inset line
    plateG += float3(0.20, 0.20, 0.24) * smoothstep(9.0 * k, 12.0 * k, gq.x);               // the thickness, facing the blade
    plateG += float3(0.55, 0.55, 0.62) * saturate(1.0 + gd / (1.8 * k)) * (0.45 + 0.55 * saturate(gv + 0.4));   // rim
    sw = lerp(sw, plateG, guard); cover = max(cover, guard);

    // collar (habaki): grey-brown block, a bright top edge, its end bevelled, the "///" mark
    float2 cq = float2(x - (xb0 - 20.0 * k), y - yc);
    float cd = sdBox(cq, float2(20.0 * k, 30.0 * k)) - 0.8 * k;
    float collar = fill(cd, 1.0);
    float cv = cq.y / (30.0 * k);
    float3 block = lerp(float3(0.30, 0.29, 0.32), tint, 0.22) * (0.38 + 0.16 * cv) * lit;
    block += float3(0.30, 0.31, 0.36) * exp(-(cv - 0.45) * (cv - 0.45) / 0.02) * 0.45;          // a soft sheen
    block = lerp(block, float3(0.77, 0.77, 0.82), line1(cq.y - 28.5 * k, 2.2 * k));               // bright top edge
    block = lerp(block, float3(0.05, 0.04, 0.05), line1(cq.y + 29.0 * k, 2.0 * k));               // dark bottom edge
    block *= 1.0 - 0.35 * smoothstep(16.0 * k, 19.5 * k, cq.x);                                  // the end bevel
    float2 lq = cq - float2(-7.0 * k, 3.0 * k);
    float mark = 0.0;
    for (int m = 0; m < 3; m++)
    {
        float ox = (m - 1.0) * 4.6 * k;
        mark = max(mark, fill(sdSegment(lq, float2(ox - 4.5 * k, -9.0 * k), float2(ox + 4.5 * k, 9.0 * k)) - 0.9 * k, 1.0));
    }
    block = lerp(block, float3(0.78, 0.78, 0.82), mark * 0.9);
    sw = lerp(sw, block, collar); cover = max(cover, collar);

    // ---- the blade, band by band from the spine
    float dpx = f * hU;                                                                     // px down from the spine
    float3 bl = steel(tint, 0.38 * lit) * (1.0 + 0.18 * exp(-(f - 0.36) * (f - 0.36) / 0.004));   // the dark panel, a soft sheen
    bl += float3(0.07, 0.075, 0.09) * (0.5 + 0.5 * sin(U / (150.0 * k) + 0.8)) * exp(-(f - 0.45) * (f - 0.45) / 0.03);   // the room reflected, changing along the blade
    bl = lerp(bl, steel(tint, 0.34 * lit), smoothstep(0.30, 0.75, f));                      // darker toward the plate
    // brushed steel: fine lengthwise streaks
    float brush = vnoise(float2(U / (28.0 * k), dpx / (0.45 * k))) - 0.5;
    bl *= 1.0 + 0.16 * brush;
    // the fire right above lights the spine side: it flickers column by column with the flames
    float flameHere = saturate(hC / max(avail, 1.0) * 1.6) * step(0.5, hC);
    float colProf = fill(abs(x - xcol) - (0.5 * colW - 0.5 * s), 1.0);                      // inside this column's width
    float flickLit = lerp(0.70, 1.25, flameHere * (0.6 + 0.4 * colProf));
    float bev = 1.0 - smoothstep(0.085, 0.105, f);
    bl = lerp(bl, tint * 0.48 * lit * flickLit, (1.0 - smoothstep(0.18, 0.21, f)));         // upper flat, fire-lit
    bl = lerp(bl, tint * 0.88 * lit * flickLit, bev);                                       // spine bevel
    bl += fireRamp(0.75, plasma) * pow(1.0 - saturate(f / 0.09), 3.0) * 0.30 * flameHere;   // a hot sheen on the bevel's top
    // the polished flat mirrors the flames: soft streaks, one per column, fading down the blade
    float3 mirrorC = fireRamp(0.45 + 0.25 * flameHere, plasmaC);
    float mirror = flameHere * (0.35 + 0.65 * colProf) * exp(-f / 0.22) * smoothstep(0.08, 0.14, f) * (1.0 - smoothstep(0.55, 0.70, f));
    bl += mirrorC * mirror * 0.38 * lerp(0.4, 1.0, playing);
    bl = lerp(bl, fireRamp(0.68, plasma) * (0.80 + 0.30 * spS * playing), 1.0 - smoothstep(0.8 * k, 1.8 * k, dpx));   // spine line
    // the double rail (fuller), with a dark channel between
    float railOn = step(0.045 * Lb, U) * step(U, 0.876 * Lb);
    float3 railC = lerp(float3(0.82, 0.80, 0.84), tint, 0.25) * (0.85 + 0.15 * lit);
    bl = lerp(bl, steel(tint, 0.12), line1(dpx - 0.243 * hU, 0.035 * hU) * railOn);
    bl = lerp(bl, railC, line1(dpx - 0.215 * hU, 1.4 * k) * railOn);
    bl = lerp(bl, railC, line1(dpx - 0.272 * hU, 1.4 * k) * railOn);
    // the armour plate: its top rim profile along the blade, the plate below it, a dark edge under it
    float fTop = 0.78;
    fTop = lerp(fTop, 0.53, smoothstep(0.285 * Lb, 0.320 * Lb, U));                          // steps up after the LED ring
    fTop = lerp(fTop, 0.77, smoothstep(0.645 * Lb, 0.675 * Lb, U));                          // and notches back down
    float after = smoothstep(0.675 * Lb, 0.70 * Lb, U);
    fTop = lerp(fTop, lerp(0.77, 0.98, saturate((U - 0.70 * Lb) / (0.20 * Lb))), after);    // the thin line runs to the edge
    float plateZone = step(fTop, f) * step(f, 0.93) * (1.0 - after) * step(0.0, U);
    // carbon fibre: a 2x2 twill of tows at 45 degrees, each tow catching light along its length
    float2 tw = float2(U + dpx, U - dpx) / (2.6 * k);
    float towA = frac(tw.x), towB = frac(tw.y);
    float over = step(0.5, frac(floor(tw.x) * 0.5 + floor(tw.y) * 0.5 + 0.25 * floor(tw.x + tw.y)));
    float tow = lerp(sin(towA * 3.14159), sin(towB * 3.14159), over);
    float weave = 0.78 + 0.30 * tow + 0.12 * over;
    bl = lerp(bl, steel(tint, 0.25 * lit) * weave * float3(0.95, 0.90, 1.0), plateZone);
    // rims with a little wear: brighter where the steel has been rubbed
    float wear = 0.85 + 0.30 * vnoise(float2(U / (9.0 * k), 3.0));
    float3 rimC = lerp(float3(0.74, 0.71, 0.76), tint, 0.12) * wear;
    bl = lerp(bl, rimC, line1(dpx - fTop * hU, 1.6 * k) * step(0.0, U) * step(U, 0.90 * Lb));
    bl = lerp(bl, float3(0.04, 0.03, 0.04), line1(dpx - (fTop * hU + 1.8 * k), 1.0 * k) * (1.0 - after) * step(0.0, U));
    // chevron engraving in the dark panel near the hilt
    float cell = (U - 0.05 * Lb) / (58.0 * k);
    float cfr = frac(cell);
    float chevOn = step(0.0, cell) * step(U, 0.27 * Lb) * step(0.30, f) * step(f, 0.72);
    float vy = 0.36 + 0.30 * (1.0 - abs(cfr * 2.0 - 1.0)) * step(0.15, cfr) * step(cfr, 0.85);
    float chev = line1(dpx - vy * hU, 1.1 * k) * chevOn;
    bl = lerp(bl, lerp(float3(0.62, 0.58, 0.62), tint, 0.25) * lit, chev * 0.75);
    bl *= 1.0 - 0.45 * line1(dpx - vy * hU - 1.3 * k, 0.9 * k) * chevOn;                    // its shadow side
    // the cutting edge: a dark bevel and a cool bright line
    bl = lerp(bl, float3(0.05, 0.045, 0.06), smoothstep(0.93, 0.95, f));
    bl = lerp(bl, float3(0.38, 0.40, 0.47), (1.0 - smoothstep(1.0 * k, 2.6 * k, y - yE)) * step(U, 0.90 * Lb));
    // the chisel point: its own facet, violet-lit, a light yokote line and a bright cut edge
    float kissZone = step(0.90 * Lb, U) * step(0.04, f);                                   // the chisel point: its facet
    float kv = saturate((y - yEk) / max(yS - yEk, 1.0));
    bl = lerp(bl, lerp(steel(tint, 0.13), lerp(tint, float3(0.62, 0.56, 0.66), 0.35) * 0.60, pow(kv, 1.3)) * lit, kissZone);
    bl = lerp(bl, float3(0.62, 0.60, 0.68), line1(U - 0.90 * Lb, 1.3 * k) * step(0.12, f) * step(f, 0.95));
    // the ridge from the rail's end to the point: the facet above it catches the fire, the one below stays dark
    float2 r0 = float2(xb0 + 0.876 * Lb, yS0 + spineRise(0.876, k) - 0.243 * bladeDepth(0.876, k));
    float2 r1 = float2(xb1, yS0 + spineRise(1.0, k));
    float2 rd = r1 - r0;
    float side = (rd.x * (y - r0.y) - rd.y * (x - r0.x)) / length(rd);                      // > 0 above the ridge
    float ridgeZone = step(r0.x, x) * inB;
    bl = lerp(bl, lerp(bl, lerp(tint, float3(0.66, 0.60, 0.70), 0.40) * 0.62 * lit, 0.55), step(0.0, side) * ridgeZone);
    bl = lerp(bl, bl * 0.65, step(side, 0.0) * ridgeZone * step(0.90 * Lb, U));
    bl = lerp(bl, float3(0.70, 0.66, 0.76), fill(abs(side) - 0.6 * k, 1.0) * ridgeZone);
    float cutLine = 1.0 - smoothstep(0.8 * k, 2.4 * k, y - yEk);
    bl = lerp(bl, float3(0.60, 0.58, 0.68), cutLine * step(0.90 * Lb, U));
    // LEDs: the rail's ends, the plate's step and notch; the song's energy in the rail with an LED at its head
    float3 ledC = float3(1.0, 0.55, 0.16);
    float2 l1 = float2(U - 0.045 * Lb, dpx - 0.243 * hU);
    float2 l2 = float2(U - 0.286 * Lb, dpx - 0.78 * hU);
    float2 l3 = float2(U - 0.672 * Lb, dpx - 0.78 * hU);
    float2 l4 = float2(U - 0.876 * Lb, dpx - 0.243 * hU);
    float pulse = 0.8 + 0.7 * exp(-age * 5.0) * playing;
    float leds = fill(length(l1) - 2.6 * k, 1.0) + fill(abs(length(l2) - 3.6 * k) - 1.1 * k, 1.0) + fill(length(l3) - 2.8 * k, 1.0) + fill(length(l4) - 2.6 * k, 1.0);
    float ledGlow = exp(-length(l1) / (5.5 * k)) + exp(-length(l2) / (6.5 * k)) + exp(-length(l3) / (6.0 * k)) + exp(-length(l4) / (5.5 * k));
    float headU = lerp(0.045 * Lb, 0.876 * Lb, saturate(progress));
    float energy = line1(dpx - 0.243 * hU, 1.2 * k) * step(0.045 * Lb, U) * step(U, headU) * (0.6 + 0.3 * spS + 0.2 * sin(U / (6.0 * k) - time * 9.0));
    float2 lh = float2(U - headU, dpx - 0.243 * hU);
    float headLed = fill(length(lh) - 2.0 * k, 1.0) + exp(-length(lh) / (4.0 * k)) * 0.8;
    emis += ledC * (leds * pulse + ledGlow * 0.45 * pulse + energy * 0.9 + headLed * (1.0 + 1.5 * exp(-age * 6.0) * playing)) * inB;
    // rare: a polish glint runs from the collar to the point every 31 s, then the point flashes
    float gph = frac(time / 31.0) * 31.0;
    float gx = xb0 + (gph / 0.8) * Lb;
    float gk = (x - gx + (y - yE) * 1.6) / (9.0 * s);
    bl += float3(0.55, 0.58, 0.66) * exp(-gk * gk) * step(gph, 0.85) * 0.8;
    float star = exp(-(gph - 0.8) * 4.0) * step(0.8, gph) * step(gph, 2.0);
    float2 tp = float2(x - xb1, y - (yS0 + spineRise(1.0, k)));
    light += float3(1.0, 0.97, 0.92) * star * 1.6 * (exp(-abs(tp.y) / (0.9 * s)) * exp(-abs(tp.x) / (30.0 * s)) + exp(-abs(tp.x) / (0.9 * s)) * exp(-abs(tp.y) / (18.0 * s)));
    sw = lerp(sw, bl, inB); cover = max(cover, inB);

    // ------------------------------------------------------------------ in front: flames over the spine, sparks
    float frontFlame = bed * smoothstep(-1.2 * k, 0.0, hf) * (1.0 - step(1.5 * s, hf)) * overBlade;   // only over the very spine
    for (int j = 0; j < 3; j++)
    {
        float cs = (10.0 + 8.0 * j) * s;
        float spd = (34.0 + 26.0 * j) * s;
        float2 q = float2(x + 7.0 * s * sin(y / (23.0 * s) + time * (0.9 + 0.5 * j)), y - time * spd) / cs;
        float2 id = floor(q);
        float2 r = hash22(id + j * 31.0);
        float live = step(hash12(id + 5.0 + j * 11.0), 0.10 + 0.32 * lv * on);
        float2 dd = (frac(q) - 0.5 - (r - 0.5) * 0.7) * cs;
        dd.y *= 0.40;
        float sx = (id.x + 0.5) * cs;
        float fromBlade = step(xb0, sx) * step(sx, xb1);
        float life = saturate(1.0 - (y - yS) / (avail * (0.55 + 0.6 * r.x))) * step(0.0, y - yS) * fromBlade;
        float tw = 0.55 + 0.45 * sin(time * (13.0 + 9.0 * r.y) + r.x * 6.28);
        float pl = saturate(smoothstep(0.36, 0.72, saturate((sx - xb0) / Lb)) + (r.y - 0.5) * 0.5);
        light += fireRamp(0.55 + 0.4 * r.y, pl) * exp(-dot(dd, dd) / (0.9 * s * s + 0.25)) * live * life * tw * (1.6 - 0.35 * j);
    }
    // beat: a burst of sparks from the LED at the head of the rail
    float uh = headU / Lb;
    float2 fp = float2(x - (xb0 + headU), y - (yS0 + spineRise(uh, k) - 0.243 * bladeDepth(uh, k)));
    float ang = atan2(fp.y, fp.x) + 3.14159;
    float abin = floor(ang / 0.2618);
    float ar = hash11(abin + floor((time - age) * 3.0) * 17.0);
    float aC = (abin + 0.2 + 0.6 * ar) * 0.2618 - 3.14159;
    float rad = (6.0 + (36.0 + 50.0 * ar) * (1.0 - exp(-age * 4.0))) * s;
    float2 dsv = fp - float2(cos(aC), sin(aC)) * rad;
    light += float3(1.0, 0.72, 0.35) * exp(-dot(dsv, dsv) / (1.1 * s * s + 0.3)) * exp(-age * 3.2) * step(0.3, ar) * playing * 2.4;

    // ------------------------------------------------------------------ the taskbar under it: dark glass, fire pooled on it
    float inBar = up ? 1.0 - smoothstep(barH - 0.5, barH + 0.5, y) : 1.0;
    float3 glass = float3(0.012, 0.013, 0.020);
    glass += fireCol * exp(-max(barH - y, 0.0) / (10.0 * s)) * (0.10 + 0.50 * spS) * lv * on * overBlade * (up ? 0.7 : 0.0);
    // the glass mirrors the flames and the blade's LEDs, upside down and fading (a dark band where the blade itself is)
    float below = max(barH - y, 0.0);
    float gap = yBase - barH;                                                                // the blade sits this far above the glass
    float mirrorFire = flameHere * (0.55 + 0.45 * colProf) * exp(-below / (6.0 * k)) * smoothstep(0.0, 2.0 * k, below - 0.0);
    glass += fireRamp(0.42 + 0.20 * flameHere, plasmaC) * mirrorFire * 0.22 * (up ? 1.0 : 0.0) * overBlade;
    glass *= 1.0 - 0.45 * exp(-below / (3.0 * k)) * overBlade * (up ? 1.0 : 0.0) * step(gap, 6.0 * k);   // the blade's dark mirror image
    float ledMirror = exp(-abs(x - (xb0 + headU)) / (3.0 * k)) * exp(-below / (5.0 * k));
    glass += float3(1.0, 0.55, 0.16) * ledMirror * 0.35 * (up ? 1.0 : 0.0);
    glass += fireCol * 0.04 * (0.4 + spS) * on * overBlade * (up ? 1.0 : 0.0);

    // ------------------------------------------------------------------ put together: the light tone-mapped, the sword as drawn
    float3 fireD = light + light * smoothstep(0.6, 1.3, luma(light)) * 0.3;
    fireD = aces(fireD * 1.1);
    float3 rgb = lerp(fireD, sw + fireD * (1.0 - cover * 0.9), cover);
    rgb += aces(bedLight * 1.1) * frontFlame * cover * 0.8;
    rgb += aces(emis * 1.2) * cover;                                                      // the LEDs and the rail on the steel
    float alpha = max(cover, saturate(max(rgb.r, max(rgb.g, rgb.b))));
    float3 onBar = glass + fireD * (up ? 0.5 : 1.0);
    rgb = lerp(rgb, onBar, inBar * (1.0 - cover));
    alpha = lerp(alpha, 0.92, inBar * (1.0 - cover));
    rgb += (hash12(uv * size + frac(time * 7.13) * 91.7) - 0.5) * 0.010;
    // a soft shadow round the sword on the desktop, so it sits on any wallpaper
    float dSword = min(min(dBlade, dHandle), min(gd, cd));
    float shadowA = exp(-max(dSword, 0.0) / (4.0 * k)) * 0.45 * (1.0 - cover) * (up ? step(barH, y) : 0.0);
    float a = saturate(max(max(alpha, shadowA), max(rgb.r, max(rgb.g, rgb.b))));
    return paint(saturate(rgb) / max(a, 1e-3), a);
}