3layout(set = 0, binding = 1, std140) uniform SpriteExtended {
9 vec4 custom_uniforms[16];
13#define amp_high ext.audio_bands.z
14#define amp_low ext.audio_bands.x
15#define amp_mid ext.audio_bands.y
16#define amp_peak ext.u2.w
17#define amp_smooth ext.u3.w
18#define history_head int(ext.u3.x)
19#define iMouse ext.mouse
20#define iResolution ext.u0.zw
21#define spectrum_history_head int(ext.audio_history.x)
22#define spectrum_history_size int(ext.audio_history.y)
23#define time_f ext.u2.y
33layout(location = 0) out vec4 color;
34layout(set = 0, binding = 0) uniform sampler2D samp;
35layout(set = 0, binding = 2) uniform sampler2DArray history;
40#ifndef CACHE_HISTORY_LAYER
41#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
43layout(set = 0, binding = 3) uniform sampler1D spectrum0;
44layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
47#ifndef SPECTRUM_HISTORY_LAYER
48#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
59const float PI = 3.14159265359;
60const float TAU = 6.28318530718;
68 float cosine = cos(angle);
69 float sine = sin(angle);
70 return mat2(cosine, -sine, sine, cosine);
79 return 1.0 - abs(mod(point, 2.0) - 1.0);
88 return fract(sin(dot(point, vec2(127.1, 311.7))) * 43758.5453123);
97 vec2
cell = floor(point);
98 vec2 part = fract(point);
99 part = part * part * (3.0 - 2.0 * part);
102 return mix(lower, upper, part.y);
113 for (
int octave = 0; octave < 4; ++octave) {
115 point =
rotate_2d(0.73) * point * 2.03 + vec2(1.7, 0.9);
127 vec2 scale = vec2(1.0, 1.7320508);
128 vec2 first = mod(point, scale) - scale * 0.5;
129 vec2 second = mod(point - scale * 0.5, scale) - scale * 0.5;
130 return dot(first, first) < dot(second, second) ? first : second;
140 float radius = length(point);
141 float sector =
TAU / max(sides, 2.0);
142 float angle = abs(mod(atan(point.y, point.x) + sector * 0.5, sector) - sector * 0.5);
143 return vec2(cos(angle), sin(angle)) * radius;
154 point = abs(point) / max(dot(point, point), 0.18) - 0.72;
155 point =
rotate_2d(0.37 + phase * 0.03 +
float(
fold) * 0.11) * point;
166 vec2 base = floor(point);
167 vec2 part = fract(point);
168 vec2 nearest = vec2(0.0);
169 float nearest_distance = 8.0;
170 for (
int y = -1; y <= 1; ++y) {
171 for (
int x = -1; x <= 1; ++x) {
172 vec2 neighbor = vec2(
float(x),
float(y));
173 vec2 random_point = vec2(
hash_21(base + neighbor),
174 hash_21(base + neighbor + 17.31));
175 random_point = 0.5 + 0.42 * sin(
time_f * 0.31 +
TAU * random_point);
176 vec2 difference = neighbor + random_point - part;
177 float distance_squared = dot(difference, difference);
178 if (distance_squared < nearest_distance) {
179 nearest_distance = distance_squared;
180 nearest = difference;
194 vec3 offset = vec3(0.03, 0.34, 0.67) +
195 identity * vec3(0.037, 0.053, 0.071);
196 vec3
frequency = vec3(1.0, 1.13 + mod(identity, 3.0) * 0.09,
197 0.83 + mod(identity, 5.0) * 0.07);
198 return 0.5 + 0.5 * cos(
TAU * (phase *
frequency + offset));
207 value = max(value, 0.0);
208 return clamp((value * (2.51 * value + 0.03)) /
209 (value * (2.43 * value + 0.59) + 0.14),
229 return texture(history,
240 return texture(spectrum_history,
255vec3
psyche_field(vec2 point,
float bass,
float middle,
float treble,
float age) {
256 float radius = length(point) + 0.0001;
257 float angle = atan(point.y, point.x);
261 6.0 + floor(treble * 5.0));
262 float film = sin(log(length(
crystal) + 0.06) * 17.0 - time * 3.0 + age * 13.0);
263 float edge = pow(abs(cos(atan(
crystal.y,
crystal.x) * 7.0)), 8.0);
264 return vec3(
film, edge * exp(-radius * 1.5),
film * 0.16 + radius + age);
267vec2
psyche_warp(vec2 uv, vec2 point, vec3 signal,
float bass,
float middle,
268 float treble,
float age) {
269 float radius = length(point) + 0.001;
270 float angle = atan(point.y, point.x);
271 vec2 radial = point / radius;
272 vec2 tangent = vec2(-radial.y, radial.x);
273 float depth = 0.25 + age * 0.75;
275 vec2 folded =
kaleidoscope(point, 6.0 + floor(treble * 5.0));
277 uv += tangent * signal.x * 0.025 * depth;
290float layer_gate(vec2 point, vec3 signal,
float progress,
int index) {
291 float radius = length(point) + 0.0001;
292 float angle = atan(point.y, point.x);
293 float slot = float(index);
295 return 0.22 + 0.78 * pow(abs(cos(angle * (3.0 + slot) + progress *
PI)), 7.0);
298vec3
memory_blend(vec3 live_color, vec3 memory, vec3 previous,
int index,
305 return mix(memory, 1.0 - (1.0 - memory) * (1.0 - live_color),
309 return mix(memory, abs(memory - live_color) * 1.35, 0.3 +
energy * 0.35);
312 return memory * (0.7 + live_color * 0.65);
315 vec3 shifted = (index % 3 == 0) ? memory.gbr :
316 ((index % 3 == 1) ? memory.brg : memory.rgb);
317 return mix(memory, shifted, 0.35 +
energy * 0.3);
319 return mix(memory, abs(memory - previous) + memory * 0.55,
328 float aspect = resolution.x / resolution.y;
329 vec2 center =
iMouse.z > 0.0 ?
iMouse.xy / resolution : vec2(0.5);
330 vec2 point = (tc - center) * vec2(aspect, 1.0);
332 float bass = max(texture(spectrum0, 0.035).r,
amp_low);
333 float middle = max(texture(spectrum0, 0.24).r,
amp_mid);
334 float treble = max(texture(spectrum0, 0.63).r,
amp_high);
336 vec3 live_signal =
psyche_field(point, bass, middle, treble, 0.0);
337 vec2 live_uv =
psyche_warp(tc, point, live_signal, bass, middle, treble, 0.0);
338 float chroma = 0.002 + treble * 0.018 + abs(live_signal.x) * 0.004;
339 vec2 chroma_direction = vec2(cos(live_signal.z *
TAU), sin(live_signal.z *
TAU));
342 live_color.r =
sample_live(live_uv + chroma_direction * chroma).r;
344 live_color.b =
sample_live(live_uv - chroma_direction * chroma).b;
348 vec3 accumulated = live_color * 1.25;
349 float total_weight = 1.25;
350 vec3 previous = live_color;
352 for (
int index = 0; index <
SIZE; ++index) {
353 float progress = float(index + 1) / float(max(
SIZE, 1));
358 fract(0.08 + progress * 0.79));
360 vec3 signal =
psyche_field(point, old_bass, old_middle, old_treble,
362 vec2 history_uv =
psyche_warp(tc, point, signal, old_bass, old_middle,
363 old_treble, progress);
366 vec3 tint =
palette(signal.z + progress * 0.63 +
367 frequency_trace * 0.71);
368 float saturation = 0.45 + old_middle * 0.55 + signal.y * 0.2;
369 memory = mix(vec3(dot(memory, vec3(0.299, 0.587, 0.114))), memory,
371 memory *= 0.68 + tint * (0.46 + old_treble * 0.34);
372 memory += tint * signal.y * (0.08 + frequency_trace * 0.2);
373 memory =
memory_blend(live_color, memory, previous, index,
374 old_bass + old_treble);
376 float gate =
layer_gate(point, signal, progress, index);
377 float decay = 2.0 + float(
PSYCHE_ID % 7) * 0.17;
378 float weight = exp(-progress * decay) * gate *
379 (0.72 + frequency_trace * 0.5);
380 accumulated += memory * weight;
381 total_weight += weight;
385 vec3 result = accumulated / max(total_weight, 0.001);
386 result = (result - 0.5) * (1.08 +
amp_smooth * 0.32) + 0.5;
389 float peak = smoothstep(0.84, 1.0,
amp_peak);
390 if (peak_mode == 0) {
391 result = mix(result, 1.0 - result, peak * 0.85);
392 }
else if (peak_mode == 1) {
393 result +=
palette(live_signal.z + 0.5) * peak * 0.28;
394 }
else if (peak_mode == 2) {
395 result = mix(result, result.brg, peak * 0.72);
397 result = mix(result, result * result * (3.0 - 2.0 * result),
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
vec2 kaleidoscope(vec2 point, float sides)
Evaluates kaleidoscope for this shader effect.
float fbm(vec2 point)
Evaluates fbm for this shader effect.
#define CACHE_HISTORY_LAYER(index)
float value_noise(vec2 point)
Evaluates value noise for this shader effect.
vec2 hex_cell(vec2 point)
Evaluates hex cell for this shader effect.
mat2 rotate_2d(float angle)
Evaluates rotate 2d for this shader effect.
float sample_history(int index, float frequency)
Evaluates sample history for this shader effect.
float hash_21(vec2 point)
Evaluates hash 21 for this shader effect.
vec3 palette(float phase)
Evaluates palette for this shader effect.
#define SPECTRUM_HISTORY_LAYER(index)
vec2 mirror_repeat(vec2 point)
Evaluates mirror repeat for this shader effect.
vec4 sample_cache(int index, vec2 uv)
Evaluates sample cache for this shader effect.
vec3 tone_map(vec3 value)
Evaluates tone map for this shader effect.
vec3 saturation(vec3 color, float amount)
Evaluates saturation for this shader effect.
float energy()
Evaluates energy for this shader effect.
vec3 crystal(float t)
Evaluates crystal for this shader effect.
vec3 film(float x, float v)
Evaluates film for this shader effect.
vec2 cell(vec2 p)
Evaluates cell for this shader effect.
vec4 sample_live(vec2 uv)
Evaluates sample live for this shader effect.
vec2 fold(vec2 uv, float zoom, float t, vec2 c, float aspect)
Evaluates fold for this shader effect.
vec3 psyche_field(vec2 point, float bass, float middle, float treble, float age)
Evaluates psyche field for this shader effect.
vec3 memory_blend(vec3 live_color, vec3 memory, vec3 previous, int index, float energy)
vec2 voronoi_cell(vec2 point)
Evaluates voronoi cell for this shader effect.
vec2 recursive_fold(vec2 point, float phase)
Evaluates recursive fold for this shader effect.
vec2 psyche_warp(vec2 uv, vec2 point, vec3 signal, float bass, float middle, float treble, float age)
float layer_gate(vec2 point, vec3 signal, float progress, int index)
Evaluates layer gate for this shader effect.