Koi Pond Ripples

của MusicBar, thanh tiến trình

Cá chép Koi cam trắng bơi uốn lượn trên hồ đêm tới chỗ đang phát, kéo theo vệt vàng lấp lánh, quẫy đuôi là sóng lan ra đánh thức lá súng.

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ó.

30 lượt tải Tải file, 23.7 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 3e35276a3a63b89bfbdea99273c1e52e1730ac1c4de9e3b1d36d9683543b45ed

//! name: Koi Pond Ripples
//! author: MusicBar
//! kind: progress
//! headroom: 60
//! description: Cá chép Koi cam trắng bơi uyển chuyển trên hồ đêm theo bài hát, để lại vệt vàng lấp lánh, vẫy đuôi lan sóng vàng đánh thức lá súng

// A night pond seen from above: ink-dark water with faint currents, lily pads (dim and asleep ahead, glowing awake
// behind), and a kohaku koi swimming left to right: the play head. It is drawn like a painting: a cream body lit from
// above with orange-red patches and fine scales, translucent fan fins with teal tips and white rays, a long flowing
// butterfly tail, a warm glow. Behind it a golden brushstroke wake with glitter; each tail beat sends a soft ring, each
// music beat a golden ring that wakes the pads it passes. Fireflies drift up over the taskbar.
// Hash and noise follow docs/skin-art/toolbox.hlsl (Hash without Sine, Dave Hoskins, MIT); the rest 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 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); }

// A tone map that keeps the hue: gold stays gold; only the brightest goes to white.
float3 toneHue(float3 c)
{
    float m = max(max(c.r, c.g), max(c.b, 1e-4));
    float mt = 1.0 - exp(-1.2 * m);
    return lerp(c * (mt / m), float3(mt, mt, mt), saturate((m - 1.6) / 2.4) * 0.8);
}

// The koi's route through the pond (its trail lies along it).
float yPath(float x, float H) { return 0.50 * H + 0.14 * H * sin(x / (0.46 * H) + 0.7) + 0.035 * H * sin(x / (1.30 * H) + 2.1); }

// The swimming wave: how far the spine is pushed sideways X px behind the nose (a gentle S through the body, the tail
// sweeping wide).
float swim(float X, float H, float t)
{
    float s = X / (1.05 * H);
    float amp = H * (0.018 + 0.060 * smoothstep(0.05, 1.0, s) + 0.08 * smoothstep(1.0, 1.8, s));
    return amp * sin(6.2831853 * X / (1.75 * H) - t * 4.2);
}

// A koi's fin as the mockup paints it: a lopsided fan from its root on the body. Its leading edge runs long and
// straight out to a pointed tip; the outer edge sweeps back from there, shorter and softly scalloped, to the trailing
// edge; the rays fan out from the root and curve back as they go (so the leading edge bows out). q = pixel - root;
// sg: which side (+1 the upper); aLead: the leading edge's angle from straight ahead; span: the fan's opening.
// Returns the coverage; u: 0 root .. 1 out at the tip; k: 0 leading edge .. 1 trailing edge; lead: 1 on the
// leading edge's rim.
float fin(float2 q, float sg, float aLead, float span, float len, out float u, out float k, out float lead)
{
    float r = length(q);
    float th = atan2(q.y, q.x);
    float rl = r / len;
    float phi = sg * th - aLead - 0.28 * rl * rl;                               // 0 on the leading edge, growing aft
    k = phi / span;
    float kc = saturate(k);
    float rmax = len * (1.0 - 0.60 * pow(kc, 1.10)) * (1.0 + 0.018 * sin(kc * 14.0));
    rmax *= 1.0 - 0.14 * (1.0 - smoothstep(0.0, 0.20, kc));                    // the tip: just behind the edge
    float d = max(r - rmax, max(-phi * r, (phi - span) * r));
    u = r / len;
    lead = saturate(1.0 - phi * r / 1.3) * step(0.0, phi);
    return fill(d, 1.0);
}

float4 main(float2 uv : TEXCOORD) : COLOR
{
    float W = size.x, H = 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) * H;                     // px; y > H in the headroom
    float s = H / 48.0;
    float px = 1.0;
    float t = time;
    float on = playing;
    float age = beatAge();
    float lv = lerp(0.35, 0.40 + 0.60 * level, on);
    float kickB = exp(-age * 4.0) * on;
    float glowK = lerp(0.65, 1.0, on) * (0.80 + 0.30 * lv);

    // ------------------------------------------------------------------ the pond (a rounded panel)
    // the pond fills the whole taskbar, edge to edge, square corners
    float xL = 0.0, xR = W, y0 = 0.0, y1 = H;
    float2 bq0 = abs(float2(x, y) - float2(0.5 * W, 0.5 * H)) - float2(0.5 * W, 0.5 * H);
    float dStrip = length(max(bq0, 0.0)) + min(max(bq0.x, bq0.y), 0.0);
    float inStrip = fill(dStrip, 1.0);
    float hx = lerp(xL + 1.9 * H, xR - 0.30 * H, saturate(progress));      // the koi's nose
    float Lb = 1.05 * H, Lt = 0.85 * H;                                     // body, tail
    float X = hx - x;                                                       // px behind the nose
    float yP = yPath(x, H);

    float3 col = float3(0.0, 0.0, 0.0);
    float cover = 0.0;
    float3 L = float3(0.0, 0.0, 0.0);
    float3 gold = float3(1.00, 0.78, 0.38);

    if (dStrip < 2.0)
    {
        // ink-dark water, faint currents drawn as soft lighter strokes
        float2 wp = float2(x / (1.6 * H), y / (0.55 * H));
        float warp = vnoise(wp * 0.7 + float2(t * 0.03, 0.0));
        float cur = vnoise(float2(x / (1.1 * H) + 1.7 * warp - t * 0.05, y / (0.30 * H) + 0.8 * warp));
        float band = abs(frac(cur * 3.0) - 0.5);
        float3 water = lerp(float3(0.018, 0.024, 0.060), float3(0.030, 0.040, 0.092), vnoise(wp + 3.3));
        water += float3(0.035, 0.045, 0.090) * (1.0 - smoothstep(0.05, 0.16, band)) * 0.8;
        float3 wl = float3(0.0, 0.0, 0.0);

        // ---- the golden wake: a soft brushed band along the route with streaks and glitter, brightest by the tail
        float back = X - (Lb + 0.45 * Lt);
        float wakeOn = smoothstep(-0.4 * H, 0.2 * H, back);
        float fade = wakeOn * (0.22 + 0.78 * exp(-max(back, 0.0) / (5.0 * H)));
        float dyP = y - yP;
        float spread = 1.0 + max(back, 0.0) / (12.0 * H);
        float bandW = 0.10 * H * spread;
        wl += gold * exp(-dyP * dyP / (bandW * bandW)) * 0.16 * fade;
        for (int i = 0; i < 5; i++)
        {
            float fi = i;
            float off = (fi - 2.0) * 0.040 * H * spread + 0.025 * H * sin(x / (0.55 * H) + fi * 1.3 - t * 1.2);
            float d = dyP - off;
            float flick = 0.55 + 0.45 * sin(x / (0.35 * H) + fi * 2.1 - t * 2.2);
            wl += gold * exp(-d * d / (0.55 * s * s + 0.20)) * fade * flick * (0.65 - 0.08 * abs(fi - 2.0));
        }
        // glitter: thick along the wake, sparse elsewhere behind the koi
        float2 gc = float2(x / (0.16 * H), y / (0.16 * H));
        float2 gi = floor(gc);
        float2 gr = hash22(gi + 7.0);
        float2 gd = (frac(gc) - 0.2 - 0.6 * gr) * 0.16 * H;
        float nearW = exp(-dyP * dyP / (bandW * bandW * 2.0));
        float sOn = step(gr.y, (0.14 + 0.45 * nearW) * smoothstep(-0.5 * H, 0.5 * H, X - Lb));
        float tw = 0.5 + 0.5 * sin(t * (2.0 + 4.0 * gr.x) + gr.y * 6.28);
        float sz = (0.30 + 0.35 * gr.x) * max(s, 0.85);
        float3 gcol = lerp(gold, float3(1.00, 0.50, 0.20), step(0.82, gr.x));
        wl += gcol * (exp(-dot(gd, gd) / (sz * sz)) * 1.6 + exp(-length(gd) / (2.5 * sz)) * 0.10) * sOn * tw * lerp(0.4, 1.0, fade + 0.3);

        // ---- ripples: a soft ring at each tail beat, a golden one on each music beat, a great bloom now and then
        for (int k = 0; k < 3; k++)
        {
            float fk = k;
            float per = 1.36;
            float a = frac(t / per + fk / 3.0) * per;
            float cxr = hx - (Lb + 0.55 * Lt) + 0.0;
            float2 c = float2(cxr, yPath(cxr, H) + swim(Lb + 0.55 * Lt, H, t - a));
            float r = length(float2(x, y) - c);
            float R = 0.12 * H + a * 0.70 * H;
            float rd = (r - R) / (0.7 * s + 0.4);
            wl += float3(0.75, 0.70, 0.55) * exp(-rd * rd) * (1.0 - a / per) * (1.0 - a / per) * 0.20;
        }
        float2 bc = float2(hx - 0.55 * Lb, yPath(hx - 0.55 * Lb, H));
        float rb = length(float2(x, y) - bc);
        float Rb = age * 2.3 * H;
        float rbd = (rb - Rb) / (0.9 * s + 0.5);
        float rbd2 = (rb - Rb * 0.78) / (0.7 * s + 0.4);
        wl += gold * (exp(-rbd * rbd) + 0.5 * exp(-rbd2 * rbd2)) * exp(-age * 1.8) * on * 0.55;
        float bp = frac(t / 41.0) * 41.0;
        float Rbl = bp * 7.0 * H;
        float rbl = (rb - Rbl) / (1.4 * s + 0.6);
        float bloom = step(bp, 3.5) * exp(-bp * 0.6);
        wl += gold * exp(-rbl * rbl) * bloom * 1.2;

        col = water + toneHue(wl);

        // ---- lily pads: asleep (dark) ahead of the koi, awake (lit, gold-rimmed) behind it, or as a ring passes
        float cell = 1.45 * H;
        float j0 = floor(x / cell);
        for (int p = -1; p <= 1; p++)
        {
            float j = j0 + p;
            float r1 = hash11(j * 1.37 + 0.1), r2 = hash11(j * 2.71 + 3.0), r3 = hash11(j * 3.97 + 5.0);
            float r4 = hash11(j * 5.33 + 7.0), r5 = hash11(j * 7.11 + 9.0), r6 = hash11(j * 8.89 + 2.0);
            if (r5 < 0.18) continue;
            bool topSide = r1 > 0.5;
            float cy = topSide ? lerp(0.80 * H, 1.08 * H, r2) : lerp(-0.08 * H, 0.20 * H, r2);
            float cx = (j + 0.15 + 0.70 * r3) * cell;
            float R = lerp(0.27 * H, 0.44 * H, r4);
            float2 q = float2(x, y) - float2(cx, cy + 0.012 * H * sin(t * 0.7 + r1 * 6.0));
            float rr = length(q);
            if (rr > R * 1.45 + 2.0) continue;
            float rot = r6 * 6.2831853 + 0.10 * sin(t * 0.35 + r2 * 6.0);
            float a = atan2(q.y, q.x) - rot;
            a -= 6.2831853 * floor((a + 3.14159) / 6.2831853);
            float Rr = R * (1.0 + 0.025 * sin(a * 5.0 + r2 * 9.0) + 0.015 * sin(a * 11.0 + r3 * 7.0));
            float dPad = max(rr - Rr, (0.21 - abs(a)) * rr);
            float cv = fill(dPad, 1.0);
            // awake: behind the koi, as the beat ring passes, in the bloom
            float spP = spectrum(saturate(cx / W) * 0.8 + 0.02);
            float dcb = length(float2(cx, cy) - bc);
            float rpd = (dcb - Rb) / (0.6 * H), bpd = (dcb - Rbl) / (1.0 * H);
            float ringPass = exp(-rpd * rpd) * exp(-age * 1.2) * on;
            float bloomPass = exp(-bpd * bpd) * bloom;
            float awake = saturate(smoothstep(-0.3 * H, 1.2 * H, hx - cx) + ringPass + bloomPass);
            // the pad: sage green lit from the upper left, painterly mottling, lighter radial veins, a fine light rim
            float lit = saturate(0.55 + 0.45 * dot(q / max(rr, 1e-3), normalize(float2(-0.5, 0.8))));
            float3 pc = lerp(float3(0.17, 0.29, 0.18), float3(0.42, 0.58, 0.33), lit * (0.45 + 0.55 * rr / R));
            pc *= 0.90 + 0.20 * vnoise(q / (0.07 * H) + j * 3.1);
            float vk = 6.2831853 / 13.0;
            float av = abs(frac(a / vk + 0.5) - 0.5) * vk * rr;
            float vein = fill(av - 0.35 * max(s, 0.8), 1.0) * smoothstep(0.08 * R, 0.30 * R, rr) * (1.0 - smoothstep(0.80 * R, 0.97 * R, rr));
            pc = lerp(pc, float3(0.62, 0.74, 0.45), vein * 0.55);
            pc = lerp(pc, float3(0.66, 0.76, 0.50), fill(abs(dPad + 0.9) - 0.45, 1.0) * 0.6);
            pc *= 1.0 - 0.25 * smoothstep(0.85, 1.0, rr / R) * (1.0 - lit);
            // asleep: a dark blue-green silhouette
            float3 sleepC = float3(0.035, 0.050, 0.075) + pc * 0.10;
            pc = lerp(sleepC, pc * (0.85 + 0.30 * spP * on), awake);
            col *= 1.0 - 0.35 * exp(-max(dPad, 0.0) / (0.05 * H)) * (1.0 - cv);   // its shadow on the water
            col = lerp(col, pc, cv);
            // awake: a golden rim glow and golden ripple arcs round it
            L += gold * exp(-abs(dPad) / (0.035 * H + 0.5)) * awake * 0.30 * (0.7 + 0.3 * spP);
            float arcs = 0.0;
            for (int n = 0; n < 2; n++)
            {
                float Ra = R * (1.16 + 0.15 * n);
                float ad = (rr - Ra) / (0.55 * s + 0.35);
                arcs += exp(-ad * ad) * smoothstep(0.2, 0.8, cos(a * 1.0 + r1 * 6.0 + n * 1.7)) * (1.0 - 0.4 * n);
            }
            L += gold * arcs * (1.0 - cv) * (0.08 + 0.55 * awake);
        }
        cover = inStrip;

        // ---- the koi's shadow on the pond floor, offset and soft
        float Xs = X + 0.05 * H, latS = y - (yPath(x - 0.05 * H, H) + swim(Xs, H, t)) + 0.11 * H;
        float sB0 = Xs / Lb;
        float wS = sB0 < 0.32 ? 0.17 * H * sqrt(saturate(sB0 / 0.32)) : 0.17 * H * (1.0 - 0.80 * smoothstep(0.32, 1.0, sB0));
        float dSh = max(max(abs(latS) - wS, -Xs), Xs - Lb * 1.5);
        col *= 1.0 - 0.45 * saturate(1.0 - max(dSh, 0.0) / (0.10 * H)) * step(-0.2 * H, Xs);
    }

    // ------------------------------------------------------------------ the koi
    float dFish = 1e4;
    if (X > -0.5 * H && X < Lb + Lt + 0.6 * H && dStrip < 1.0)
    {
        float ySp = yP + swim(X, H, t);
        float lat = y - ySp;
        float sB = X / Lb;
        float wmax = 0.17 * H;
        float wB = sB < 0.32 ? wmax * sqrt(saturate(sB / 0.32)) * (0.88 + 0.12 * saturate(sB / 0.32)) : wmax * (1.0 - 0.80 * smoothstep(0.32, 1.0, sB));
        float dB = max(max(abs(lat) - wB, -X), X - Lb * 1.02);

        float3 finC = float3(0.0, 0.0, 0.0);
        float finA = 0.0;
        // fins under the body: pectoral (big, near the head) and pelvic (small, mid body), both sides, flapping
        for (int side = 0; side < 2; side++)
        {
            float sg = side == 0 ? 1.0 : -1.0;
            for (int f = 0; f < 2; f++)
            {
                float Xa = f == 0 ? 0.25 * Lb : 0.60 * Lb;
                float wa = f == 0 ? wmax * 0.95 : wmax * 0.62;
                float xa = hx - Xa;
                float2 root = float2(xa, yPath(xa, H) + swim(Xa, H, t) + sg * wa * 0.80);
                // the leading edge points out and a little back (pectoral) or well back (pelvic), flapping slowly,
                // the two sides out of step
                float flap = (f == 0 ? 0.16 : 0.12) * sin(t * 2.6 + sg * 1.4 + f * 0.9);
                float aLead = (f == 0 ? 2.02 : 2.25) + flap;
                float span = f == 0 ? 0.95 : 0.72;
                float len = f == 0 ? 0.50 * H : 0.28 * H;
                float u, k, lead;
                float cvF = fin(float2(x, y) - root, sg, aLead, span, len, u, k, lead);
                if (cvF > 0.0)
                {
                    // the membrane: warm cream at the root, white through the middle, teal-blue out toward the edge
                    // and most on the trailing side; rays fanning out along the curve; the leading edge's rim bright
                    float uc = saturate(u);
                    float kc = saturate(k);
                    float3 fc = lerp(float3(1.00, 0.76, 0.50), float3(1.00, 0.97, 0.92), smoothstep(0.06, 0.34, uc));
                    float teal = smoothstep(0.25, 0.85, uc) * (0.50 + 0.50 * kc);
                    fc = lerp(fc, float3(0.34, 0.76, 0.88), teal);
                    float rayVis = smoothstep(10.0, 26.0, len) * smoothstep(0.10, 0.30, uc);
                    float rw = 0.5 + 0.5 * cos(kc * 3.14159 * 2.0 * (f == 0 ? 5.0 : 3.5));
                    float rw4 = rw * rw * rw * rw;
                    fc *= 1.0 - 0.08 * rayVis * (1.0 - rw);
                    fc = lerp(fc, float3(0.95, 0.98, 0.98), rayVis * rw4 * 0.45);       // fine white rays to the edge
                    fc = lerp(fc, float3(1.00, 0.98, 0.95), lead * 0.80);
                    // translucent: the pond shows through more toward the edge and the trailing side
                    float fa = cvF * lerp(0.92, 0.50, uc * uc) * (1.0 - 0.25 * kc);
                    L += float3(0.70, 0.90, 0.95) * cvF * teal * 0.10 * glowK;            // a faint cool glow
                    finC = lerp(finC, fc, fa);
                    finA = max(finA, fa);
                }
            }
        }
        // the butterfly tail: two long flowing lobes, fluttering, rays along it, glowing gold at the edges
        // the two lobes are long and wispy, spreading only a little, the whole veil rippling as it trails
        float q = (X - 0.92 * Lb) / Lt;
        float qq = saturate(q);
        float lat2 = lat + 0.045 * H * qq * sin(q * 6.0 - t * 6.0) + 0.05 * H * qq * qq * sin(t * 2.3 + 1.0);
        float wt = H * (0.030 + 0.25 * pow(qq, 0.80)) * (1.0 - 0.15 * smoothstep(0.75, 1.1, q));
        float uT = lat2 / max(wt, 0.5);
        // a deep fork: the two lobes run long at the outside, the middle cut back; the ends soft and rounded
        float au = saturate(abs(uT));
        float qe = 0.58 + 0.50 * pow(au, 1.1) - 0.22 * smoothstep(0.85, 1.0, au) + 0.03 * sin(uT * 3.0 + t * 2.0);
        float dT = max(max(abs(lat2) - wt, (q - qe) * Lt), -q * Lt);
        float cvT = fill(dT, 1.0);
        if (cvT > 0.0)
        {
            float tq = saturate(q / qe);
            // orange at the root, then a translucent cream-gold veil with fine rays, its edges lit gold
            float3 tc = lerp(float3(0.98, 0.48, 0.16), float3(1.00, 0.80, 0.52), smoothstep(0.05, 0.35, tq));
            tc = lerp(tc, float3(1.00, 0.93, 0.80), smoothstep(0.45, 1.0, tq) * 0.55);
            float tr = 0.5 + 0.5 * cos(uT * 3.14159 * 5.5 + q * 2.0);
            tc *= 0.78 + 0.32 * tr * tr;
            float tedge = saturate(1.0 + dT / (0.030 * H + 0.6));
            tc += float3(0.55, 0.42, 0.20) * tedge * 0.55;
            float ta = cvT * lerp(0.95, 0.62, tq);
            finC = lerp(finC, tc, ta);
            finA = max(finA, ta);
        }
        float tailHalo = exp(-max(dT, 0.0) / (0.04 * H + 0.5)) * (1.0 - cvT) * step(0.0, q);
        // a thin translucent dorsal fin along the back
        float dDor = abs(lat) - 0.020 * H;
        float dorsal = fill(dDor, 1.0) * smoothstep(0.30, 0.38, sB) * (1.0 - smoothstep(0.78, 0.92, sB));

        // the body: cream lit from the upper left, orange-red kohaku patches, fine scales, a warm translucent rim
        float cvB = fill(dB, 1.0);
        float3 bodyC = float3(0.0, 0.0, 0.0);
        if (cvB > 0.0)
        {
            float v = clamp(lat / max(wB, 0.5), -1.0, 1.0);
            float3 n = normalize(float3(-0.15 * (1.0 - smoothstep(0.0, 0.3, sB)), v * 0.95, sqrt(saturate(1.0 - 0.80 * v * v))));
            float3 Ld = normalize(float3(-0.35, 0.55, 0.76));
            float dif = saturate(dot(n, Ld));
            float spec = pow(saturate(dot(n, normalize(Ld + float3(0.0, 0.0, 1.0)))), 40.0);
            // the kohaku pattern, fixed to the fish: an orange cap on the head (the nose left white), then two big
            // patches lying across the back (crossing the spine, edges wandering), cream between and on the belly sides
            // the patches' edges wander: each boundary is pushed along the body by noise across it
            float pn = vnoise(float2(sB * 2.6 + 11.0, v * 0.55 + 2.0)) * 0.70 + vnoise(float2(sB * 6.0 + 3.0, v * 1.6)) * 0.30;
            float wob = (vnoise(float2(v * 2.2 + 5.0, 1.7)) - 0.5) * 0.12 + (vnoise(float2(v * 5.0, 8.3)) - 0.5) * 0.05;
            float sw = sB + wob;
            float across = 1.0 - smoothstep(0.55, 0.95, abs(v - 0.15 * sin(sB * 7.0 + 1.0)));
            float band1 = smoothstep(0.29, 0.33, sw) * (1.0 - smoothstep(0.50, 0.54, sw + 0.05 * v));
            float band2 = smoothstep(0.59, 0.63, sw - 0.04 * v) * (1.0 - smoothstep(0.83, 0.88, sw));
            float patchR = saturate((band1 + band2) * across);
            float cap = smoothstep(0.07, 0.11, sB) * (1.0 - smoothstep(0.21, 0.26, sB)) * (1.0 - smoothstep(0.55, 0.80, abs(v + 0.05)));
            float red = saturate(patchR + cap);
            float3 cream = float3(0.97, 0.90, 0.80);
            float3 orange = lerp(float3(0.97, 0.44, 0.14), float3(0.86, 0.26, 0.08), smoothstep(0.45, 0.70, pn));
            float3 base = lerp(cream, orange, red);
            // scales: small crescents in offset rows, visible where they are big enough
            float2 scq = float2(X / (0.045 * H), lat / (0.036 * H));
            float row = floor(scq.y);
            float2 sf = frac(float2(scq.x + 0.5 * row, scq.y)) - 0.5;
            float cres = smoothstep(0.38, 0.50, length(sf * float2(1.0, 1.1) + float2(0.22, 0.0)));
            float scVis = smoothstep(2.6, 4.5, 0.045 * H) * smoothstep(0.12, 0.25, sB) * (1.0 - smoothstep(0.88, 1.0, sB)) * (0.4 + 0.6 * (1.0 - abs(v)));
            base *= 1.0 - (0.10 * red + 0.04) * cres * scVis;
            bodyC = base * (0.50 + 0.48 * dif) + float3(1.00, 0.97, 0.92) * spec * 0.22;
            bodyC *= 0.88 + 0.12 * (1.0 - abs(v));
            bodyC += float3(1.00, 0.58, 0.28) * pow(abs(v), 5.0) * 0.30;            // light through the thin edge
            // the eyes, set wide on the head, with a glint; the nose a touch pink
            float2 eyeQ = float2(X - 0.085 * Lb, abs(lat) - 0.66 * wB);
            float er = max(0.019 * H, 0.8);
            bodyC = lerp(bodyC, float3(0.05, 0.04, 0.05), fill(length(eyeQ) - er, 1.0));
            bodyC += float3(0.9, 0.9, 0.9) * fill(length(eyeQ + float2(0.35 * er, -0.35 * er * sign(lat))) - 0.35 * er, 1.0) * 0.8;
            bodyC = lerp(bodyC, float3(1.00, 0.80, 0.72), (1.0 - smoothstep(0.0, 0.05, sB)) * 0.4);
            bodyC = lerp(bodyC, float3(1.00, 0.95, 0.86), dorsal * 0.45);
        }
        // barbels: two fine whiskers at the nose
        float2 nose = float2(hx, yP + swim(0.0, H, t));
        float wh = 0.0;
        for (int b = 0; b < 2; b++)
        {
            float sg = b == 0 ? 1.0 : -1.0;
            float2 a0 = nose + float2(-0.02 * H, sg * 0.05 * H);
            float2 a1 = a0 + float2(0.06 * H, sg * (0.05 + 0.01 * sin(t * 2.0 + sg)) * H);
            wh = max(wh, fill(sdSegment(float2(x, y), a0, a1) - 0.25 * max(s, 0.8), 0.8));
        }
        float3 fishC = lerp(finC, bodyC, cvB);
        float fishA = max(finA, cvB);
        fishC = lerp(fishC, float3(0.95, 0.88, 0.78), wh * 0.7 * (1.0 - cvB));
        fishA = max(fishA, wh * 0.7);
        fishA *= inStrip;
        // the glow already on the water stays under the fish, not on it
        L *= 1.0 - fishA;
        col = lerp(col, fishC, fishA);
        cover = max(cover, fishA);
        dFish = min(dB, dT + 0.03 * H);
        // the koi's warm glow on the water round it (a halo, and a wider breath of light; stronger on the beat)
        L += float3(1.00, 0.60, 0.28) * (exp(-max(dFish, 0.0) / (0.06 * H)) * 0.32 + exp(-max(dFish, 0.0) / (0.28 * H)) * 0.12) * glowK * (1.0 + 0.5 * kickB) * inStrip * (1.0 - fishA);
        L += gold * tailHalo * 0.30 * glowK * inStrip * (1.0 - fishA);               // the veil's lit edges glow
    }

    // ------------------------------------------------------------------ fireflies over the taskbar
    if (up && y > H * 0.9)
    {
        float cellF = 0.55 * H;
        float2 fp = float2(x / cellF, (y - t * 0.12 * H) / cellF);
        float2 fi = floor(fp);
        float2 fr = hash22(fi + 3.7);
        float2 fd = (frac(fp) - 0.2 - 0.6 * fr) * cellF + float2(0.10 * H * sin(t * 0.7 + fr.x * 6.0), 0.0);
        float lifeF = saturate(1.0 - (y - H) / max(room, 1.0));
        float liveF = step(fr.y, 0.10 * (1.0 - smoothstep(hx - 2.0 * H, hx + 1.0 * H, fi.x * cellF))) * on;
        float pulse = 0.5 + 0.5 * sin(t * (1.5 + 2.0 * fr.x) + fr.y * 6.28);
        L += gold * (exp(-dot(fd, fd) / (0.6 * s * s + 0.2)) * 1.5 + exp(-length(fd) / (2.0 * s)) * 0.15) * liveF * lifeF * pulse;
    }

    // ------------------------------------------------------------------ put together
    float3 lightD = toneHue(L);
    float3 rgb = col + lightD;
    float alpha = max(cover, max(lightD.r, max(lightD.g, lightD.b)));
    rgb += (hash12(uv * size + frac(t * 7.13) * 91.7) - 0.5) * 0.008;
    float aa = saturate(max(alpha, max(rgb.r, max(rgb.g, rgb.b))));
    return paint(saturate(rgb) / max(aa, 1e-3), aa);
}