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;
66 return 1.0 - abs(mod(point, 2.0) - 1.0);
75 return 0.5 + 0.5 * cos(
TAU * (phase + vec3(0.01, 0.35, 0.69)));
96 int age = min(index + 1, max_age);
108vec2
phase_warp(vec2 uv,
float depth,
float bass,
float high) {
109 vec2 point = uv - 0.5;
110 float phase_x = sin(point.y * 14.0 +
time_f * 1.3 + depth *
TAU);
111 float phase_y = cos(point.x * 11.0 -
time_f * 0.9 - depth * 4.0);
112 point.x += phase_x * depth * (0.012 + bass * 0.055);
113 point.y += phase_y * depth * (0.012 + high * 0.045);
114 float shear = sin(
time_f * 0.37 + depth *
TAU) * (0.08 + high * 0.2);
115 point = mat2(1.0, shear, -shear, 1.0) * point;
116 return point / (1.0 + depth * 0.2) + 0.5;
123 vec4 live = texture(samp, tc);
124 vec3 accumulated = live.rgb;
125 float total_weight = 1.0;
127 for (
int index = 0; index <
SIZE; ++index) {
128 float depth = float(index) / float(max(
SIZE - 1, 1));
132 float grid = 0.5 + 0.5 * sin(uv.x * 25.0 +
time_f) * cos(uv.y * 21.0 -
time_f);
133 float weight = mix(0.08, 0.55, depth) * mix(0.65, 1.1, grid);
135 accumulated += mix(cached, cached.gbr *
palette(depth + high), 0.52) * weight;
136 total_weight += weight;
139 vec3 result = accumulated / total_weight;
140 result = mix(result, vec3(1.0) - result,
amp_peak * step(0.7, fract(
time_f * 5.0)) * 0.28);
141 result = (result - 0.5) * (1.1 +
amp_smooth * 0.25) + 0.5;
142 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)
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 phase_warp(vec2 uv, float depth, float bass, float high)
Evaluates phase warp for this shader effect.