激光扇
从舞台下方扇形扫起的激光,底鼓时变粗。
GLSL 源码
// A laser fan from the bottom centre of the stage. Sweeps left and right once every 8 beats and thickens on each kick.
vec2 prim(vec2 uv) {
vec2 p = vec2((uv.x - 0.5) * uResolution.x / uResolution.y, uv.y);
float beams = floor(uParams.x);
float sweep = sin(uBeat * TAU / 8.0) * uParams.y;
float ang = atan(p.x, p.y);
float dist = length(p);
float l = 0.0;
for (int i = 0; i < 24; i++) {
if (float(i) >= beams) break;
float g = (float(i) - (beams - 1.0) * 0.5) * 0.13 + sweep;
float w = 0.0025 + uKick * 0.006;
l += smoothstep(w, 0.0, abs(ang - g) * dist);
}
l = min(l, 1.0) * smoothstep(0.0, 0.08, dist);
return vec2(l, l);
}
一个使用通用 uniform 约定(uBeat · uBass · uKick …)的 vec2 prim(vec2 uv) 函数,只输出 luma 与 alpha。