7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
13 vec4 custom_uniforms[16];
17#define amp_peak ext.u2.w
18#define amp_smooth ext.u3.w
19#define history_head int(ext.u3.x)
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
27layout(location = 0) out vec4 color;
28layout(set = 0, binding = 0) uniform sampler2D samp;
29layout(set = 0, binding = 2) uniform sampler2DArray history;
34#ifndef CACHE_HISTORY_LAYER
35#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
37layout(set = 0, binding = 3) uniform sampler1D spectrum0;
38layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
41#ifndef SPECTRUM_HISTORY_LAYER
42#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
48const float TAU = 6.28318530718;
55vec2
mirror_repeat(vec2 point) {
return 1.0 - abs(mod(point, 2.0) - 1.0); }
61float hash_21(vec2 point) {
return fract(sin(dot(point, vec2(127.1, 311.7))) * 43758.5453123); }
67vec3
palette(
float phase) {
return 0.5 + 0.5 * cos(
TAU * (phase + vec3(0.06, 0.41, 0.78))); }
83 int age = min(index + 1, maximum_age);
94 vec2 grid = point * scale;
95 vec2
cell = floor(grid);
96 vec2 local = fract(grid) - 0.5;
98 for (
int y = -1; y <= 1; ++y) {
99 for (
int x = -1; x <= 1; ++x) {
100 vec2 offset = vec2(
float(x),
float(y));
103 nearest = min(nearest, length(local - offset -
seed));
114 vec2 aspect = vec2(resolution.x / resolution.y, 1.0);
115 vec2 point = (tc - 0.5) * aspect;
116 float bass = texture(spectrum0, 0.04).r;
117 float middle = texture(spectrum0, 0.27).r;
118 float high = texture(spectrum0, 0.73).r;
120 float web = exp(-abs(
cells - 0.43) * (38.0 + high * 20.0));
121 vec2
warp = vec2(sin(point.y * 23.0 +
time_f * 4.0), cos(point.x * 21.0 -
time_f * 3.0)) * web * (0.025 + bass * 0.04);
126 vec3 accumulated = live;
127 float total_weight = 1.0;
128 for (
int index = 0; index <
SIZE; ++index) {
129 float generation = float(index + 1);
130 float age = generation / float(max(
SIZE, 1));
132 vec2 cache_point = point * (1.0 - age * (0.055 + old_audio.x * 0.075));
133 cache_point += vec2(sin(cache_point.y * 14.0 + generation), cos(cache_point.x * 13.0 - generation)) * old_audio.z * age * 0.035;
134 vec3 memory =
sample_cache(index, cache_point / aspect + 0.5);
135 float old_web = exp(-abs(
ion_cells(cache_point + age * 0.11, 7.0 + old_audio.y * 4.0) - 0.43) * 30.0);
136 memory *= mix(vec3(0.65),
palette(age + old_audio.y), 0.55 + old_web * 0.35);
137 float weight = pow(0.79, generation) * (0.8 + old_web * 0.6);
138 accumulated += memory * weight;
139 total_weight += weight;
141 vec3 result = accumulated / total_weight;
143 result = (result - 0.5) * (1.27 +
amp_smooth * 0.28) + 0.5;
144 color = vec4(clamp(result, 0.0, 1.0), 1.0);
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
#define CACHE_HISTORY_LAYER(index)
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.
#define spectrum_history_size
shared uint cells[10][10]
vec2 warp(vec2 p, vec2 o, float k)
Evaluates warp for this shader effect.
float history_fft(int index, float frequency)
Evaluates history fft for this shader effect.
vec2 cell(vec2 p)
Evaluates cell for this shader effect.
float ion_cells(vec2 point, float scale)
Evaluates ion cells for this shader effect.