Sod Roll

by TaiDev, progress bar

Plz

64 downloads Download file, 3.2 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 81363d3674f4f76816f38d500fd9e62e480223a0a59162c86554be2035baf248

//! name: Sod Roll
//! author: Claude
//! kind: progress
//! description: Cuộn cỏ lăn trên nền đất kiểu loading Plants vs Zombies, trải cỏ tới chỗ đang phát

// Trộn lớp "top" lên lớp "bottom" (màu không nhân sẵn alpha).
float4 over(float4 top, float4 bottom)
{
    float a = top.a + bottom.a * (1.0 - top.a);
    float3 c = (top.rgb * top.a + bottom.rgb * bottom.a * (1.0 - top.a)) / max(a, 0.0001);
    return float4(c, a);
}

float noise2(float2 p)
{
    return frac(sin(dot(floor(p), float2(12.9898, 78.233))) * 43758.5453);
}

float4 main(float2 uv : TEXCOORD) : COLOR
{
    // Đơn vị pixel: x dọc thanh, y là khoảng cách từ mép màn hình
    float2 px = float2(uv.x * size.x, rise(uv) * size.y);
    float H = size.y;

    float groundH = H * 0.20;                     // độ dày dải đất
    float rollMax = H * 0.30;                     // bán kính cuộn cỏ lúc đầu
    float rollR = rollMax * (1.0 - 0.5 * progress); // cuộn nhỏ dần khi trải cỏ ra
    float cx = rollMax + progress * (size.x - 2.0 * rollMax);
    float cy = groundH + rollR + beat * 1.5;      // nảy nhẹ theo nhịp

    // ---------- Đất ----------
    float n = noise2(px / 3.0);
    float3 dirtColor = lerp(float3(0.27, 0.16, 0.08), float3(0.43, 0.28, 0.14), n);
    float shadow = 1.0 - 0.45 * exp(-pow((px.x - cx) / (rollR * 1.2), 2.0));
    float dirtA = (1.0 - smoothstep(groundH - 0.7, groundH + 0.7, px.y)) * 0.85;
    float4 dirt = float4(dirtColor * shadow, dirtA);

    // ---------- Cỏ đã trải (phía sau cuộn) ----------
    float blade = abs(sin(px.x * 1.3 + sin(px.x * 0.4 + time) * 1.5));
    float grassTop = groundH + 2.5 * blade;
    float grassBottom = groundH * 0.45;
    float laid = 1.0 - smoothstep(cx - 1.0, cx + 1.0, px.x);
    float grassA = laid
                 * (1.0 - smoothstep(grassTop - 0.7, grassTop + 0.7, px.y))
                 * smoothstep(grassBottom - 0.7, grassBottom + 0.7, px.y)
                 * 0.95;
    float gt = saturate((px.y - grassBottom) / max(grassTop - grassBottom, 1.0));
    float3 grassColor = lerp(float3(0.10, 0.36, 0.08), float3(0.35, 0.72, 0.18), gt);
    grassColor *= 0.9 + 0.2 * noise2(px / 2.0);
    grassColor *= shadow;
    float4 grass = float4(grassColor, grassA);

    // ---------- Cuộn cỏ ----------
    float2 d2 = px - float2(cx, cy);
    float d = length(d2);
    float ang = atan2(d2.y, d2.x);
    float rot = cx / rollR;                       // lăn theo quãng đường đi được
    float s = frac(d / rollR * 2.5 + (ang + rot) / 6.28318);
    float greenBand = smoothstep(0.0, 0.08, s) * (1.0 - smoothstep(0.58, 0.66, s));
    float3 rollGreen = lerp(float3(0.14, 0.45, 0.10), float3(0.42, 0.78, 0.22), saturate(d / rollR));
    float3 rollDirt = float3(0.33, 0.20, 0.10);
    float3 rollColor = lerp(rollDirt, rollGreen, greenBand);
    float shade = 0.65 + 0.45 * saturate(0.5 + 0.5 * d2.y / rollR); // sáng ở trên
    rollColor *= shade;
    rollColor = lerp(rollColor, float3(0.06, 0.22, 0.05), smoothstep(rollR - 2.5, rollR - 0.5, d) * 0.8); // viền tối
    float rollA = 1.0 - smoothstep(rollR - 1.0, rollR, d);
    float4 roll = float4(rollColor, rollA);

    float4 result = over(roll, over(grass, dirt));
    return paint(result.rgb, result.a);
}