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.10, 0.43, 0.77)));
96 int age = min(index + 1, max_age);
109vec2
petal_warp(vec2 uv, vec2 center,
float depth,
float bass,
float middle) {
110 vec2 point = uv - center;
111 float radius = length(point);
112 float angle = atan(point.y, point.x);
113 float petals = 5.0 + floor(middle * 4.0);
114 angle = abs(mod(angle + 3.14159265 / petals,
TAU / petals) - 3.14159265 / petals);
115 radius *= 1.0 + cos(angle * petals) * (0.16 + bass * 0.28);
116 angle += depth * (0.45 + middle) * sin(
time_f * 0.5);
117 radius /= 1.0 + depth * (0.32 + bass * 0.8);
118 return vec2(cos(angle), sin(angle)) * radius + center;
126 vec2 center =
iMouse.z > 0.0 ?
iMouse.xy / resolution : vec2(0.5);
127 vec4 live = texture(samp, tc);
128 vec3 accumulated = live.rgb;
129 float total_weight = 1.0;
131 for (
int index = 0; index <
SIZE; ++index) {
132 float depth = float(index) / float(max(
SIZE - 1, 1));
135 vec2 uv =
petal_warp(tc, center, depth, bass, middle);
136 float angle = atan(tc.y - center.y, tc.x - center.x);
137 float petal = pow(abs(cos(angle * 5.0)), 5.0);
138 float weight = mix(0.1, 0.55, depth) * (0.72 + petal * 0.4);
140 accumulated += mix(cached, cached.gbr *
palette(depth + middle), 0.48) * weight;
141 total_weight += weight;
144 vec3 result = accumulated / total_weight;
145 result = mix(result, result.bgr, smoothstep(0.88, 1.0,
amp_peak) * 0.3);
146 result = (result - 0.5) * (1.1 +
amp_smooth * 0.24) + 0.5;
147 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 petal_warp(vec2 uv, vec2 center, float depth, float bass, float middle)
Evaluates petal warp for this shader effect.