Event Horizon
của MusicBar, visualizer
Hố đen nằm giữa thanh trong một đĩa khí mỏng rực lửa, phía sau đĩa bị bẻ cong vòng qua trên và dưới bóng đen, một bên sáng hơn vì đang quay về phía mình, bass càng mạnh đĩa càng bùng sáng.
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 9a4d91cec45481b9b0549352cec2bdb2b9df42093ae317782e79cfd6ec0a4587
//! name: Event Horizon
//! author: MusicBar
//! kind: visualizer
//! description: A black hole sits in the middle of the bar inside a thin, glowing accretion disk whose far side bends over and under the shadow, one side brighter as it swings toward you, flaring with the bass.
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); }
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);
}
// 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);
}
// Gas temperature to color: deep second color, main color, then the accent and white at the hottest.
float3 hot(float t)
{
float3 c = lerp(colorB.rgb * 0.7, colorA.rgb, smoothstep(0.05, 0.4, t));
c = lerp(c, colorC.rgb, smoothstep(0.45, 0.85, t));
return lerp(c, float3(1, 1, 1), smoothstep(0.85, 1.15, t));
}
// The disk seen from a hair above its plane: s is a point on the screen (in bar heights from the hole) as the
// light left it. Returns brightness in .x and temperature in .y. ci squashes the disk into a thin ellipse.
float2 disk(float2 s, float ci, float rIn, float rOut, float bass, float spin, float detail)
{
float2 q = float2(s.x, s.y / ci);
float r = length(q);
float ang = atan2(q.y, q.x);
// Inner gas orbits much faster than outer gas, so clumps shear into spiral streaks (smoothed where the
// lens squeezes a lot of disk into a few pixels).
float orbit = ang + spin * pow(max(r, rIn), -1.5);
float streak = vnoise(float2(r * 2.5, orbit * 1.5)) * 0.6 + vnoise(float2(r * 7.0, orbit * 2.5 + 3.0)) * 0.4;
streak = lerp(0.55, streak, detail);
float edge = smoothstep(rIn * 0.92, rIn * 1.12, r) * smoothstep(rOut, rOut * 0.4, r);
float prof = pow(rIn / max(r, rIn), 0.6) * edge * exp(-abs(s.y) / 0.1);
// The spectrum runs out along the disk, bass at the inner edge, and a shock ring races outward on the beat.
float sp = spectrum(saturate((r - rIn) / (rOut * 0.8)));
float shock = exp(-abs(r - rIn - (1.0 - beat) * rOut * 0.5) / (0.3 + 0.4 * (1.0 - beat))) * beat;
// The side swinging toward us is beamed brighter and hotter, the side going away dims and reddens.
float toward = -q.x / max(r, 0.001);
float beam = pow(saturate(1.0 + 0.45 * toward), 3.0) + 0.08;
float b = prof * (0.35 + 0.8 * streak) * beam * (0.45 + 1.3 * sp + 0.5 * bass) + shock * edge * (0.3 + beam) * exp(-abs(s.y) / 0.1);
float t = saturate(0.75 * pow(rIn / max(r, rIn), 0.5) + 0.25 * toward + 0.2 * sp + 0.15 * streak + 0.4 * shock);
return float2(b, t);
}
float4 main(float2 uv : TEXCOORD) : COLOR
{
float u = size.y;
float2 px = float2(uv.x * size.x, rise(uv) * size.y);
float2 p = (px - float2(0.5 * size.x, 0.5 * u)) / u; // bar heights from the hole, y up from the edge
float aa = 1.0 / u;
float bass = spectrum(0.04);
float3 acc = float3(0, 0, 0);
float cover = 0;
float Rs = 0.19; // the shadow
float rE = 0.3 + 0.015 * beat; // ring where the far side of the disk is lensed
float ci = 0.05; // how nearly edge-on we see the disk
float rIn = 0.5, rOut = 0.5 * size.x / u;
float spin = time * 0.9;
float rr = length(p);
// Light from behind is bent around the hole: a point lens maps each pixel back to where its light started.
float2 src = p - p * rE * rE / max(rr * rr, 0.0001);
// A pocket of dark space around the hole and along the disk, so the glow still reads on a light taskbar.
float dark = 0.6 * exp(-length(p * float2(0.45, 1.0)) / 0.4) + 0.3 * exp(-abs(p.y) / 0.13) * exp(-abs(p.x) / (0.3 * rOut));
layer(acc, cover, float3(0.01, 0.005, 0.01), dark);
// Faint stars, smeared into arcs near the hole by the same bending.
float2 sc = floor(src * 9.0);
float2 sf = frac(src * 9.0) - 0.5 - 0.3 * (float2(hash2(sc), hash2(sc + 7.1)) - 0.5);
float star = step(0.9, hash2(sc + 3.3)) * smoothstep(0.08, 0.0, length(sf)) * smoothstep(Rs, Rs + 0.06, rr);
layer(acc, cover, lerp(colorC.rgb, float3(1, 1, 1), 0.6), star * 0.5 * (0.6 + 0.4 * sin(time * 2.0 + sc.x)));
// The lensed image: the far side of the disk arched over the top and wrapped under the bottom of the shadow.
float2 L = disk(src, ci, rIn, rOut, bass, spin, smoothstep(0.45, 1.1, rr));
float lensed = L.x * smoothstep(Rs, Rs + 0.025, rr);
layer(acc, cover, hot(L.y), saturate(lensed * 1.3));
// Photon ring: a hairline of light circling the shadow's edge, flaring on the beat.
float ring = exp(-abs(rr - Rs - 0.012) / (0.008 + 0.01 * beat));
float ringBeam = pow(saturate(1.0 - 0.45 * p.x / max(rr, 0.001)), 2.0);
layer(acc, cover, lerp(hot(0.85), float3(1, 1, 1), 0.5 * beat), ring * ringBeam * (0.55 + 0.6 * bass + 1.2 * beat));
// The shadow itself: nothing comes out of it.
layer(acc, cover, float3(0, 0, 0), smoothstep(aa, -aa, rr - Rs));
// The near side of the disk passes in front of the shadow, unbent, as a thin bright band below center.
float2 N = disk(p, ci, rIn, rOut, bass, spin, 0.5);
float near = step(p.y, 0.0) * N.x * smoothstep(rE * 1.6, rE * 0.9, rr);
layer(acc, cover, hot(N.y), saturate(near * 1.4));
// A soft glow of hot gas around the whole disk, and a flare of light from the center on the beat.
float glow = exp(-abs(p.y) / (0.06 + 0.04 * level)) * exp(-abs(p.x) / (2.0 + 2.0 * level)) * (0.25 + 0.35 * bass);
layer(acc, cover, colorA.rgb, glow * smoothstep(Rs, Rs + 0.1, rr) * 0.6);
float flare = exp(-length(p * float2(0.35, 1.6)) / 0.25) * beat;
layer(acc, cover, lerp(colorC.rgb, float3(1, 1, 1), 0.4), flare * 0.35 * smoothstep(Rs, Rs + 0.05, rr));
return paint(acc / max(cover, 0.001), cover);
}