Level Up

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

Thanh kinh nghiệm kiểu game nhập vai trong khung vàng pixel chạm trổ, bài chạy tới đâu mana dâng tới đó, cứ qua mỗi một phần tư bài là lên cấp với cột sáng phụt lên và sao lấp lánh, tới nhịp là tia sáng nhỏ bay lên.

2 lượt tải Tải file, 8.5 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 f187a469ff1e81bc9afba31bf04bcba499cdb9bc0889da6efe06bf58361431cb

//! name: Level Up
//! author: MusicBar
//! kind: progress
//! description: A fantasy RPG experience bar in an ornate pixel-art gold frame fills with glowing mana as the song plays; every quarter of the song it levels up in a burst of light pillars and sparkles, and small sparks rise from the mana on every beat.

float hash1(float n) { return frac(sin(n * 127.1 + 311.7) * 43758.5453); }

// 1 when two whole numbers match, and a whole number a modulo m (both safe against float drift).
float eq(float a, float b) { return step(abs(a - b), 0.5); }
float modi(float a, float m) { return floor(frac((a + 0.5) / m) * m); }

// 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);
}

float4 main(float2 uv : TEXCOORD) : COLOR
{
    // Chunky pixels: at least 16 rows at any bar height, counted from the middle row.
    float pz = max(1.0, floor(size.y / 16.0));
    float2 c = floor(float2(uv.x * size.x, (1.0 - uv.y) * size.y) / pz);
    float ry = c.y - floor(floor(size.y / pz) * 0.5);
    float ay = abs(ry);
    float cols = floor(size.x / pz);
    float hc = floor(progress * size.x / pz);
    float perU = size.y / pz;                                      // pixels per bar height
    float3 white = float3(1, 1, 1);
    float3 acc = float3(0, 0, 0);
    float cover = 0;

    // Gold with a touch of the accent color, and a dark ink for outlines.
    float3 gHi = lerp(float3(1.0, 0.95, 0.66), colorC.rgb, 0.2);
    float3 gMid = lerp(float3(0.96, 0.7, 0.2), colorC.rgb, 0.25);
    float3 gLo = lerp(float3(0.56, 0.32, 0.08), colorC.rgb * 0.55, 0.25);
    float3 ink = float3(0.14, 0.06, 0.05);

    float x0 = 7.0, x1 = cols - 8.0;                               // the bar runs between two end orbs
    float inBar = step(x0, c.x) * step(c.x, x1);
    float played = step(c.x, hc);

    // Mana: rolling bands in four dithered shades, a glossy top row, bubbles drifting along, a white-hot front.
    float inCh = step(ay, 2.0) * inBar;
    float hot = exp(-max(hc - c.x, 0.0) / (perU * 1.2));
    float w = 0.5 * sin(c.x * 0.31 - time * 7.0 + ry * 0.9) + 0.35 * sin(c.x * 0.12 + time * 2.2 - ry * 0.6);
    float v = saturate(0.38 + 0.3 * w + 0.11 * ry + 0.3 * hot + 0.12 * level);
    float bx = modi(c.x, 2.0), by = modi(c.y, 2.0);
    float L = floor(v * 3.0 + (bx * 2.0 + by * 3.0 - bx * by * 4.0) * 0.25);
    float3 mana = L < 0.5 ? lerp(colorB.rgb, colorA.rgb, 0.25) * 0.7 : (L < 1.5 ? lerp(colorB.rgb, colorA.rgb, 0.65) : (L < 2.5 ? lerp(colorA.rgb, white, 0.3) : lerp(colorA.rgb, white, 0.75)));
    mana = lerp(mana, lerp(colorA.rgb, white, 0.7), eq(ry, 1.0) * 0.45) * (1.0 - 0.3 * eq(ry, 2.0));
    float bc = floor(c.x - time * 11.0);
    mana = lerp(mana, white, step(hash1(bc * 1.7), 0.07) * eq(ry, floor(hash1(bc * 3.1) * 4.0) - 2.0));
    mana = lerp(mana, lerp(colorC.rgb, white, 0.55 + 0.45 * beat), step(hc - 1.0, c.x));
    layer(acc, cover, mana, inCh * played);
    float3 empty = float3(0.05, 0.04, 0.1) + lerp(colorA.rgb, white, 0.3) * 0.3 * eq(modi(c.x, 4.0), 0.0) * eq(ry, 0.0);
    layer(acc, cover, empty, inCh * (1.0 - played) * 0.55);

    // The frame: studded gold rails, polished where the song has been, dull bronze ahead; a glint runs along the played part.
    float fRow = step(2.5, ay) * step(ay, 5.5) * inBar;
    float3 fc = eq(ay, 5.0) > 0.5 ? ink : (eq(ay, 3.0) > 0.5 ? gMid : (ry > 0.0 ? gHi : gLo));
    fc = lerp(fc, gHi, eq(modi(c.x, 6.0), 0.0) * eq(ay, 3.0));
    fc = lerp(fc, ry > 0.0 ? gMid : ink, eq(modi(c.x + 3.0, 6.0), 0.0) * eq(ay, 4.0));
    fc *= lerp(0.62, 1.0, played);
    fc = lerp(fc, white, eq(modi(c.x - floor(time * 24.0) + ry, 56.0), 0.0) * played * step(ay, 4.5) * 0.75);
    layer(acc, cover, fc, fRow);

    // A soft glow over the mana and around the front, chunky like everything else.
    layer(acc, cover, colorA.rgb, exp(-max(ay - 2.0, 0.0) / 2.0) * played * inBar * (0.12 + 0.12 * level) * step(2.5, ay));
    layer(acc, cover, lerp(colorC.rgb, white, 0.4), exp(-length(float2(c.x - hc, ry)) / 3.0) * (0.35 + 0.4 * beat) * step(0.5, length(float2(c.x - hc, ry * 0.6)) - 2.0));

    // Gem sockets at each quarter: gold diamonds with little wings; the gem lights once the song gets there.
    float m = clamp(floor(c.x / (cols * 0.25) + 0.5), 1.0, 3.0);
    float mx = floor(m * cols * 0.25);
    float dx = c.x - mx, ax = abs(dx);
    float man = ax + ay;
    float lit = step(mx, hc);
    float bt = (hc - mx) / perU;                                   // bar heights since the front passed this mark
    float burst = step(0.0, bt) * saturate(1.0 - bt / 1.8);
    float3 gemC = m < 1.5 ? colorA.rgb : (m < 2.5 ? colorB.rgb : colorC.rgb);
    float3 sock = man < 1.5 ? lerp(gemC * 0.35, lerp(gemC, white, 0.45), lit) : (man < 2.5 ? lerp(gemC * 0.25, gemC, lit) : lerp(gemC * 0.15, gemC * 0.6, lit));
    sock = lerp(sock, white, eq(dx, -1.0) * eq(ry, 1.0) * (0.4 + 0.5 * lit));
    sock = man < 3.5 ? lerp(sock, white, exp(-bt * 6.0) * step(0.0, bt)) : (man < 4.5 ? (ry >= 0.0 ? gHi : gMid) : (man < 5.5 ? (ry >= 0.0 ? gMid : gLo) : ink));
    layer(acc, cover, gemC, exp(-man / 2.5) * lit * (0.25 + 0.25 * beat) * step(6.5, man));
    layer(acc, cover, sock * (man < 3.5 ? 1.0 : lerp(0.62, 1.0, lit)), step(man, 6.5));

    // End orbs: gold rings with crown points; the left holds swirling mana that pulses with the music,
    // the right stays dark until the song is done.
    float leftSide = step(c.x, cols * 0.5);
    float2 od = float2(c.x - (leftSide > 0.5 ? 6.0 : cols - 7.0), ry);
    float d2 = dot(od, od);
    float full = max(leftSide, step(0.999, progress));
    float swirl = sin(atan2(od.y, od.x) * 2.0 + time * 4.0 + length(od));
    float3 orb = lerp(colorB.rgb * 0.15, lerp(colorA.rgb, white, 0.15 + 0.3 * step(0.3, swirl)) * (0.7 + 0.4 * level + 0.3 * beat), full);
    orb = lerp(orb, white, eq(od.x, -1.0) * eq(od.y, 1.0) * 0.8);
    float3 ring = d2 < 10.5 ? orb : (d2 < 18.5 ? gMid : (d2 < 30.5 ? (ry > 0.0 ? gHi : gLo) : ink));
    float crown = eq(od.x, 0.0) * eq(ay, 7.0);
    layer(acc, cover, ink, eq(od.x, 0.0) * eq(ay, 8.0) + (eq(abs(od.x), 1.0) * eq(ay, 7.0)));
    layer(acc, cover, gHi, crown);
    layer(acc, cover, ring, step(d2, 42.5));

    // Level up: pillars of light shoot up around the mark, racing chunks of light inside them.
    // They burst out of the frame both ways, with chunks of light racing outward and a white-hot center beam.
    float pil = step(ax, 1.5) + 0.8 * eq(ax, 5.0) + 0.65 * eq(ax, 10.0) + 0.5 * step(14.5, ax) * step(ax, 15.5) + 0.4 * eq(ax, 21.0);
    float race = step(0.4, frac((ay - bt * perU * 5.0) / 5.0));
    float reach = step(ay, 4.0 + bt * perU * 16.0 - ax * 0.3);
    float outside = lerp(0.3, 1.0, step(5.5, ay));
    layer(acc, cover, lerp(colorC.rgb, white, 0.3), exp(-length(float2(dx * 0.5, ry)) / 3.5) * burst * 0.55);
    layer(acc, cover, colorC.rgb, pil * burst * reach * outside * (0.4 + 0.5 * race));
    layer(acc, cover, white, step(ax, 0.5) * burst * reach * outside * (0.5 + 0.5 * race));

    // ...and sparkles: little four-point pixel stars that rise and twinkle.
    float star = 0, starCore = 0;
    for (int i = 0; i < 8; i++)
    {
        float fi = i;
        float sx = mx + floor((hash1(fi + m * 13.0) - 0.5) * 34.0);
        float sy = floor(-3.0 + 6.0 * hash1(fi * 2.3 + m) + bt * perU * (1.2 + 1.6 * hash1(fi + 5.0)));
        float arm = hash1(fi + 9.0) > 0.6 ? 2.0 : 1.0;
        float ddx = abs(c.x - sx), ddy = abs(ry - sy);
        float tw = step(0.3, frac(time * 7.0 + hash1(fi + 2.0)));
        starCore = max(starCore, step(ddx + ddy, 0.5));
        star = max(star, step(min(ddx, ddy), 0.5) * step(max(ddx, ddy), arm + 0.5) * tw);
    }
    layer(acc, cover, colorC.rgb, star * burst);
    layer(acc, cover, white, starCore * burst);

    // Sparks rise from the mana on every beat, and a few slow motes drift up all the time.
    float sc = floor(c.x / 7.0);
    float sh = hash1(sc * 1.3 + floor(time * 2.0) * 7.1);
    float sxk = sc * 7.0 + floor(hash1(sc * 4.1) * 7.0);
    float spark = eq(c.x, sxk) * eq(ry, 2.0 + floor((1.0 - beat) * 7.0 * (0.6 + 0.4 * sh))) * step(0.45, sh) * step(0.05, beat);
    float life = frac(time * 0.5 + hash1(sc * 2.9));
    float mote = eq(c.x, sc * 7.0 + floor(hash1(sc * 6.7) * 7.0)) * eq(ry, 3.0 + floor(life * 6.0)) * step(0.55, hash1(sc * 8.3));
    layer(acc, cover, lerp(colorA.rgb, white, 0.65), spark * played * inBar);
    layer(acc, cover, lerp(colorA.rgb, white, 0.4), mote * played * inBar * (1.0 - life) * 0.8);

    return paint(acc / max(cover, 0.001), cover);
}