Flower

by Naa, progress bar

Mình em là bông hoa

69 downloads Download file, 13.3 KB
How it installs, its SHA-256 and its code

Click Apply: MusicBar downloads it, checks its SHA-256 and puts it on the taskbar, or just puts it on if it already has it. Needs MusicBar 1.8 or newer.

SHA-256 2cbc798a6182facf96d9c72acaf86ab3ef1cc23f07c3e7ac4400688d8ec16d4f

//! name: Sakura Fubuki (Mưa Hoa Anh Đào)
//! author: Antigravity
//! kind: progress
//! description: Ba lớp sóng lụa xuân hồng phấn dâng mềm theo nhạc, bông hoa anh đào 5 cánh nở rộ ở đầu phát thả cơn mưa cánh hoa lật 3D bay trong nắng chiều

float hash11(float n)
{
    return frac(sin(n * 127.1 + 31.7) * 43758.5453);
}

float2 rot2d(float2 v, float a)
{
    float c = cos(a);
    float s = sin(a);
    return float2(c * v.x - s * v.y, s * v.x + c * v.y);
}

// 5-tap Gaussian-smoothed spectrum lookup so music waves rise in soft, expressive, rounded hills
float smoothBand(float f)
{
    float s0 = spectrum(f - 0.044);
    float s1 = spectrum(f - 0.022);
    float s2 = spectrum(f);
    float s3 = spectrum(f + 0.022);
    float s4 = spectrum(f + 0.044);
    return s0 * 0.12 + s1 * 0.24 + s2 * 0.28 + s3 * 0.24 + s4 * 0.12;
}

// Draws a single heart-notched Sakura petal in local coordinates q, with 3D tumble foreshortening.
// Returns x = petal mask, y = inner blush/sunlit highlight factor (0..1).
float2 sakuraPetal(float2 q, float R, float tumbleWidth, float aa)
{
    float2 u = q / max(R, 0.5);
    u.x /= clamp(tumbleWidth, 0.34, 1.0);

    // Tapered base (u.y < 0) and wide rounded upper lobes (u.y > 0) with signature V-cleft at top tip
    float widthScale = clamp(0.54 + 0.26 * u.y, 0.28, 0.82);
    float notch = 0.27 * smoothstep(0.22, 0.012, abs(u.x)) * smoothstep(0.32, 0.72, u.y);
    float2 pn = float2(u.x / widthScale, (u.y + 0.08 + notch) * 1.08);

    float d = length(pn);
    float invR = aa / max(R, 1.0);
    float mask = smoothstep(0.95 + invR, 0.84 - invR, d);

    // Subtle center crease & sunlit rim toward the notched tip
    float rim = smoothstep(0.35, 0.90, d) * smoothstep(-0.4, 0.7, u.y);
    return float2(mask, saturate(rim));
}

// Draws the 5-petal blooming Sakura blossom centered at origin with stamens & golden pollen anthers.
void drawSakuraBlossom(
    float2 fv, float R, float aa, float spin,
    float3 deepRose, float3 petalPink, float3 creamWhite, float3 stamenGold,
    inout float3 col, inout float alpha)
{
    float r = length(fv);
    if (r > R + 3.0) return;

    float2 q = rot2d(fv, spin);
    float safeX = q.x + (q.x >= 0.0 ? 0.0001 : -0.0001);
    float ang = atan2(q.y, safeX);

    // 5-fold rotational symmetry (72 deg = 1.25663706 rad per petal)
    float sector = 1.25663706;
    float a = ang - sector * floor(ang / sector + 0.5);

    // Petal-local coordinates: uy outward along petal axis, ux across petal width
    float2 u = float2(r * sin(a), r * cos(a)) / R;
    float py = u.y - 0.52;
    float widthProfile = clamp(0.30 + 0.34 * (u.y - 0.15), 0.14, 0.44);
    float notch = 0.14 * smoothstep(0.11, 0.008, abs(u.x)) * smoothstep(0.55, 0.85, u.y);
    float2 pn = float2(u.x / widthProfile, (py + notch) / 0.46);

    float dPetal = length(pn);
    float invR = aa / R;
    float petalMask = smoothstep(1.0 + invR * 1.4, 0.88 - invR, dPetal) * smoothstep(0.04, 0.14, u.y);

    // Soft petal overlap shading + delicate radial veins
    float edgeHighlight = smoothstep(0.55, 0.95, dPetal);
    float vein = 0.5 + 0.5 * cos(a * 25.0);
    float innerBlush = exp(-r / (R * 0.42));

    float3 blossomCol = lerp(petalPink, creamWhite, saturate(0.45 + 0.50 * (r / R) + 0.20 * edgeHighlight - 0.10 * vein));
    blossomCol = lerp(blossomCol, deepRose, saturate(innerBlush * 0.72));

    // 15 slender stamens radiating from center + golden pollen dots at tips + ruby-rose heart
    float stamenR = R * 0.40;
    float dStamen = r * abs(sin(ang * 7.5)) / 7.5;
    float filaments = smoothstep(0.48, 0.08, dStamen) * smoothstep(stamenR + 0.5, stamenR - 1.0, r) * smoothstep(R * 0.10, R * 0.18, r);
    float anthers = smoothstep(0.85, 0.15, dStamen) * exp(-abs(r - stamenR + 0.4) * 1.85);
    float centerHeart = smoothstep(R * 0.15, R * 0.04, r);

    col = lerp(col, blossomCol, petalMask * 0.96);
    col = lerp(col, lerp(creamWhite, stamenGold, 0.5), filaments * 0.78);
    col = lerp(col, deepRose, centerHeart * 0.92);
    col = lerp(col, stamenGold, saturate(anthers + smoothstep(R * 0.07, 0.2, r)) * 0.95);

    float totalMask = saturate(max(petalMask * 0.96, max(filaments * 0.78, anthers * 0.95)));
    alpha = max(alpha, totalMask);
}

// One parallax wind layer of fluttering 3D Sakura petals
void evalPetalLayer(
    float2 p, float barScale, float cw, float driftSpeed, float fallSpeed,
    float baseR, float baseAlpha, float seedOff, float2 hub, float audioGlow,
    float3 deepRose, float3 sakuraPink, float3 creamWhite,
    inout float3 col, inout float alpha)
{
    float cid = floor((p.x - time * driftSpeed) / cw);
    float h1 = hash11(cid * 4.91 + seedOff);
    float h2 = hash11(cid * 9.37 + seedOff * 1.7);
    float h3 = hash11(cid * 14.3 + seedOff * 2.3);

    // Smooth continuous breeze trajectory (drifting right & gently falling/swaying)
    float sx = (cid + 0.5) * cw + time * driftSpeed + (cw * 0.23) * sin(time * (0.75 + 0.35 * h1) + h1 * 6.283);
    float fallPhase = frac(h2 - time * fallSpeed / 64.0);
    float sy = -6.0 + fallPhase * 60.0 + 3.2 * sin(time * 1.3 + h2 * 6.283);

    float pR = baseR * (0.84 + 0.30 * h1);
    float clearHub = smoothstep(21.0, 32.0, length(float2(sx, sy) - hub));
    float2 delta = p - float2(sx, sy);
    if (dot(delta, delta) < (pR + 3.0) * (pR + 3.0) && clearHub > 0.01)
    {
        float spinAngle = time * (0.85 + 0.65 * h2) + h1 * 6.283;
        float tumble = 0.42 + 0.58 * abs(sin(time * (1.6 + 0.8 * h3) + h3 * 6.283));
        float2 pq = rot2d(delta, spinAngle);
        float2 sp = sakuraPetal(pq, pR, tumble, 0.55 / barScale);

        float pMask = sp.x * baseAlpha * clearHub;
        float halo = exp(-length(delta) / (pR * 1.35)) * (0.12 + 0.14 * audioGlow) * baseAlpha * clearHub;

        float3 pCol = lerp(lerp(deepRose, sakuraPink, 0.65 + 0.35 * h1), creamWhite, 0.38 + 0.54 * sp.y);
        col += sakuraPink * halo;
        col = lerp(col, pCol, pMask);
        alpha = max(alpha, saturate(pMask + halo * 0.65));
    }
}

float4 main(float2 uv : TEXCOORD) : COLOR
{
    float h = rise(uv);
    float barScale = max(size.y / 48.0, 0.45);
    float2 p = float2(uv.x * size.x, h * size.y) / barScale;
    float barW = size.x / barScale;

    // Continuous Gaussian-smoothed symmetric spectrum for soft, expressive spring waves
    float symU = abs(uv.x - 0.5) * 1.62;
    float bandMain = smoothBand(symU);
    float bandShifted = smoothBand(frac(symU * 0.68 + 0.14));
    float bass = smoothBand(0.06);
    float midFreq = smoothBand(0.32);
    float highFreq = spectrum(0.72);
    float audioGlow = saturate(0.58 * level + 0.42 * beat);

    // Anime Spring Sakura Palette (harmonized with song colors)
    float3 creamWhite = float3(1.0, 0.975, 0.985);
    float3 sakuraPink = lerp(colorA.rgb, float3(1.0, 0.60, 0.80), 0.52);
    float3 deepRose   = lerp(colorA.rgb, float3(0.92, 0.30, 0.56), 0.55);
    float3 springSky  = lerp(colorB.rgb, float3(0.52, 0.72, 1.0), 0.38);
    float3 sunPeach   = lerp(colorC.rgb, float3(1.0, 0.84, 0.56), 0.48);

    float hasProg = step(0.002, progress);
    float headU = lerp(0.50, clamp(progress, 0.034, 0.966), hasProg);
    float headX = headU * barW;

    float played = smoothstep(headX + 12.0, headX - 18.0, p.x);
    float activeZone = lerp(1.0, played, hasProg);
    float heroCushion = lerp(1.0, smoothstep(5.0, 28.0, abs(p.x - headX)) * 0.64 + 0.36, hasProg);

    float3 col = float3(0.0, 0.0, 0.0);
    float alpha = 0.0;

    // 1. Three Soft, Flowing Multi-Layer Sakura Silk Waves Rising Smoothly with the Music
    float swell1 = 0.5 + 0.5 * sin(p.x * 0.028 - time * 2.05) * cos(p.x * 0.011 + time * 0.88);
    float swell2 = 0.5 + 0.5 * sin(p.x * 0.035 + time * 1.60 + 1.7) * cos(p.x * 0.014 - time * 1.05);
    float swell3 = 0.5 + 0.5 * cos(p.x * 0.030 - time * 2.30 + 0.8);

    float eBase = saturate(bandMain * 0.76 + bandShifted * 0.26 + bass * 0.16) * (1.0 + 0.25 * beat);

    // Layer A (Back): Tall, pillowy sunset-peach & sakura mist wave (up to ~84% height)
    float hBack = clamp((0.12 + 0.10 * swell1 + eBase * (0.78 + 0.20 * swell2)) * 41.5, 5.0, 41.5);
    float backBody = smoothstep(hBack + 5.5, hBack - 7.5, p.y) * smoothstep(hBack + 6.0, 0.0, p.y * 0.65);
    float backCrest = exp(-abs(p.y - hBack + 1.5) / 3.8) * 0.48;
    float visBack = lerp(0.14, 0.54, activeZone) * heroCushion;
    float3 colBack = lerp(springSky, lerp(sakuraPink, sunPeach, 0.38), saturate(p.y / 34.0 + 0.20));
    col += colBack * (backBody + backCrest) * visBack;
    alpha = saturate((backBody * 0.85 + backCrest * 0.65) * visBack);

    // Layer B (Middle): Silky flowing rose-blossom ribbon wave with glowing sunlit crest
    float eMid = saturate(bandShifted * 0.60 + bandMain * 0.40 + midFreq * 0.18) * (1.0 + 0.20 * beat);
    float hMid = clamp((0.11 + 0.09 * swell2 + eMid * (0.66 + 0.16 * swell3)) * 37.5, 4.5, 37.5);
    float midBody = smoothstep(hMid + 2.6, hMid - 4.2, p.y);
    float midRim = exp(-abs(p.y - hMid) / 2.1);
    float visMid = lerp(0.16, 0.68, activeZone) * heroCushion;
    float3 colMid = lerp(deepRose, lerp(sakuraPink, creamWhite, 0.48), saturate(p.y / max(hMid, 1.0)));
    col = lerp(col, colMid, midBody * visMid * 0.74);
    col += lerp(sunPeach, creamWhite, 0.60) * midRim * lerp(0.12, 0.58, activeZone) * heroCushion;
    alpha = max(alpha, saturate(midBody * visMid * 0.78 + midRim * 0.46 * activeZone * heroCushion));

    // Layer C (Front): Soft blush-pink petal wave with creamy white-pink highlight rim
    float hFront = clamp((0.09 + 0.07 * swell3 + (bass * 0.48 + bandMain * 0.52) * (0.48 + 0.14 * swell1)) * 30.0, 3.8, 29.0);
    float frontBody = smoothstep(hFront + 1.8, hFront - 2.8, p.y);
    float frontRim = exp(-abs(p.y - hFront) / 1.55);
    float visFront = lerp(0.18, 0.82, activeZone) * heroCushion;
    float3 colFront = lerp(sakuraPink, creamWhite, saturate(pow(saturate(p.y / max(hFront, 1.0)), 1.45) * 0.86));
    col = lerp(col, colFront, frontBody * visFront * 0.82);
    col += creamWhite * frontRim * lerp(0.14, 0.62, activeZone) * heroCushion;
    alpha = max(alpha, saturate(frontBody * visFront * 0.85 + frontRim * 0.50 * activeZone * heroCushion));

    // Warm golden-hour komorebi bokeh orbs floating inside the spring waves
    float bCell = floor((p.x - time * 8.5) / 50.0);
    float bh1 = hash11(bCell * 3.9 + 1.4);
    float bh2 = hash11(bCell * 8.3 + 5.2);
    float2 bPos = float2((bCell + 0.5) * 50.0 + time * 8.5 + 11.0 * sin(time * 0.6 + bh1 * 6.283), 9.0 + 22.0 * bh2);
    float bR = 5.5 + 5.5 * bh1;
    float dB = length(p - bPos);
    float bokeh = exp(-dB * dB / (bR * bR * 0.45)) * (0.20 + 0.15 * midFreq) * lerp(0.22, 1.0, activeZone);
    col += lerp(sakuraPink, sunPeach, bh2 * 0.65) * bokeh;
    alpha = saturate(alpha + bokeh * 0.65);

    // 2. Spring Sunlight Kirakira 4-Pointed Stars Twinkling on High Notes
    float kCell = floor((p.x - time * 12.0) / 50.0);
    float kh1 = hash11(kCell * 6.31 + 2.7);
    float2 kp = float2((kCell + 0.5) * 50.0 + time * 12.0, 14.0 + 26.0 * hash11(kCell * 11.9));
    float2 kd = abs(p - kp);
    float glint = (exp(-kd.x * 1.9 - kd.y * 0.4) + exp(-kd.y * 1.9 - kd.x * 0.4)) * exp(-length(kd) * 0.4);
    float blink = pow(0.5 + 0.5 * sin(time * 3.5 + kh1 * 23.0), 4.0) * (0.42 + 0.65 * highFreq + 0.42 * beat);
    float gMask = saturate(glint) * blink * step(0.30, kh1) * smoothstep(20.0, 30.0, length(kp - float2(headX, 24.5)));
    col += lerp(sunPeach, creamWhite, 0.65) * gMask * 0.85;
    alpha = max(alpha, gMask * 0.80);

    // 3. Two Hero Petals Peeling Directly Off the Blooming Sakura & Sweeping Rightward
    float2 hub = float2(headX, 24.5 + 1.0 * sin(time * 1.35));
    [unroll]
    for (int d = 0; d < 2; d++)
    {
        float fd = (float)d;
        float life = frac(time * 0.26 + fd * 0.5);
        float liftFade = smoothstep(0.0, 0.09, life) * smoothstep(1.0, 0.76, life) * hasProg;
        float2 startPos = hub + float2(11.0 + 2.0 * fd, 2.0 + (fd - 0.5) * 5.0);
        float2 sPos = startPos + float2(life * (128.0 + 28.0 * fd), sin(life * 5.0 + fd * 2.1) * 5.8 + (0.4 - fd * 0.8) * 4.5 * life);
        float2 delta = p - sPos;
        if (dot(delta, delta) < 64.0 && liftFade > 0.01)
        {
            float2 pq = rot2d(delta, life * 4.5 + fd * 1.8);
            float tumble = 0.45 + 0.55 * abs(cos(life * 7.5 + fd));
            float2 sp = sakuraPetal(pq, 5.8, tumble, 0.52 / barScale);
            float pMask = sp.x * liftFade * 0.96;
            float3 pCol = lerp(sakuraPink, creamWhite, 0.45 + 0.50 * sp.y);
            col = lerp(col, pCol, pMask);
            alpha = max(alpha, pMask);
        }
    }

    // 4. Three Silky-Smooth Parallax Layers of Fluttering 3D Sakura Petals
    evalPetalLayer(p, barScale, 34.0, 12.0, 7.5,  3.6, 0.58, 1.4, hub, audioGlow, deepRose, sakuraPink, creamWhite, col, alpha);
    evalPetalLayer(p, barScale, 48.0, 18.5, 10.5, 5.0, 0.80, 5.8, hub, audioGlow, deepRose, sakuraPink, creamWhite, col, alpha);
    evalPetalLayer(p, barScale, 64.0, 26.0, 13.5, 6.6, 0.95, 9.6, hub, audioGlow, deepRose, sakuraPink, creamWhite, col, alpha);

    // 5. Hero Giant 5-Petal Blooming Sakura Flower at Playhead (~39px!)
    if (hasProg > 0.5)
    {
        float dHub = length(p - hub);
        float heroAura = exp(-dHub / (22.0 + 7.5 * beat)) * (0.36 + 0.30 * beat);
        col += lerp(sakuraPink, sunPeach, 0.42) * heroAura;
        alpha = saturate(alpha + heroAura * 0.65);

        drawSakuraBlossom(p - hub, 19.2, 0.52 / barScale, time * 0.32, deepRose, sakuraPink, creamWhite, sunPeach, col, alpha);
    }

    return paint(col, alpha);
}