Turbo Lane

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

Xe đua mui thấp lao vun vút tới chỗ đang phát, kéo theo vệt đèn hậu đỏ rực, nhạc càng to vạch đường càng vụt nhanh, tới nhịp là ống pô phụt lửa.

113 lượt tải Tải file, 10.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 c949f8a5a12aa678ddba62c0b28e11d7d46ba0eee41bcbfe9ef27151b2fa44a6

//! name: Turbo Lane
//! author: MusicBar
//! kind: progress
//! description: A low race car tears down the track to the playhead, painting a taillight streak behind it, with the exhaust flaring and the suspension dipping on every beat.

float hash2(float2 p) { float3 q = frac(float3(p.x, p.y, p.x) * 0.1031); q += dot(q, q.yzx + 33.33); return frac((q.x + q.y) * q.z); }

// Smooth value noise, for the asphalt grain and the tire smoke.
float vnoise(float2 p)
{
    float2 i = floor(p), f = frac(p);
    f = f * f * (3.0 - 2.0 * f);
    return lerp(lerp(hash2(i), hash2(i + float2(1, 0)), f.x), lerp(hash2(i + float2(0, 1)), hash2(i + float2(1, 1)), f.x), f.y);
}

// The car's roofline in bar heights: a low nose, a bump over each wheel, a ducktail at the back.
float roof(float x)
{
    float y = 0.315 + 0.035 * exp(-pow((x + 0.33) / 0.2, 2.0)) + 0.06 * exp(-pow((x + 1.45) / 0.32, 2.0));
    return y + 0.05 * smoothstep(-1.55, -1.95, x) - 0.1 * smoothstep(-0.3, 0.22, x);
}

float ellipse(float2 p, float2 r) { float k0 = length(p / r); return k0 * (k0 - 1.0) / max(length(p / (r * r)), 0.0001); }

float sdSeg(float2 p, float2 a, float2 b) { float2 pa = p - a, ba = b - a; return length(pa - ba * saturate(dot(pa, ba) / dot(ba, ba))); }

// 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
{
    float u = size.y;
    float2 px = float2(uv.x * size.x, rise(uv) * size.y);      // pixels: along the bar, up from the screen edge
    float head = progress * size.x;
    float2 q = (px - float2(head, 0.0)) / u;                   // the car's frame, in bar heights, nose near 0
    float aa = 1.0 / u;                                        // one pixel in bar heights
    float3 acc = float3(0, 0, 0);
    float cover = 0;
    float bass = spectrum(0.04);
    float run = time * 7.0;                                    // how far the road has slid by, in bar heights

    // The track: dark asphalt at the screen edge with a striped kerb on the far side and dashes rushing left.
    layer(acc, cover, float3(0.1, 0.1, 0.12) + vnoise(px * 0.5) * 0.06, step(px.y, 0.15 * u) * 0.85);
    float stripe = step(0.5, frac((q.x + run) / 0.36));
    layer(acc, cover, lerp(colorA.rgb * 0.8, float3(0.92, 0.92, 0.95), stripe), step(0.15 * u, px.y) * step(px.y, 0.19 * u) * 0.75);
    float dl = 0.45 + 0.4 * level;                             // dashes stretch into streaks when the song is loud
    float dx = frac((q.x + run) / 1.1) * 1.1;
    float dash = smoothstep(0.0, 0.08, dx) * smoothstep(dl, dl - 0.15, dx) * smoothstep(0.016 * u + 0.5, 0.016 * u - 0.5, abs(px.y - 0.06 * u));
    layer(acc, cover, float3(0.95, 0.95, 0.85), dash * 0.8);

    // The finish: a checkered strip across the track and a waving checkered flag at the far end of the bar.
    float fx = size.x - 0.32 * u;
    float2 fc = floor(float2(px.x - fx, px.y) / (0.075 * u));
    float check = frac((fc.x + fc.y) * 0.5) * 2.0;
    layer(acc, cover, lerp(float3(0.08, 0.08, 0.1), float3(0.95, 0.95, 0.95), check), step(fx - 0.3 * u, px.x) * step(px.x, fx - 0.15 * u) * step(px.y, 0.15 * u));
    float fl = (fx - px.x) / u;
    float fy = (0.93 * u - px.y) / u + 0.05 * sin(fl * 8.0 - time * 7.0) * saturate(fl / 0.7);
    float inFlag = step(0.0, fl) * step(fl, 0.66) * step(0.0, fy) * step(fy, 0.34);
    float2 fcell = floor(float2(fl, fy) / 0.085);
    float cloth = 0.75 + 0.3 * cos(fl * 8.0 - time * 7.0);
    layer(acc, cover, lerp(float3(0.1, 0.1, 0.12), float3(1, 1, 1), frac((fcell.x + fcell.y) * 0.5) * 2.0) * cloth, inFlag * 0.95);
    layer(acc, cover, float3(0.8, 0.82, 0.88), smoothstep(0.5, -0.5, abs(px.x - fx) - 0.018 * u) * step(0.15 * u, px.y) * step(px.y, 0.95 * u));
    layer(acc, cover, colorC.rgb, smoothstep(0.5, -0.5, length(px - float2(fx, 0.96 * u)) - 0.04 * u));

    // Behind the car: the long-exposure taillight streak over the whole played part.
    float rearX = -1.97;
    float back = max(rearX - q.x, 0.0);
    float trail = step(q.x, rearX) * (0.25 + 0.75 * exp(-back / 2.5));
    float ty = abs(q.y - 0.31) / (0.012 + 0.004 * back);
    layer(acc, cover, colorA.rgb, trail * exp(-ty * 0.5) * 0.35);
    layer(acc, cover, lerp(colorA.rgb, float3(1, 1, 1), 0.4), trail * smoothstep(1.2, 0.4, ty) * 0.9);

    // Speed lines in the air and tire smoke at the rear wheel, stronger when the song is loud.
    float rh = hash2(float2(floor(q.y / 0.055), 3.0));
    float sl = frac((q.x + time * (9.0 + 8.0 * rh)) * (0.3 + 0.2 * rh) + rh * 7.0);
    float lines = step(0.6, rh) * step(sl, 0.2 + 0.15 * level) * smoothstep(0.5, 0.1, abs(frac(q.y / 0.055) - 0.5)) * step(0.24, q.y);
    layer(acc, cover, lerp(colorB.rgb, float3(1, 1, 1), 0.35), lines * smoothstep(0.3, -0.6, q.x) * exp(-back / 3.0) * (0.25 + 0.5 * level));
    float sm = vnoise(float2(q.x * 6.0 + time * 40.0, q.y * 6.0 - time * 3.0)) * 0.7 + vnoise(float2(q.x * 13.0 + time * 45.0, q.y * 13.0)) * 0.3;
    float sb = max(-1.4 - q.x, 0.0);
    float puff = exp(-sb / 1.1) * smoothstep(-1.3, -1.6, q.x) * smoothstep(0.1 + 0.16 * min(sb, 1.2), 0.0, abs(q.y - 0.14 - 0.1 * min(sb, 1.5)));
    layer(acc, cover, float3(0.85, 0.86, 0.9), puff * smoothstep(0.3, 0.8, sm) * (0.35 + 0.45 * level));

    // The car body bounces on its springs: down on a kick, a buzz with the bass.
    float2 b = q - float2(0.0, -0.035 * beat + 0.012 * bass * sin(time * 40.0));

    // Headlight beam ahead and a soft shadow under the car.
    float hb = max(b.x - 0.2, 0.0);
    float beam = step(0.2, b.x) * exp(-abs(b.y - 0.215 + 0.04 * hb) / (0.02 + 0.09 * hb)) * exp(-hb / 1.6);
    layer(acc, cover, float3(1.0, 0.95, 0.8), beam * (0.5 + 0.2 * level));
    layer(acc, cover, float3(0, 0, 0), exp(-abs(q.y - 0.1) / 0.03) * smoothstep(0.15, 0.0, max(abs(q.x + 0.88) - 1.0, 0.0)) * 0.55);

    // Exhaust flame from the rear: a blue-white core into the second color, flaring on the beat.
    float flen = 0.16 + 0.42 * beat + 0.05 * sin(time * 73.0) + 0.08 * level;
    float ft = (rearX + 0.01 - b.x) / flen;
    float frad = 0.036 * (1.0 - ft * ft) * (1.0 + 0.5 * beat);
    float flame = step(0.0, ft) * step(ft, 1.0) * smoothstep(frad + aa, frad - aa, abs(b.y - 0.2));
    float fglow = exp(-length(float2(max(ft, 0.0) * flen, b.y - 0.2)) / (0.06 + 0.06 * beat)) * step(b.x, rearX + 0.02);
    layer(acc, cover, colorB.rgb, fglow * (0.35 + 0.5 * beat));
    layer(acc, cover, lerp(float3(0.85, 0.95, 1.0), colorB.rgb, saturate(ft * 1.5)), flame);

    // The body: a low wedge with a bubble canopy, a rear wing, and the livery stripe.
    float top = roof(b.x);
    float slope = (roof(b.x + 0.01) - roof(b.x - 0.01)) / 0.02;
    float sill = 0.15 + 0.06 * smoothstep(-0.15, 0.22, b.x);
    float dBody = max(max((b.y - top) / sqrt(1.0 + slope * slope), sill - b.y), max(b.x - 0.22, -1.97 - b.x));
    dBody = max(dBody, -length((b - float2(-1.97, 0.15)) / float2(1.0, 1.4)) + 0.04);   // a rounded lower tail
    float dCanopy = max(ellipse(b - float2(-0.88, 0.3), float2(0.46, 0.18)), 0.29 - b.y);
    float dWing = min(sdSeg(b, float2(-1.99, 0.53), float2(-1.69, 0.535)) - 0.02, sdSeg(b, float2(-1.78, 0.38), float2(-1.82, 0.52)) - 0.016);
    layer(acc, cover, colorA.rgb * 0.15, smoothstep(aa, -aa, min(min(dBody, dCanopy), dWing) - 1.2 * aa));

    float t = saturate((b.y - 0.15) / (top - 0.15));
    float3 body = colorA.rgb * (0.4 + 0.75 * t) + 0.4 * exp(-abs(b.y - top + 0.045) / 0.01);   // with a gloss line on the shoulder
    float band = b.y - lerp(0.255, 0.2, smoothstep(-0.3, 0.2, b.x));                         // the stripe follows the nose down
    body = lerp(body, colorC.rgb * (0.75 + 0.35 * t), smoothstep(aa, -aa, abs(band) - 0.02));
    body = lerp(body, float3(1, 1, 1) * 0.92, smoothstep(aa, -aa, abs(band - 0.033) - 0.006));
    body += float3(1, 1, 1) * 0.5 * smoothstep(-0.022, 0.0, dBody) * step(0.27, b.y);        // lit top edge
    body = lerp(body, colorA.rgb * 0.25, smoothstep(0.19, 0.16, b.y));                       // dark sill
    float wingT = saturate((b.y - 0.5) / 0.05);
    body = lerp(body, colorA.rgb * (0.3 + 0.6 * wingT) + 0.2 * wingT, step(0.45, b.y) * step(dWing, 0.0));
    layer(acc, cover, body, smoothstep(aa, -aa, min(dBody, dWing)));

    // The canopy glass: dark, a reflection gradient, the driver's helmet, and a glint that slides on the beat.
    float g = saturate((b.y - 0.3) / 0.18);
    float3 glass = lerp(float3(0.04, 0.05, 0.1), lerp(colorB.rgb, float3(1, 1, 1), 0.3) * 0.6, g * g);
    float3 helm = lerp(float3(0.95, 0.95, 0.97), float3(0.05, 0.05, 0.08), step(-0.8, b.x - 0.02) * step(abs(b.y - 0.37), 0.022));
    glass = lerp(glass, helm * 0.75, smoothstep(aa, -aa, length(b - float2(-0.8, 0.37)) - 0.07) * 0.85);
    glass += exp(-abs(b.x + 0.72 - 0.5 * (b.y - 0.4) + 0.12 * beat) / 0.018) * 0.8 * step(0.34, b.y);
    layer(acc, cover, colorA.rgb * 0.3, smoothstep(aa, -aa, dCanopy));
    layer(acc, cover, glass, smoothstep(aa, -aa, dCanopy + 0.015));

    // Head and tail lights.
    layer(acc, cover, float3(1, 0.97, 0.85), smoothstep(aa, -aa, ellipse(b - float2(0.1, 0.235), float2(0.065, 0.013))));
    layer(acc, cover, float3(1.0, 0.15, 0.2), exp(-length((b - float2(-1.96, 0.31)) / float2(1.0, 2.0)) / 0.03) * 0.8);

    // Wheels: a dark arch, the tire, and a rim whose five spokes blur into a disc at speed.
    float2 w = q - float2(b.x < -0.9 ? -1.5 : -0.32, 0.23);
    float wr = length(w);
    layer(acc, cover, float3(0.03, 0.03, 0.05), smoothstep(aa, -aa, wr - 0.165) * step(dBody, 0.0));
    float spokes = smoothstep(0.3, 0.7, cos((atan2(w.y, w.x) + time * 30.0) * 5.0));
    float blur = saturate(0.35 + 0.65 * level);
    float3 rim = lerp(float3(0.75, 0.77, 0.82) * (0.45 + 0.55 * lerp(spokes, 0.55, blur)), colorC.rgb, smoothstep(aa, -aa, wr - 0.025));
    rim += 0.25 * exp(-abs(wr - 0.08) / 0.008) * blur;
    float3 tire = float3(0.07, 0.07, 0.08) + 0.08 * smoothstep(0.12, 0.14, wr) * step(0.0, w.y);
    layer(acc, cover, lerp(tire, rim, smoothstep(aa, -aa, wr - 0.095)), smoothstep(aa, -aa, wr - 0.14));

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