ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
peak_inversion_texture-code_cache-3-chrome_aurora_maze.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file peak_inversion_texture-code_cache-3-chrome_aurora_maze.frag
5 * @brief Vulkan fragment shader: peak inversion texture-code cache-3-chrome aurora maze.
6 */
7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
8 vec4 mouse;
9 vec4 u0;
10 vec4 u1;
11 vec4 u2;
12 vec4 u3;
13 vec4 custom_uniforms[16];
14 vec4 audio_bands;
15 vec4 audio_history;
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_rms ext.u3.z
22#define amp_smooth ext.u3.w
23#define history_head int(ext.u3.x)
24#define iMouse ext.mouse
25#define iResolution ext.u0.zw
26#define slider1 ext.custom_uniforms[5].x
27#define slider2 ext.custom_uniforms[5].y
28#define slider3 ext.custom_uniforms[5].z
29#define slider4 ext.custom_uniforms[5].w
30#define spectrum_history_head int(ext.audio_history.x)
31#define spectrum_history_size int(ext.audio_history.y)
32#define time_f ext.u2.y
33
34// chrome_aurora_maze
35// Chrome maze walls carry aurora feedback through moving ripple sources.
36#define FX_MODE 4
37layout(location = 0) in vec2 tc;
38layout(location = 0) out vec4 color;
39layout(set = 0, binding = 0) uniform sampler2D samp;
40layout(set = 0, binding = 2) uniform sampler2DArray history;
41
42#ifndef SIZE
43#define SIZE 8
44#endif
45#ifndef CACHE_HISTORY_LAYER
46#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
47#endif
48layout(set = 0, binding = 3) uniform sampler1D spectrum0;
49layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
50
51
52#ifndef SPECTRUM_HISTORY_LAYER
53#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
54#endif
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69const float TAU = 6.28318530718;
70const int MODE = FX_MODE;
71
72/**
73 * @brief Evaluates rotate2D for this shader effect.
74 * @param a Input value for the calculation.
75 * @return Computed mat2 value.
76 */
77mat2 rotate2D(float a) {
78 float c = cos(a);
79 float s = sin(a);
80 return mat2(c, -s, s, c);
81}
82
83/**
84 * @brief Evaluates mirrorUV for this shader effect.
85 * @param uv Input value for the calculation.
86 * @return Computed vec2 value.
87 */
88vec2 mirrorUV(vec2 uv) {
89 return 1.0 - abs(mod(uv, 2.0) - 1.0);
90}
91
92// Feather only near mirror turnarounds. This keeps the useful repeat behavior
93// while removing the hard derivative flip that can appear as a vertical seam.
94/**
95 * @brief Evaluates seamlessUV for this shader effect.
96 * @param uv Input value for the calculation.
97 * @return Computed vec2 value.
98 */
99vec2 seamlessUV(vec2 uv) {
100 vec2 mirrored = mirrorUV(uv);
101 vec2 cosineFold = 0.5 - 0.5 * cos(3.14159265359 * uv);
102 vec2 edgeDistance = min(mirrored, 1.0 - mirrored);
103 vec2 feather = 1.0 - smoothstep(vec2(0.015), vec2(0.085), edgeDistance);
104 return mix(mirrored, cosineFold, feather);
105}
106
107/**
108 * @brief Evaluates hash21 for this shader effect.
109 * @param p Input value for the calculation.
110 * @return Computed float value.
111 */
112float hash21(vec2 p) {
113 return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
114}
115
116/**
117 * @brief Evaluates noise21 for this shader effect.
118 * @param p Input value for the calculation.
119 * @return Computed float value.
120 */
121float noise21(vec2 p) {
122 vec2 cell = floor(p);
123 vec2 f = fract(p);
124 f = f * f * (3.0 - 2.0 * f);
125 return mix(mix(hash21(cell), hash21(cell + vec2(1.0, 0.0)), f.x),
126 mix(hash21(cell + vec2(0.0, 1.0)), hash21(cell + 1.0), f.x), f.y);
127}
128
129/**
130 * @brief Evaluates fbm for this shader effect.
131 * @param p Input value for the calculation.
132 * @return Computed float value.
133 */
134float fbm(vec2 p) {
135 float sum = 0.0;
136 float weight = 0.5;
137 for (int i = 0; i < 4; ++i) {
138 sum += noise21(p) * weight;
139 p = rotate2D(0.71) * p * 2.03 + 1.37;
140 weight *= 0.5;
141 }
142 return sum;
143}
144
145/**
146 * @brief Evaluates hexCell for this shader effect.
147 * @param p Input value for the calculation.
148 * @return Computed vec2 value.
149 */
150vec2 hexCell(vec2 p) {
151 vec2 scale = vec2(1.0, 1.7320508);
152 vec2 a = mod(p, scale) - scale * 0.5;
153 vec2 b = mod(p - scale * 0.5, scale) - scale * 0.5;
154 return dot(a, a) < dot(b, b) ? a : b;
155}
156
157/**
158 * @brief Evaluates kaleido for this shader effect.
159 * @param p Input value for the calculation.
160 * @param sides Input value for the calculation.
161 * @return Computed vec2 value.
162 */
163vec2 kaleido(vec2 p, float sides) {
164 float radius = length(p);
165 float sector = TAU / sides;
166 float angle = abs(mod(atan(p.y, p.x) + sector * 0.5, sector) - sector * 0.5);
167 return vec2(cos(angle), sin(angle)) * radius;
168}
169
170/**
171 * @brief Evaluates palette for this shader effect.
172 * @param x Input value for the calculation.
173 * @return Computed vec3 value.
174 */
175vec3 palette(float x) {
176 float modeHue = float(MODE) * 0.071;
177 int paletteFamily = MODE % 5;
178 if (paletteFamily == 0) {
179 return 0.52 + 0.5 * cos(TAU * (x + modeHue + vec3(0.02, 0.34, 0.68)));
180 }
181 if (paletteFamily == 1) {
182 return vec3(0.48, 0.22, 0.64) +
183 vec3(0.52, 0.3, 0.62) *
184 cos(TAU * (x * vec3(1.0, 0.78, 1.34) + vec3(0.42, 0.18, 0.82)));
185 }
186 if (paletteFamily == 2) {
187 return vec3(0.48, 0.34, 0.18) +
188 vec3(0.52, 0.42, 0.3) *
189 cos(TAU * (x * vec3(0.82, 1.14, 1.5) + vec3(0.03, 0.13, 0.58)));
190 }
191 if (paletteFamily == 3) {
192 return vec3(0.22, 0.48, 0.56) +
193 vec3(0.28, 0.52, 0.48) *
194 cos(TAU * (x * vec3(1.25, 0.9, 1.08) + vec3(0.58, 0.08, 0.25)));
195 }
196 return vec3(0.5) + vec3(0.5) * cos(TAU * (x * vec3(1.0, 1.41, 1.73) + vec3(0.0, 0.21, 0.47)));
197}
198
199/**
200 * @brief Evaluates aces for this shader effect.
201 * @param x Input value for the calculation.
202 * @return Computed vec3 value.
203 */
204vec3 aces(vec3 x) {
205 return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
206}
207
208/**
209 * @brief Evaluates sampleCache for this shader effect.
210 * @param index Input value for the calculation.
211 * @param uv Input value for the calculation.
212 * @return Computed vec4 value.
213 */
214vec4 sampleCache(int index, vec2 uv) {
215 if (index == 0)
216 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(0))));
217 if (index == 1)
218 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(1))));
219 if (index == 2)
220 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(2))));
221 if (index == 3)
222 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(3))));
223 if (index == 4)
224 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(4))));
225 if (index == 5)
226 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(5))));
227 if (index == 6)
228 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(6))));
229 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(7))));
230}
231
232/**
233 * @brief Evaluates sampleHistory for this shader effect.
234 * @param index Input value for the calculation.
235 * @param frequency Input value for the calculation.
236 * @return Computed float value.
237 */
238float sampleHistory(int index, float frequency) {
239 if (index == 0)
240 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(1)))).r;
241 if (index == 1)
242 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(2)))).r;
243 if (index == 2)
244 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(3)))).r;
245 if (index == 3)
246 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(4)))).r;
247 if (index == 4)
248 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(5)))).r;
249 if (index == 5)
250 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(6)))).r;
251 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(7)))).r;
252}
253
254/**
255 * @brief Evaluates effectField for this shader effect.
256 * @param p Input value for the calculation.
257 * @param origin Input value for the calculation.
258 * @param bass Input value for the calculation.
259 * @param mid Input value for the calculation.
260 * @param treble Input value for the calculation.
261 * @return Computed float value.
262 */
263float effectField(vec2 p, vec2 origin, float bass, float mid, float treble) {
264 vec2 q = p - origin;
265 float radius = length(q) + 0.001;
266 float angle = atan(q.y, q.x);
267 float t = time_f;
268 float field = 0.0;
269
270 if (MODE == 0) {
271 vec2 moonA = vec2(cos(t * 0.43), sin(t * 0.61)) * 0.22;
272 vec2 moonB = vec2(cos(t * 0.31 + 2.1), sin(t * 0.47 + 2.1)) * 0.31;
273 field = sin(length(q - moonA) * (26.0 + bass * 16.0) - t * 6.0) * 0.13;
274 field += sin(length(q - moonB) * (21.0 + mid * 14.0) - t * 4.6) * 0.12;
275 field += cos(angle * 5.0 - radius * 13.0 + t * 2.0) * 0.08;
276 } else if (MODE == 1) {
277 vec2 grid = abs(fract((q + fbm(q * 3.0) * 0.04) * 9.0) - 0.5);
278 float circuit = exp(-min(grid.x, grid.y) * (32.0 + treble * 20.0));
279 field = circuit * 0.27 + sin(radius * 25.0 - t * 5.0) * 0.11;
280 field += sin((q.x - q.y) * 16.0 + t * 2.0) * 0.06;
281 } else if (MODE == 2) {
282 vec2 cell = hexCell((q + vec2(t * 0.025, 0.0)) * 8.0);
283 float plate = pow(max(1.0 - length(cell) * 1.45, 0.0), 4.0);
284 field = plate * (0.22 + 0.1 * cos(atan(cell.y, cell.x) * 6.0));
285 field += sin(radius * (28.0 + bass * 15.0) - t * 6.0) * 0.12;
286 } else if (MODE == 3) {
287 float helix = sin(angle * (4.0 + floor(treble * 5.0)) - radius * 19.0 - t * 5.0);
288 float counter = cos(angle * 3.0 + radius * 14.0 - t * 3.0);
289 field = helix * 0.16 + counter * 0.1 + fbm(q * 5.0 - t * 0.15) * 0.13;
290 } else if (MODE == 4) {
291 vec2 maze = abs(fract((rotate2D(0.25) * q) * 8.0) - 0.5);
292 float walls = 1.0 - smoothstep(0.04, 0.13, min(maze.x, maze.y));
293 field = walls * 0.24 + sin(radius * 23.0 - t * 5.0) * 0.11;
294 field += cos(angle * 8.0 + floor(radius * 10.0) * 1.7) * 0.05;
295 } else if (MODE == 5) {
296 float well = sin(log(radius + 0.04) * (13.0 + bass * 5.0) - angle * 4.0 + t * 4.0);
297 field = well * 0.2 + exp(-radius * 5.0) * 0.28;
298 field += sin(length(q - vec2(0.2, 0.0)) * 26.0 - t * 6.0) * 0.08;
299 } else if (MODE == 6) {
300 float petals = cos(angle * (7.0 + floor(treble * 4.0)) - radius * 12.0);
301 float bloom = pow(max(petals, 0.0), 4.0) * exp(-radius * 1.8);
302 field = bloom * 0.3 + sin(radius * (25.0 + bass * 18.0) - t * 5.5) * 0.12;
303 } else if (MODE == 7) {
304 float meshA = sin(q.x * 19.0 + sin(q.y * 7.0 - t) * 4.0);
305 float meshB = sin(q.y * 17.0 + cos(q.x * 8.0 + t) * 4.0);
306 field = pow(1.0 - abs(meshA * meshB), 5.0) * 0.25;
307 field += sin(radius * 30.0 - t * (7.0 + bass * 3.0)) * 0.11;
308 } else if (MODE == 8) {
309 vec2 h = q;
310 h.x *= 1.0 + 1.5 * abs(q.y);
311 float glass = sin(length(h) * 28.0 - t * 5.0);
312 float waist = exp(-abs(q.x) * (8.0 + mid * 5.0)) * cos(q.y * 18.0 - t * 3.0);
313 field = glass * 0.13 + waist * 0.22 + fbm(q * 4.0) * 0.08;
314 } else if (MODE == 9) {
315 float arches = cos(sqrt(q.x * q.x + 0.004) * 16.0 - q.y * 5.0);
316 float sonar = sin(radius * (27.0 + bass * 17.0) - t * 7.0);
317 field = arches * 0.16 + sonar * 0.13 + pow(max(cos(angle * 6.0), 0.0), 5.0) * 0.17;
318 } else if (MODE == 10) {
319 float spikes = pow(abs(sin(angle * 9.0 - radius * 21.0 + t * 2.0)), 8.0);
320 field = spikes * exp(-radius * 1.4) * 0.3;
321 field += sin(radius * (24.0 + bass * 20.0) - t * 6.0) * 0.12;
322 field += (fbm(q * 6.0 + t * 0.08) - 0.5) * 0.15;
323 } else if (MODE == 11) {
324 vec2 k = kaleido(q, 8.0 + floor(treble * 5.0));
325 field = sin(length(k - vec2(0.18, 0.0)) * 28.0 - t * 5.0) * 0.13;
326 field += cos(atan(k.y, k.x) * 5.0 - length(k) * 18.0) * 0.17;
327 } else if (MODE == 12) {
328 float canopy = sin(q.x * 11.0 + sin(q.y * 8.0 + t) * 3.0);
329 canopy *= cos(q.y * 13.0 - cos(q.x * 6.0 - t) * 3.0);
330 field = canopy * 0.16 + sin(radius * 29.0 - t * 7.0) * 0.12;
331 field += exp(-radius * 2.5) * 0.18;
332 } else if (MODE == 13) {
333 float shell = sin(log(radius + 0.08) * 14.0 - angle * 6.0 + t * 3.5);
334 float ribs = cos(angle * 12.0 + radius * 6.0);
335 field = shell * 0.18 + ribs * exp(-radius * 1.8) * 0.13;
336 field += sin(radius * (22.0 + bass * 18.0) - t * 5.0) * 0.09;
337 } else if (MODE == 14) {
338 float ribbons = sin(q.x * 15.0 + sin(q.y * 6.0 - t * 0.8) * 5.0);
339 ribbons += cos(q.y * 14.0 + sin(q.x * 7.0 + t) * 4.0);
340 field = ribbons * 0.105 + sin(radius * 24.0 - t * 5.0) * 0.1;
341 } else if (MODE == 15) {
342 vec2 cell = hexCell(q * (7.0 + treble * 3.0));
343 float geode = pow(max(1.0 - length(cell) * 1.5, 0.0), 6.0);
344 float vortex = sin(angle * 5.0 - radius * 18.0 - t * 4.0);
345 field = geode * 0.29 + vortex * 0.13 + sin(radius * 29.0 - t * 6.0) * 0.07;
346 } else if (MODE == 16) {
347 vec2 cell = hexCell((q + vec2(sin(t * 0.2), cos(t * 0.17)) * 0.03) * 10.0);
348 float honey = smoothstep(0.5, 0.18, length(cell));
349 field = honey * 0.25 + sin(radius * (25.0 + bass * 15.0) - t * 5.0) * 0.12;
350 field += cos(atan(cell.y, cell.x) * 6.0) * honey * 0.07;
351 } else if (MODE == 17) {
352 float torus = sin((radius - 0.28) * (34.0 + bass * 15.0) - t * 6.0);
353 float rain = sin(q.y * 27.0 + sin(q.x * 9.0 - t) * 5.0 + t * 4.0);
354 field = torus * exp(-abs(radius - 0.28) * 3.0) * 0.2 + rain * 0.1;
355 } else if (MODE == 18) {
356 float web = sin(angle * 10.0 + sin(radius * 14.0 - t * 2.0) * 2.0);
357 float rings = sin(radius * (26.0 + bass * 17.0) - t * 6.0);
358 field = pow(abs(web), 5.0) * 0.22 + rings * 0.12;
359 field += fbm(q * 5.0 - t * 0.1) * 0.1;
360 } else if (MODE == 19) {
361 float bell = exp(-abs(q.y + 0.06) * 3.0) * cos(q.x * 15.0);
362 float tentacles = sin(q.y * 19.0 + sin(q.x * 11.0 + t) * 4.0 - t * 3.0);
363 field = bell * 0.22 + tentacles * smoothstep(0.3, -0.4, q.y) * 0.12;
364 field += sin(radius * 23.0 - t * 5.0) * 0.08;
365 } else if (MODE == 20) {
366 float fault = tanh(sin(q.x * 8.0 + fbm(q * 4.0) * 5.0 + t) * 4.0);
367 float aurora = sin(q.y * 15.0 + sin(q.x * 5.0 - t) * 4.0);
368 field = fault * 0.13 + aurora * 0.13 + sin(radius * 27.0 - t * 6.0) * 0.08;
369 } else if (MODE == 21) {
370 float forge = sin(q.x * 17.0 + cos(q.y * 8.0 + t) * 5.0);
371 float cross = cos(q.y * 19.0 + sin(q.x * 6.0 - t) * 3.0);
372 field = abs(forge + cross) * 0.12 + sin(radius * 25.0 - t * 5.5) * 0.11;
373 } else if (MODE == 22) {
374 float lotus = pow(max(cos(angle * 9.0 - radius * 13.0 + t * 2.0), 0.0), 5.0);
375 float ripple = sin(radius * (28.0 + bass * 18.0) - t * 7.0);
376 field = lotus * exp(-radius * 1.7) * 0.31 + ripple * 0.12;
377 } else if (MODE == 23) {
378 float handA = exp(-abs(sin(angle - t * 0.4)) * radius * 24.0);
379 float handB = exp(-abs(sin(angle + t * 0.23)) * radius * 32.0);
380 float clock = sin(radius * 32.0 - floor(t * 3.0) * 0.7);
381 field = (handA + handB) * 0.18 + clock * 0.12;
382 } else {
383 float nova = sin(radius * (35.0 + bass * 20.0) - t * 9.0);
384 float rays = pow(abs(cos(angle * (10.0 + floor(treble * 6.0)) + t)), 10.0);
385 float cathedral = cos(sqrt(q.x * q.x + 0.003) * 15.0 - q.y * 5.0);
386 field = nova * 0.13 + rays * exp(-radius * 2.2) * 0.26 + cathedral * 0.1;
387 }
388
389 vec2 sourceA = vec2(sin(t * 0.3), cos(t * 0.4)) * vec2(0.2, 0.15);
390 vec2 sourceB = vec2(-sin(t * 0.5), sin(t * 0.3)) * vec2(0.15, 0.2);
391 vec2 sourceC = vec2(cos(t * 0.2), -cos(t * 0.6)) * 0.1;
392 float density = mix(0.7, 1.55, max(slider2, 0.1));
393 float rippleA = sin(length(q - sourceA) * (20.0 + bass * 15.0) * density - t * 5.0);
394 float rippleB = sin(length(q - sourceB) * (18.0 + mid * 12.0) * density - t * 4.0);
395 float rippleC = sin(length(q - sourceC) * (22.0 + treble * 10.0) * density - t * 6.0);
396 float interference = (rippleA + rippleB + rippleC) / 3.0;
397
398 float arms = 3.0 + floor(treble * 4.0 + max(slider1, 0.1) * 5.0);
399 float twist = 15.0 - bass * 8.0;
400 float spiralPhase = angle * arms - radius * twist - t * (4.0 + amp_smooth * 8.0);
401 float spiral = pow(max(sin(spiralPhase), 0.0), 4.0) * exp(-radius * (2.0 - mid));
402
403 return field + interference * 0.12 + spiral * 0.22 +
404 (fbm(q * 3.2 + vec2(0.0, -t * 0.12)) - 0.5) * 0.06;
405}
406
407vec2 feedbackTransform(vec2 uv, vec2 center, float generation, float bass, float mid, float treble,
408 vec2 normalFlow) {
409 vec2 q = uv - center;
410 int family = MODE % 5;
411 float zoom = pow(max(0.975 - bass * 0.085, 0.25), generation);
412 float angle = (0.018 + treble * 0.105) * generation;
413
414 if (family == 0) {
415 q = rotate2D(angle) * q * zoom;
416 q += normalFlow * generation * (0.008 + mid * 0.012);
417 } else if (family == 1) {
418 q = kaleido(rotate2D(angle * 0.55) * q, 5.0 + float(MODE % 7)) * zoom;
419 } else if (family == 2) {
420 q.x += sin(q.y * 14.0 + generation + time_f) * (0.006 + mid * 0.015) * generation;
421 q.y += cos(q.x * 12.0 - generation + time_f) * (0.005 + treble * 0.01) * generation;
422 q *= zoom;
423 } else if (family == 3) {
424 q = rotate2D(-angle) * q;
425 q.x *= 1.0 + generation * (0.012 + mid * 0.018);
426 q.y *= zoom;
427 } else {
428 float radius = length(q);
429 q = rotate2D(angle + sin(radius * 16.0 - time_f) * 0.035 * generation) * q * zoom;
430 q += normalize(q + vec2(0.001)) * bass * 0.012 * generation;
431 }
432
433 // Return an unfolded coordinate. Folding again after manual zoom caused
434 // double-reflection creases in several of the original variants.
435 return q + center;
436}
437
438/**
439 * @brief Evaluates modeOverlay for this shader effect.
440 * @param p Input value for the calculation.
441 * @param height Input value for the calculation.
442 * @param audio Input value for the calculation.
443 * @return Computed float value.
444 */
445float modeOverlay(vec2 p, float height, float audio) {
446 float radius = length(p);
447 float angle = atan(p.y, p.x);
448 int family = MODE % 5;
449 if (family == 0)
450 return pow(max(sin(radius * 34.0 - time_f * 8.0), 0.0), 10.0);
451 if (family == 1)
452 return pow(max(cos(angle * (6.0 + float(MODE % 8)) - radius * 17.0), 0.0), 7.0);
453 if (family == 2)
454 return pow(1.0 - abs(sin((p.x + p.y) * 22.0 + time_f * 3.0)), 9.0);
455 if (family == 3)
456 return pow(max(sin(height * 31.0 + angle * 3.0 - time_f * 4.0), 0.0), 8.0);
457 return pow(max(cos(log(radius + 0.04) * 15.0 - angle * 5.0 + time_f * 3.0), 0.0), 9.0) *
458 (0.45 + audio);
459}
460
461/**
462 * @brief Executes the fragment shader entry point.
463 */
464void main() {
465 vec2 resolution = max(iResolution, vec2(1.0));
466 float aspect = resolution.x / resolution.y;
467 vec2 mouseUV = iMouse.xy / resolution;
468
469 float bass = texture(spectrum0, 0.03).r;
470 float mid = texture(spectrum0, 0.22).r;
471 float treble = texture(spectrum0, 0.58).r;
472 float air = texture(spectrum0, 0.80).r;
473 float audioGate = clamp(amp_rms + amp_peak + amp_low + amp_mid + amp_high, 0.0, 1.0);
474
475 vec2 p = (tc - 0.5) * vec2(aspect, 1.0);
476 vec2 origin = iMouse.z > 0.0 ? (mouseUV - 0.5) * vec2(aspect, 1.0) : vec2(0.0);
477 float pixel = 2.0 / max(max(resolution.x, resolution.y), 360.0);
478 float radius = length(p - origin);
479 float historyShell = clamp(radius * 7.0, 0.0, 7.0);
480 int shellIndex = int(historyShell);
481 float shellFFT = sampleHistory(min(shellIndex, 6), clamp(radius * 0.65, 0.0, 1.0));
482
483 float height = effectField(p, origin, bass, mid, treble);
484 vec2 gradient = vec2(effectField(p + vec2(pixel, 0.0), origin, bass, mid, treble) - height,
485 effectField(p + vec2(0.0, pixel), origin, bass, mid, treble) - height) /
486 pixel;
487 vec3 normal = normalize(vec3(-gradient * (0.21 + amp_high * 0.06), 1.0));
488
489 float waveDrive = sin(height * (18.0 + max(slider2, 0.1) * 22.0) -
490 time_f * (3.0 + audioGate * 5.0) + shellFFT * 8.0);
491 vec2 radial = normalize(p - origin + vec2(0.001));
492 vec2 liveDistortion = normal.xy * (0.027 + amp_low * 0.05) +
493 radial * waveDrive * (0.008 + shellFFT * 0.025 * max(slider4, 0.1));
494 vec2 flowUV = seamlessUV(tc + liveDistortion);
495 float dispersion =
496 (0.005 + treble * 0.019 + abs(waveDrive) * 0.008) * mix(0.2, 2.4, max(slider3, 0.1));
497 vec3 live =
498 vec3(texture(samp, seamlessUV(flowUV + normal.xy * dispersion)).r, texture(samp, flowUV).g,
499 texture(samp, seamlessUV(flowUV - normal.xy * dispersion)).b);
500
501 vec3 viewDir = normalize(vec3(-p * 0.12, 1.8));
502 vec3 lightA = normalize(vec3(-0.55, 0.7, 0.82));
503 vec3 lightB = normalize(vec3(0.72, -0.18, 0.68));
504 float fresnel = pow(1.0 - max(dot(normal, viewDir), 0.0), 5.0);
505 float roughnessProfile = float(MODE % 7) / 6.0;
506 float specA =
507 pow(max(dot(normal, normalize(viewDir + lightA)), 0.0), mix(145.0, 34.0, roughnessProfile));
508 float specB =
509 pow(max(dot(normal, normalize(viewDir + lightB)), 0.0), mix(82.0, 20.0, roughnessProfile));
510 float luminance = dot(live, vec3(0.299, 0.587, 0.114));
511
512 float mouseIntensity = length(mouseUV - vec2(0.5)) * 2.0;
513 float timeHue = iMouse.z > 0.0 ? mouseIntensity * time_f * 0.32 : 0.0;
514 float manualHue = iMouse.w > 0.0 ? (mouseUV.x - 0.5) * 2.4 : 0.0;
515 vec3 acidMetal = palette(height * 1.8 + bass + time_f * 0.055 + timeHue + manualHue);
516 float modeIntensity = 1.15 + 0.25 * sin(float(MODE) * 2.17);
517 float alloyMix = 0.38 + 0.1 * float(MODE % 4);
518 vec3 current = mix(live, acidMetal * (0.3 + luminance), alloyMix) * modeIntensity;
519 current *= 0.14 + 0.62 * max(dot(normal, lightA), 0.0);
520 current += palette(normal.x * 0.23 - normal.y * 0.17 + time_f * 0.035) *
521 (fresnel * 0.75 + specA * 2.3 + specB * 1.4);
522
523 vec3 accumulated = current;
524 float totalWeight = 1.0;
525 vec2 feedbackCenter =
526 iMouse.z > 0.0 ? mouseUV + liveDistortion * 0.15 : vec2(0.5) + liveDistortion * 1.5;
527 float manualZoom = iMouse.w > 0.0 ? (0.5 - mouseUV.y) * 0.16 : 0.0;
528 vec3 userHue = vec3(sin(timeHue), cos(timeHue * 0.8), sin(timeHue * 1.2));
529
530 for (int i = 0; i < 8; ++i) {
531 float generation = float(i + 1);
532 float oldBass = sampleHistory(i, 0.03);
533 float oldMid = sampleHistory(i, 0.22);
534 float oldTreble = sampleHistory(i, 0.58);
535 vec2 historyUV = feedbackTransform(tc, feedbackCenter, generation, oldBass, oldMid,
536 oldTreble, normal.xy);
537 historyUV =
538 feedbackCenter + (historyUV - feedbackCenter) *
539 pow(max(1.0 + manualZoom - oldBass * 0.03, 0.05), generation);
540 vec3 history = sampleCache(i, seamlessUV(historyUV)).rgb;
541 float driftDirection = (MODE % 2 == 0) ? 1.0 : -1.0;
542 float shift = generation * (0.045 + 0.012 * float(MODE % 4));
543 history.r *= 1.0 + driftDirection * shift + oldMid * 0.32 + userHue.r * generation * 0.1;
544 history.g *=
545 1.0 - driftDirection * shift * 0.78 - oldBass * 0.18 + userHue.g * generation * 0.1;
546 history.b *=
547 1.0 + driftDirection * shift * 0.5 + oldTreble * 0.38 + userHue.b * generation * 0.1;
548 history *= palette(height * 0.13 + generation * 0.052 + manualHue);
549 float historyDecay = 0.7 + 0.025 * float(MODE % 5);
550 float weight = pow(historyDecay, generation);
551 accumulated += history * weight;
552 totalWeight += weight;
553 }
554
555 accumulated /= totalWeight;
556 float crest = pow(max(sin(height * 24.0 - time_f * 2.5), 0.0), 8.0);
557 accumulated += palette(height + time_f * 0.11 + timeHue) * crest * (0.55 + air * 2.0);
558 float vividRing = smoothstep(0.1, 0.95, waveDrive) * (0.2 + shellFFT + audioGate);
559 vec3 ringColor = palette(radius * 2.0 + historyShell * 0.08 + shellFFT * 0.4 + manualHue);
560 accumulated = 1.0 - (1.0 - accumulated) * (1.0 - clamp(ringColor * vividRing, 0.0, 1.0));
561 accumulated += ringColor * vividRing * 0.55;
562 float signature = modeOverlay(p - origin, height, audioGate);
563 vec3 signatureColor =
564 palette(height * 0.7 + radius * 0.35 - time_f * 0.08 + float(MODE) * 0.031);
565 accumulated += signatureColor * signature * (0.28 + amp_high * 0.75 + float(MODE % 3) * 0.12);
566 if (MODE % 3 == 1)
567 accumulated = mix(accumulated, accumulated.brg, signature * 0.22);
568 if (MODE % 3 == 2)
569 accumulated = mix(accumulated, accumulated.gbr, signature * 0.2);
570 accumulated = mix(accumulated, vec3(1.0) - accumulated, smoothstep(0.91, 1.0, amp_peak));
571 accumulated = (accumulated - 0.5) * (1.22 + amp_smooth * 0.3) + 0.5;
572
573 color = vec4(aces(max(accumulated, 0.0)), texture(samp, flowUV).a);
574}
layout(set=0, binding=1, std140) uniform SpriteExtended
Definition 3high.frag:7
#define iMouse
Definition 3high.frag:17
ext
Definition 3high.frag:16
void main(void)
Executes the fragment shader entry point.
Definition 3high.frag:47
#define iResolution
Definition 3high.frag:18
#define time_f
Definition 3high.frag:19
float fbm(vec2 point)
Evaluates fbm for this shader effect.
#define amp_smooth
#define CACHE_HISTORY_LAYER(index)
#define amp_mid
vec3 palette(float phase)
Evaluates palette for this shader effect.
#define amp_low
#define amp_high
#define SPECTRUM_HISTORY_LAYER(index)
#define amp_peak
vec3 ripple(ivec2 p, ivec2 size)
Evaluates ripple for this shader effect.
vec3 aurora(float t)
Evaluates aurora for this shader effect.
vec2 mirrorUV(vec2 uv)
Evaluates mirrorUV for this shader effect.
vec3 bloom(float t)
Evaluates bloom for this shader effect.
vec2 kaleido(vec2 p, float seg)
Evaluates kaleido for this shader effect.
#define amp_rms
Definition breathe.frag:21
float hash21(vec2 p)
Evaluates hash21 for this shader effect.
float h(vec2 p)
Evaluates h for this shader effect.
float field(vec2 p, float tm)
Evaluates field for this shader effect.
float luminance(vec3 c)
Evaluates luminance for this shader effect.
mat2 rotate2D(float a)
Evaluates rotate2D for this shader effect.
vec3 aces(vec3 x)
Evaluates aces for this shader effect.
vec2 hexCell(vec2 p)
Evaluates hexCell for this shader effect.
vec4 sampleCache(int index, vec2 uv)
Evaluates sampleCache for this shader effect.
float sampleHistory(int index, float frequency)
Evaluates sampleHistory for this shader effect.
float effectField(vec2 p, vec2 origin, float bass, float mid, float treble)
Evaluates effectField for this shader effect.
vec2 feedbackTransform(vec2 uv, vec2 center, float generation, float bass, float mid, float treble, vec2 normalFlow)
float noise21(vec2 p)
Evaluates noise21 for this shader effect.
vec2 cell(vec2 p)
Evaluates cell for this shader effect.
#define TAU
float ribbons(vec2 point, float bass, float middle, float high)
Evaluates ribbons for this shader effect.
vec2 vortex(vec2 uv, vec2 c, float t)
Evaluates vortex for this shader effect.
Definition huei_af2.frag:80
vec3 interference(float phase, float thickness)
Evaluates interference for this shader effect.
#define frequency
Definition ol.frag:13
vec2 seamlessUV(vec2 uv)
Evaluates seamlessUV for this shader effect.
float modeOverlay(vec2 p, float height, float audio)
Evaluates modeOverlay for this shader effect.
vec2 twist(vec2 coord, float twistAmount, float time, float direction)
Evaluates twist for this shader effect.