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.18, 0.47, 0.76)));
96 int age = min(index + 1, max_age);
109 vec2 grid = uv * (8.0 + middle * 5.0);
111 flow.x = sin(grid.y +
time_f * 1.3 + sin(grid.x * 0.7));
112 flow.y = cos(grid.x -
time_f * 1.1 + cos(grid.y * 0.8));
113 uv += flow * depth * (0.008 + bass * 0.035);
114 uv = (uv - 0.5) / (1.0 + depth * (0.18 + bass * 0.6)) + 0.5;
122 vec4 live = texture(samp, tc);
123 vec3 accumulated = live.rgb;
124 float total_weight = 1.0;
126 for (
int index = 0; index <
SIZE; ++index) {
127 float depth = float(index) / float(max(
SIZE - 1, 1));
131 vec2 grid = abs(fract(uv * 9.0) - 0.5);
132 float lattice = 1.0 - smoothstep(0.02, 0.12, min(grid.x, grid.y));
133 float weight = mix(0.09, 0.56, depth) * (0.72 +
lattice * 0.38);
135 accumulated += mix(cached, cached *
palette(depth + middle), 0.6) * weight;
136 total_weight += weight;
139 vec3 result = accumulated / total_weight;
140 result = mix(result, result.bgr,
amp_peak * 0.22);
141 result = (result - 0.5) * (1.06 +
amp_smooth * 0.26) + 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
float lattice(vec2 point, float bass, float middle, float high)
Evaluates lattice for this shader effect.
vec2 liquid_warp(vec2 uv, float depth, float bass, float middle)
Evaluates liquid warp for this shader effect.