7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
13 vec4 custom_uniforms[16];
17#define amp_high ext.audio_bands.z
18#define amp_low ext.audio_bands.x
19#define amp_mid ext.audio_bands.y
20#define amp_peak ext.u2.w
21#define amp_smooth ext.u3.w
22#define history_head int(ext.u3.x)
23#define iMouse ext.mouse
24#define iResolution ext.u0.zw
25#define spectrum_history_head int(ext.audio_history.x)
26#define spectrum_history_size int(ext.audio_history.y)
27#define time_f ext.u2.y
32layout(location = 0) out vec4 color;
33layout(set = 0, binding = 0) uniform sampler2D samp;
34layout(set = 0, binding = 2) uniform sampler2DArray history;
39#ifndef CACHE_HISTORY_LAYER
40#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
42layout(set = 0, binding = 3) uniform sampler1D spectrum0;
43layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
46#ifndef SPECTRUM_HISTORY_LAYER
47#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
58const float TAU = 6.28318530718;
68 return mat2(c, -s, s, c);
77 return 1.0 - abs(mod(point, 2.0) - 1.0);
86 return 0.5 + 0.5 * cos(
TAU * (phase + vec3(0.20, 0.52, 0.86)));
107 int age = min(index + 1, max_age);
120vec2
hypercube_fold(vec2 uv, vec2 center,
float depth,
float bass,
float middle) {
121 vec2 point = (uv - center) * (2.0 + depth * 1.5);
123 point = abs(point) - vec2(0.55 + bass * 0.18);
124 point = abs(point.yx) - vec2(0.26 + middle * 0.12);
125 float w = sin((point.x - point.y) * 5.0 +
time_f + depth *
TAU);
126 point /= 1.0 + depth * 0.7 + w * 0.12;
127 return point * 0.5 + center;
135 vec2 center =
iMouse.z > 0.0 ?
iMouse.xy / resolution : vec2(0.5);
136 vec4 live = texture(samp, tc);
137 vec3 accumulated = live.rgb * 0.8;
138 float total_weight = 0.8;
140 for (
int index = 0; index <
SIZE; ++index) {
141 float depth = float(index) / float(max(
SIZE - 1, 1));
145 float frame = 1.0 - smoothstep(0.0, 0.03, abs(max(abs(uv.x - center.x), abs(uv.y - center.y)) - 0.22));
146 float weight = mix(0.1, 0.54, depth) + frame * 0.2;
148 accumulated += mix(cached, cached *
palette(depth + middle), 0.72) * weight;
149 total_weight += weight;
152 vec3 result = accumulated / total_weight;
153 result = mix(result, result.bgr,
amp_peak * 0.35);
154 result = (result - 0.5) * (1.12 +
amp_smooth * 0.2) + 0.5;
155 color = vec4(clamp(result, 0.0, 1.0), live.a);
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
#define CACHE_HISTORY_LAYER(index)
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.
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
vec2 hypercube_fold(vec2 uv, vec2 center, float depth, float bass, float middle)
Evaluates hypercube fold for this shader effect.