190 vec3 s00 = textureGrad(img, uv + ts * vec2(-1.0, -1.0), dFdx(uv), dFdy(uv)).rgb;
191 vec3 s10 = textureGrad(img, uv + ts * vec2(0.0, -1.0), dFdx(uv), dFdy(uv)).rgb;
192 vec3 s20 = textureGrad(img, uv + ts * vec2(1.0, -1.0), dFdx(uv), dFdy(uv)).rgb;
193 vec3 s01 = textureGrad(img, uv + ts * vec2(-1.0, 0.0), dFdx(uv), dFdy(uv)).rgb;
194 vec3 s11 = textureGrad(img, uv, dFdx(uv), dFdy(uv)).rgb;
195 vec3 s21 = textureGrad(img, uv + ts * vec2(1.0, 0.0), dFdx(uv), dFdy(uv)).rgb;
196 vec3 s02 = textureGrad(img, uv + ts * vec2(-1.0, 1.0), dFdx(uv), dFdy(uv)).rgb;
197 vec3 s12 = textureGrad(img, uv + ts * vec2(0.0, 1.0), dFdx(uv), dFdy(uv)).rgb;
198 vec3 s22 = textureGrad(img, uv + ts * vec2(1.0, 1.0), dFdx(uv), dFdy(uv)).rgb;
199 return (s00 + 2.0 * s10 + s20 + 2.0 * s01 + 4.0 * s11 + 2.0 * s21 + s02 + 2.0 * s12 + s22) / 16.0;
265vec3
generate_live_frame(vec2 uv, vec2 res,
float aspect, vec2 m,
float bass,
float mid,
float treble,
float rms,
float peak) {
266 float void_presence = 1.0 - smoothstep(0.0, 0.15, rms);
267 float jam_build = smoothstep(0.05, 0.6, rms);
269 vec2 mapped_uv = uv * 2.0 - 1.0;
270 mapped_uv.x *= aspect;
273 float radius = sqrt(aspect * aspect + 1.0) + 0.5;
274 float glow = smoothstep(radius, radius - (0.5 + bass * 0.3), r);
275 vec2 ar = vec2(aspect, 1.0);
277 float seg = 4.0 + (2.0 + mid * 2.0 * jam_build) * sin(
time_f * 0.33);
278 vec2 kUV =
reflectUV(uv, seg, m, aspect);
281 float foldZoom = 1.15 + (0.2 * void_presence + bass * jam_build * 0.8) * sin(
time_f * (0.42 + jam_build * 0.5));
287 vec2 p = (kUV - m) * ar;
289 if (q.y > q.x) q = q.yx;
293 float tz =
time_f * (0.65 + bass * 0.3 * jam_build);
296 float ang = atan(q.y, q.x) + tz * 0.35 + 0.35 * sin(rD * 18.0 +
time_f * 0.6);
298 float k = fract((log(rD) - tz) / period);
299 float rw = exp(k * period);
301 vec2 pwrap = vec2(cos(ang), sin(ang)) * rw * 0.5;
302 vec2 u0 = fract(pwrap / ar + m);
303 vec2 u1 = fract((pwrap * 1.045) / ar + m);
304 vec2 u2 = fract((pwrap * 0.955) / ar + m);
306 vec2 dir = normalize(pwrap + 1e-6);
307 float chromatic_drift = (0.004 * void_presence * sin(
time_f * 0.4)) + (treble * 0.008 * jam_build);
308 vec2 off = dir * chromatic_drift * vec2(1.0, 1.0 / aspect);
310 float vign = 1.0 - smoothstep(0.75, 1.2, length((uv - m) * ar));
311 vign = mix(0.9, (1.15 + rms * 0.2), vign);
313 vec3 rC =
tentBlur3(samp, u0 + off, res) * 0.7;
314 vec3 gC =
tentBlur3(samp, u1, res) * 0.7;
315 vec3 bC =
tentBlur3(samp, u2 - off, res) * 0.7;
316 vec3 kaleidoRGB = vec3(rC.r, gC.g, bC.b);
318 float ring = smoothstep(0.0, 0.7, sin(log(rD + 1e-3) * 9.5 +
time_f * 1.2));
321 float pulse = 0.5 + (0.5 + rms * 0.3 * jam_build) * sin(
time_f * 2.0 + rD * 28.0 + k * 12.0);
323 vec3 outCol = clamp(kaleidoRGB * (0.6 + 0.4 * pulse) * vign, 0.0, 1.0);
324 vec4 baseTex = texture(samp, uv);
325 vec3 finalRGB = mix(baseTex.rgb * 0.8, outCol,
pingPong(glow *
PI, 5.0) * (0.5 + 0.5 * jam_build));
327 finalRGB = mix(finalRGB, finalRGB * vec3(0.7, 0.8, 1.2), void_presence);
328 finalRGB *= 1.0 + (peak * 1.5 * jam_build) + (void_presence * 0.2);
330 vec3 eqColor = vec3(1.0 + bass * 0.4, 1.0 - bass * 0.2, 1.0 + clamp(treble, 0.0, 1.0) * 0.4);
331 finalRGB = mix(finalRGB, finalRGB * eqColor, peak * jam_build);
341 float aspect = res.x / res.y;
342 vec2 m = (
iMouse.z > 0.0) ? (
iMouse.xy / res) : vec2(0.5);
345 float bass = texture(spectrum0, 0.05).r;
346 float mid = texture(spectrum0, 0.25).r;
347 float treble = texture(spectrum0, 0.70).r;
349 float rms = (bass + mid + treble) / 3.0;
350 float peak = max(bass, max(mid, treble));
356 vec3 trail_accum = vec3(0.0);
357 float trail_weight = 0.0;
359 for (
int index = 0; index <
SIZE; ++index) {
366 float progress = float(index) / float(max(
SIZE - 1, 1));
367 float weight = exp(-progress * 3.5);
369 vec3 trail_tint = mix(vec3(1.0),
palette(
time_f * 0.2 + progress + old_bass), progress * 0.8);
371 trail_accum += (cached * trail_tint) * weight;
372 trail_weight += weight;
375 vec3 trail = trail_accum / max(trail_weight, 0.001);
379 vec3 result = live + trail - (live * trail);
382 result = (result - 0.5) * (1.1 + rms * 0.2) + 0.5;
383 result = mix(result, vec3(1.0) - result, smoothstep(0.9, 1.0, peak));
385 color = vec4(clamp(result, 0.0, 1.0), texture(samp, tc).a);
vec3 generate_live_frame(vec2 uv, vec2 res, float aspect, vec2 m, float bass, float mid, float treble, float rms, float peak)
Evaluates generate live frame for this shader effect.