252vec4
soft_sample(sampler2D image, vec2 uv, vec2 texel,
float spread) {
254 result += texture(image,
mirror_repeat(uv + vec2(texel.x, 0.0) * spread)) * 2.0;
255 result += texture(image,
mirror_repeat(uv - vec2(texel.x, 0.0) * spread)) * 2.0;
256 result += texture(image,
mirror_repeat(uv + vec2(0.0, texel.y) * spread)) * 2.0;
257 result += texture(image,
mirror_repeat(uv - vec2(0.0, texel.y) * spread)) * 2.0;
258 result += texture(image,
mirror_repeat(uv + texel * spread));
259 result += texture(image,
mirror_repeat(uv - texel * spread));
260 result += texture(image,
mirror_repeat(uv + vec2(texel.x, -texel.y) * spread));
261 result += texture(image,
mirror_repeat(uv + vec2(-texel.x, texel.y) * spread));
262 return result / 16.0;
273float effect_field(vec2 point,
float bass,
float middle,
float treble) {
274 float radius = length(point) + 0.0001;
275 float angle = atan(point.y, point.x);
278 vec4 geo_4d = vec4(point.x, point.y, bass - middle, treble + sin(
time_f * 0.2));
286 float crown = pow(abs(cos(angle * (13.0 + floor(treble * 7.0)) +
time_f + geo_4d.w * 5.0)), 12.0);
287 float ring = sin(radius * (37.0 + bass * 24.0) -
time_f * 9.0 + geo_4d.z * 10.0);
289 float field = crown * exp(-radius * 1.7) * 0.72 + ring * 0.32;
290 return field + (
fbm(vec2(geo_4d.x, geo_4d.y) * 3.1 - vec2(0.0,
time_f * 0.12)) - 0.5) * 0.12;
333 vec2 texel = 1.0 / resolution;
334 float aspect = resolution.x / resolution.y;
335 vec2 mouse_uv =
iMouse.xy / resolution;
336 vec2 center =
iMouse.z > 0.0 ? mouse_uv : vec2(0.5);
337 vec2 point = (tc - center) * vec2(aspect, 1.0);
339 float bass = texture(spectrum0, 0.03).r;
340 float middle = texture(spectrum0, 0.22).r;
341 float treble = texture(spectrum0, 0.58).r;
342 float air = texture(spectrum0, 0.82).r;
346 float pixel = 2.0 / max(max(resolution.x, resolution.y), 360.0);
347 vec2 gradient = vec2(
effect_field(point + vec2(pixel, 0.0), bass, middle, treble) -
field,
350 vec3 surface_normal = normalize(vec3(-gradient * (0.16 +
amp_high * 0.05), 1.0));
352 float ripple = sin(point.x * 10.0 +
time_f * (4.0 + bass * 3.0));
353 ripple += sin(point.y * 11.0 +
time_f * (3.5 + middle * 2.0));
354 vec2 radial = normalize(point + vec2(0.001));
356 vec2 ripple_uv = tc + radial *
ripple * (0.009 + bass * 0.018);
359 vec3 sharp = texture(samp, live_uv).rgb;
360 vec3 softened =
soft_sample(samp, live_uv, texel, 1.0 + middle * 3.0).rgb;
361 float dispersion = 0.003 + treble * 0.014;
362 vec3 refracted = vec3(texture(samp,
mirror_repeat(live_uv + surface_normal.xy * dispersion)).r,
364 texture(samp,
mirror_repeat(live_uv - surface_normal.xy * dispersion)).b);
365 vec3 live = mix(sharp, refracted, 0.48 +
amp_smooth * 0.15);
367 float luminance = dot(live, vec3(0.299, 0.587, 0.114));
371 vec4 color_4d = vec4(
field, bass, middle,
time_f * 0.1);
374 vec3 mapped = 0.5 + 0.5 * cos(clamp(live, 0.0, 1.0) *
PI * 0.5 +
375 palette(color_4d.x + color_4d.w));
377 vec3 accumulated = mix(live, mapped * (0.45 +
luminance), 0.44);
379 pow(max(0.0, 1.0 - surface_normal.z), 2.0) * 0.7;
380 float total_weight = 1.0;
382 for (
int index = 0; index < 8; ++index) {
383 float age = float(index + 1);
389 vec2 history_uv =
cache_transform_4d(tc, center, age, old_bass, old_middle, old_treble, surface_normal.xy);
391 vec3 history_color =
sample_cache(index, history_uv).rgb;
392 float old_energy = old_bass * 0.5 + old_middle * 0.3 + old_treble * 0.2;
395 vec3 history_tint =
palette(color_4d.z * 0.12 + age * 0.061 + old_energy * 0.7);
397 float weight = pow(0.76, age);
398 accumulated += mix(history_color, history_color * history_tint, 0.62) * weight;
399 total_weight += weight;
402 accumulated /= total_weight;
403 float crest = pow(max(sin(
field * 19.0 -
time_f * 2.4), 0.0), 7.0);
405 accumulated = (accumulated - 0.5) * (1.08 +
amp_smooth * 0.28) + 0.5;
406 accumulated = mix(accumulated, vec3(1.0) - accumulated, smoothstep(0.91, 1.0,
amp_peak));
408 color = vec4(
tone_map(accumulated), texture(samp, live_uv).a);