ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
af_scale-cache-code-aurora-interference.frag
Go to the documentation of this file.
1#version 450
2
3layout(set = 0, binding = 1, std140) uniform SpriteExtended {
4 vec4 mouse;
5 vec4 u0;
6 vec4 u1;
7 vec4 u2;
8 vec4 u3;
9 vec4 custom_uniforms[16];
10 vec4 audio_bands;
11 vec4 audio_history;
13#define amp_high ext.audio_bands.z
14#define amp_low ext.audio_bands.x
15#define amp_mid ext.audio_bands.y
16#define amp_peak ext.u2.w
17#define amp_smooth ext.u3.w
18#define history_head int(ext.u3.x)
19#define iMouse ext.mouse
20#define iResolution ext.u0.zw
21#define spectrum_history_head int(ext.audio_history.x)
22#define spectrum_history_size int(ext.audio_history.y)
23#define time_f ext.u2.y
24
25/**
26 * @file af_scale-cache-code-aurora-interference.frag
27 * @brief Vulkan fragment shader: af scale-cache-code-aurora-interference.
28 */
29// af_scale-cache-code-aurora-interference
30// Noisy aurora interference with spectral color flow.
31#define EFFECT_ID 13
32layout(location = 0) in vec2 tc;
33layout(location = 0) out vec4 color;
34layout(set = 0, binding = 0) uniform sampler2D samp;
35layout(set = 0, binding = 2) uniform sampler2DArray history;
36
37#ifndef SIZE
38#define SIZE 8
39#endif
40#ifndef CACHE_HISTORY_LAYER
41#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
42#endif
43layout(set = 0, binding = 3) uniform sampler1D spectrum0;
44layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
45
46
47#ifndef SPECTRUM_HISTORY_LAYER
48#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
49#endif
50
51
52
53
54
55
56
57
58
59const float PI = 3.14159265359;
60const float TAU = 6.28318530718;
61
62/**
63 * @brief Evaluates rotate 2d for this shader effect.
64 * @param angle Input value for the calculation.
65 * @return Computed mat2 value.
66 */
67mat2 rotate_2d(float angle) {
68 float cosine = cos(angle);
69 float sine = sin(angle);
70 return mat2(cosine, -sine, sine, cosine);
71}
72
73/**
74 * @brief Evaluates mirror repeat for this shader effect.
75 * @param point Input value for the calculation.
76 * @return Computed vec2 value.
77 */
78vec2 mirror_repeat(vec2 point) {
79 return 1.0 - abs(mod(point, 2.0) - 1.0);
80}
81
82/**
83 * @brief Evaluates ping pong for this shader effect.
84 * @param value Input value for the calculation.
85 * @param size Input value for the calculation.
86 * @return Computed float value.
87 */
88float ping_pong(float value, float size) {
89 float wrapped = mod(value, size * 2.0);
90 return wrapped <= size ? wrapped : size * 2.0 - wrapped;
91}
92
93/**
94 * @brief Evaluates hash 21 for this shader effect.
95 * @param point Input value for the calculation.
96 * @return Computed float value.
97 */
98float hash_21(vec2 point) {
99 return fract(sin(dot(point, vec2(127.1, 311.7))) * 43758.5453);
100}
101
102/**
103 * @brief Evaluates value noise for this shader effect.
104 * @param point Input value for the calculation.
105 * @return Computed float value.
106 */
107float value_noise(vec2 point) {
108 vec2 cell = floor(point);
109 vec2 part = fract(point);
110 part = part * part * (3.0 - 2.0 * part);
111 float lower = mix(hash_21(cell), hash_21(cell + vec2(1.0, 0.0)), part.x);
112 float upper = mix(hash_21(cell + vec2(0.0, 1.0)), hash_21(cell + 1.0), part.x);
113 return mix(lower, upper, part.y);
114}
115
116/**
117 * @brief Evaluates fbm for this shader effect.
118 * @param point Input value for the calculation.
119 * @return Computed float value.
120 */
121float fbm(vec2 point) {
122 float result = 0.0;
123 float weight = 0.5;
124 for (int octave = 0; octave < 4; ++octave) {
125 result += value_noise(point) * weight;
126 point = rotate_2d(0.71) * point * 2.03 + 1.37;
127 weight *= 0.5;
128 }
129 return result;
130}
131
132/**
133 * @brief Evaluates hex cell for this shader effect.
134 * @param point Input value for the calculation.
135 * @return Computed vec2 value.
136 */
137vec2 hex_cell(vec2 point) {
138 vec2 scale = vec2(1.0, 1.7320508);
139 vec2 first = mod(point, scale) - scale * 0.5;
140 vec2 second = mod(point - scale * 0.5, scale) - scale * 0.5;
141 return dot(first, first) < dot(second, second) ? first : second;
142}
143
144/**
145 * @brief Evaluates kaleidoscope for this shader effect.
146 * @param point Input value for the calculation.
147 * @param sides Input value for the calculation.
148 * @return Computed vec2 value.
149 */
150vec2 kaleidoscope(vec2 point, float sides) {
151 float radius = length(point);
152 float sector = TAU / sides;
153 float angle = abs(mod(atan(point.y, point.x) + sector * 0.5, sector) - sector * 0.5);
154 return vec2(cos(angle), sin(angle)) * radius;
155}
156
157/**
158 * @brief Evaluates acid palette for this shader effect.
159 * @param phase Input value for the calculation.
160 * @param hue_offset Input value for the calculation.
161 * @return Computed vec3 value.
162 */
163vec3 acid_palette(float phase, float hue_offset) {
164 vec3 base = vec3(0.5);
165 vec3 amplitude = vec3(0.5);
166 vec3 frequency = vec3(1.0, 1.0, 0.5);
167 vec3 offset = vec3(0.30, 0.20, 0.20);
168 offset += vec3(hue_offset, hue_offset * 1.2, hue_offset * 0.8);
169 offset += float(EFFECT_ID) * vec3(0.031, 0.047, 0.067);
170 return base + amplitude * cos(TAU * (frequency * phase + offset));
171}
172
173/**
174 * @brief Evaluates color scale for this shader effect.
175 * @param video Input value for the calculation.
176 * @param acid_color Input value for the calculation.
177 * @param energy Input value for the calculation.
178 * @return Computed vec3 value.
179 */
180vec3 color_scale(vec3 video, vec3 acid_color, float energy) {
181 float luminance = dot(video, vec3(0.299, 0.587, 0.114));
182 vec3 channel_scale = 0.38 + acid_color * (0.78 + energy * 0.65);
183 vec3 scaled = video * channel_scale;
184 scaled += acid_color * luminance * (0.12 + energy * 0.18);
185 return scaled;
186}
187
188/**
189 * @brief Evaluates tone map for this shader effect.
190 * @param value Input value for the calculation.
191 * @return Computed vec3 value.
192 */
193vec3 tone_map(vec3 value) {
194 value = max(value, 0.0);
195 return clamp((value * (2.51 * value + 0.03)) /
196 (value * (2.43 * value + 0.59) + 0.14),
197 0.0, 1.0);
198}
199
200/**
201 * @brief Evaluates sample cache for this shader effect.
202 * @param index Input value for the calculation.
203 * @param uv Input value for the calculation.
204 * @return Computed vec4 value.
205 */
206vec4 sample_cache(int index, vec2 uv) {
207 uv = mirror_repeat(uv);
208 if (index == 0)
209 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(0))));
210 if (index == 1)
211 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(1))));
212 if (index == 2)
213 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(2))));
214 if (index == 3)
215 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(3))));
216 if (index == 4)
217 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(4))));
218 if (index == 5)
219 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(5))));
220 if (index == 6)
221 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(6))));
222 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(7))));
223}
224
225/**
226 * @brief Evaluates sample history for this shader effect.
227 * @param index Input value for the calculation.
228 * @param frequency Input value for the calculation.
229 * @return Computed float value.
230 */
231float sample_history(int index, float frequency) {
232 if (index == 0)
233 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(1)))).r;
234 if (index == 1)
235 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(2)))).r;
236 if (index == 2)
237 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(3)))).r;
238 if (index == 3)
239 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(4)))).r;
240 if (index == 4)
241 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(5)))).r;
242 if (index == 5)
243 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(6)))).r;
244 return texture(spectrum_history, vec2(frequency, float(SPECTRUM_HISTORY_LAYER(7)))).r;
245}
246
247/**
248 * @brief Evaluates soft sample for this shader effect.
249 * @param image Input value for the calculation.
250 * @param uv Input value for the calculation.
251 * @param texel Input value for the calculation.
252 * @param spread Input value for the calculation.
253 * @return Computed vec4 value.
254 */
255vec4 soft_sample(sampler2D image, vec2 uv, vec2 texel, float spread) {
256 vec4 result = texture(image, mirror_repeat(uv)) * 4.0;
257 result += texture(image, mirror_repeat(uv + vec2(texel.x, 0.0) * spread)) * 2.0;
258 result += texture(image, mirror_repeat(uv - vec2(texel.x, 0.0) * spread)) * 2.0;
259 result += texture(image, mirror_repeat(uv + vec2(0.0, texel.y) * spread)) * 2.0;
260 result += texture(image, mirror_repeat(uv - vec2(0.0, texel.y) * spread)) * 2.0;
261 result += texture(image, mirror_repeat(uv + texel * spread));
262 result += texture(image, mirror_repeat(uv - texel * spread));
263 result += texture(image, mirror_repeat(uv + vec2(texel.x, -texel.y) * spread));
264 result += texture(image, mirror_repeat(uv + vec2(-texel.x, texel.y) * spread));
265 return result / 16.0;
266}
267
268/**
269 * @brief Evaluates effect field for this shader effect.
270 * @param point Input value for the calculation.
271 * @param bass Input value for the calculation.
272 * @param middle Input value for the calculation.
273 * @param treble Input value for the calculation.
274 * @return Computed float value.
275 */
276float effect_field(vec2 point, float bass, float middle, float treble) {
277 float radius = length(point) + 0.0001;
278 float angle = atan(point.y, point.x);
279 float time = time_f;
280 float field = 0.0;
281
282#if EFFECT_ID == 0
283 float nova = sin(radius * (34.0 + bass * 22.0) - time * 8.0);
284 float rays = pow(abs(cos(angle * (10.0 + floor(treble * 7.0)) + time)), 10.0);
285 float arches = cos(sqrt(point.x * point.x + 0.003) * 16.0 - point.y * 6.0);
286 field = nova * 0.28 + rays * exp(-radius * 2.0) * 0.55 + arches * 0.17;
287#elif EFFECT_ID == 1
288 float cross_wave = sin(point.x * 16.0 + time * 5.0) + sin(point.y * 18.0 + time * 4.0);
289 field = cross_wave * 0.18 + sin(angle * 6.0 - radius * 24.0 + time * 5.0) * 0.4;
290#elif EFFECT_ID == 2
291 vec2 glass = point;
292 glass.x *= 1.0 + abs(point.y) * (1.8 + middle);
293 field = sin(length(glass) * 29.0 - time * 5.0) * 0.35;
294 field += exp(-abs(point.x) * (8.0 + middle * 7.0)) * cos(point.y * 19.0) * 0.35;
295#elif EFFECT_ID == 3
296 vec2 cell = hex_cell(point * (8.0 + treble * 4.0));
297 float plate = pow(max(1.0 - length(cell) * 1.5, 0.0), 5.0);
298 field = plate * 0.65 + sin(radius * (28.0 + bass * 18.0) - time * 6.0) * 0.3;
299#elif EFFECT_ID == 4
300 vec2 petal = kaleidoscope(point, 7.0 + floor(treble * 5.0));
301 field = cos(atan(petal.y, petal.x) * 5.0 - length(petal) * 19.0) * 0.4;
302 field += sin(length(petal - vec2(0.2, 0.0)) * 28.0 - time * 5.0) * 0.3;
303#elif EFFECT_ID == 5
304 float sonar = sin(radius * (31.0 + bass * 18.0) - time * 8.0);
305 float spiral = sin(angle * 5.0 - radius * 17.0 + time * 3.0);
306 field = sonar * 0.38 + spiral * 0.34;
307#elif EFFECT_ID == 6
308 float lattice_x = sin(point.x * 18.0 + sin(point.y * 7.0 - time) * 4.0);
309 float lattice_y = sin(point.y * 17.0 + cos(point.x * 8.0 + time) * 4.0);
310 field = (1.0 - abs(lattice_x * lattice_y)) * 0.55 + sin(radius * 27.0 - time * 6.0) * 0.25;
311#elif EFFECT_ID == 7
312 vec2 cell = hex_cell(rotate_2d(0.25) * point * 9.0);
313 float facet = pow(max(1.0 - length(cell) * 1.6, 0.0), 7.0);
314 field = facet * 0.7 + cos(atan(cell.y, cell.x) * 6.0) * facet * 0.2;
315#elif EFFECT_ID == 8
316 float rose = cos(angle * (8.0 + floor(treble * 5.0)) - radius * 13.0 + time * 2.0);
317 field = pow(max(rose, 0.0), 5.0) * exp(-radius * 1.5) * 0.75;
318 field += sin(radius * 27.0 - time * 6.0) * 0.25;
319#elif EFFECT_ID == 9
320 float fold = ping_pong(radius + time * (0.18 + bass * 0.2), 0.34);
321 field = sin(fold * (42.0 + middle * 20.0)) * 0.48;
322 field += cos(angle * 8.0 + floor(radius * 11.0) * 1.6) * 0.25;
323#elif EFFECT_ID == 10
324 vec2 grid = abs(fract((point + fbm(point * 4.0) * 0.05) * 10.0) - 0.5);
325 float circuit = exp(-min(grid.x, grid.y) * (30.0 + treble * 24.0));
326 field = circuit * 0.65 + sin(radius * 26.0 - time * 6.0) * 0.28;
327#elif EFFECT_ID == 11
328 float ribbon_a = sin(point.x * 15.0 + sin(point.y * 6.0 - time) * 5.0);
329 float ribbon_b = cos(point.y * 14.0 + sin(point.x * 7.0 + time) * 4.0);
330 field = (ribbon_a + ribbon_b) * 0.25 + sin(angle * 4.0 - radius * 17.0) * 0.2;
331#elif EFFECT_ID == 12
332 vec2 crystal = kaleidoscope(point, 6.0);
333 float tunnel = sin(log(length(crystal) + 0.07) * (15.0 + bass * 6.0) - time * 5.0);
334 field = tunnel * 0.4 + cos(atan(crystal.y, crystal.x) * 9.0) * 0.3;
335#elif EFFECT_ID == 13
336 float fault = tanh(sin(point.x * 8.0 + fbm(point * 4.0) * 6.0 + time) * 4.0);
337 float aurora = sin(point.y * 16.0 + sin(point.x * 5.0 - time) * 4.0);
338 field = fault * 0.3 + aurora * 0.32 + fbm(point * 5.0 - time * 0.1) * 0.18;
339#elif EFFECT_ID == 14
340 float hand_a = exp(-abs(sin(angle - floor(time * 2.0) * 0.2)) * radius * 25.0);
341 float hand_b = exp(-abs(sin(angle + time * 0.31)) * radius * 34.0);
342 field = (hand_a + hand_b) * 0.5 + sin(radius * 33.0 - floor(time * 3.0)) * 0.28;
343#elif EFFECT_ID == 15
344 vec2 cell = hex_cell((point + vec2(sin(time * 0.2), cos(time * 0.17)) * 0.03) * 10.0);
345 float honey = smoothstep(0.5, 0.16, length(cell));
346 field = honey * 0.65 + sin(radius * (25.0 + bass * 17.0) - time * 5.0) * 0.28;
347#elif EFFECT_ID == 16
348 float web = sin(angle * 11.0 + sin(radius * 15.0 - time * 2.0) * 2.0);
349 field = pow(abs(web), 6.0) * 0.62 + sin(radius * (29.0 + bass * 17.0) - time * 7.0) * 0.3;
350#elif EFFECT_ID == 17
351 float helix_a = sin(angle * 5.0 - radius * 21.0 - time * 5.0);
352 float helix_b = cos(angle * 4.0 + radius * 15.0 - time * 3.0);
353 field = helix_a * 0.38 + helix_b * 0.3 + fbm(point * 6.0 + time * 0.08) * 0.2;
354#elif EFFECT_ID == 18
355 float lotus = pow(max(cos(angle * 9.0 - radius * 13.0 + time * 2.0), 0.0), 5.0);
356 field = lotus * exp(-radius * 1.6) * 0.72;
357 field += sin(radius * (29.0 + bass * 20.0) - time * 7.0) * 0.28;
358#elif EFFECT_ID == 19
359 float tide = sin(point.x * 11.0 + sin(point.y * 8.0 + time) * 3.0);
360 tide *= cos(point.y * 13.0 - cos(point.x * 6.0 - time) * 3.0);
361 field = tide * 0.37 + exp(-radius * 2.4) * 0.3;
362#elif EFFECT_ID == 20
363 vec2 diamond = abs(fract(rotate_2d(PI * 0.25) * point * 9.0) - 0.5);
364 float facets = 1.0 - smoothstep(0.12, 0.28, diamond.x + diamond.y);
365 field = facets * 0.62 + sin(point.y * 25.0 + sin(point.x * 8.0 - time) * 4.0) * 0.27;
366#elif EFFECT_ID == 21
367 vec2 maze = abs(fract((rotate_2d(0.24) * point) * 8.0) - 0.5);
368 float walls = 1.0 - smoothstep(0.04, 0.13, min(maze.x, maze.y));
369 field = walls * 0.62 + cos(angle * 8.0 + floor(radius * 10.0) * 1.7) * 0.25;
370#elif EFFECT_ID == 22
371 float spokes = pow(abs(sin(angle * 12.0 - radius * 18.0 + time * 2.0)), 8.0);
372 field = spokes * exp(-radius * 1.3) * 0.7;
373 field += sin(radius * (25.0 + bass * 22.0) - time * 7.0) * 0.3;
374#elif EFFECT_ID == 23
375 float well = sin(log(radius + 0.035) * (14.0 + bass * 7.0) - angle * 5.0 + time * 4.0);
376 field = well * 0.48 + exp(-radius * 5.0) * 0.5;
377#else
378 float crown = pow(abs(cos(angle * (13.0 + floor(treble * 7.0)) + time)), 12.0);
379 float ring = sin(radius * (37.0 + bass * 24.0) - time * 9.0);
380 field = crown * exp(-radius * 1.7) * 0.72 + ring * 0.32;
381#endif
382
383 return field + (fbm(point * 3.1 - vec2(0.0, time * 0.12)) - 0.5) * 0.12;
384}
385
386vec2 cache_transform(vec2 uv, vec2 center, float age, float bass, float middle, float treble,
387 vec2 flow) {
388 vec2 point = uv - center;
389 float radius = length(point) + 0.0001;
390 vec2 radial = point / radius;
391 float phase = radius * (13.0 + float(EFFECT_ID % 8)) - time_f * (2.0 + bass * 3.0) + age;
392 float wave = sin(phase);
393 float zoom = pow(max(0.958 - bass * 0.09, 0.35), age);
394
395#if EFFECT_ID % 5 == 0
396 point *= zoom;
397 point += radial * wave * age * (0.004 + treble * 0.01);
398 point += flow * age * (0.006 + middle * 0.012);
399#elif EFFECT_ID % 5 == 1
400 point.x += sin(point.y * (12.0 + middle * 8.0) + time_f + age) *
401 age * (0.006 + treble * 0.012);
402 point.y += cos(point.x * 10.0 - time_f * 0.7 - age) *
403 age * (0.005 + bass * 0.01);
404 point *= zoom;
405#elif EFFECT_ID % 5 == 2
406 point += radial * sin(phase + atan(point.y, point.x) * 4.0) *
407 age * (0.008 + middle * 0.014);
408 point *= zoom;
409#elif EFFECT_ID % 5 == 3
410 point.x *= 1.0 + age * (0.009 + treble * 0.012);
411 point.y *= zoom;
412 point += vec2(wave, -wave) * age * 0.004;
413#else
414 vec2 folded = abs(point);
415 folded -= vec2(0.12 + bass * 0.08, 0.09 + middle * 0.07);
416 point = mix(point, sign(point + vec2(0.0001)) * folded, 0.35 + treble * 0.25);
417 point *= zoom;
418 point += radial * wave * age * 0.006;
419#endif
420
421 return mirror_repeat(point + center);
422}
423
424/**
425 * @brief Executes the fragment shader entry point.
426 */
427void main() {
428 vec2 resolution = max(iResolution, vec2(1.0));
429 vec2 texel = 1.0 / resolution;
430 float aspect = resolution.x / resolution.y;
431 vec2 mouse_uv = iMouse.xy / resolution;
432 vec2 center = iMouse.z > 0.0 ? mouse_uv : vec2(0.5);
433 vec2 point = (tc - center) * vec2(aspect, 1.0);
434
435 float global_hue = 0.0;
436 if (iMouse.w > 0.0)
437 global_hue = (mouse_uv.x - 0.5) * 3.0;
438
439 float bass = texture(spectrum0, 0.03).r;
440 float middle = texture(spectrum0, 0.22).r;
441 float treble = texture(spectrum0, 0.58).r;
442 float air = texture(spectrum0, 0.82).r;
443 float field = effect_field(point, bass, middle, treble);
444
445 float pixel = 2.0 / max(max(resolution.x, resolution.y), 360.0);
446 vec2 gradient = vec2(effect_field(point + vec2(pixel, 0.0), bass, middle, treble) - field,
447 effect_field(point + vec2(0.0, pixel), bass, middle, treble) - field) /
448 pixel;
449 vec3 surface_normal = normalize(vec3(-gradient * (0.16 + amp_high * 0.05), 1.0));
450
451 float ripple_x =
452 sin(point.x * (11.0 + float(EFFECT_ID % 7)) + time_f * (4.0 + bass * 3.0));
453 float ripple_y =
454 sin(point.y * (12.0 + float(EFFECT_ID % 6)) + time_f * (3.5 + middle * 2.0));
455 float cross_ripple = sin((point.x + point.y) * (8.0 + float(EFFECT_ID % 5)) -
456 time_f * (2.5 + treble * 3.0));
457 vec2 wave_distortion =
458 vec2(ripple_x + cross_ripple * 0.6, ripple_y - cross_ripple * 0.6) *
459 (0.008 + bass * 0.018);
460 wave_distortion += surface_normal.xy * (0.012 + amp_low * 0.025);
461 vec2 live_uv = mirror_repeat(tc + wave_distortion);
462
463 vec3 sharp = texture(samp, live_uv).rgb;
464 vec3 softened = soft_sample(samp, live_uv, texel, 1.0 + middle * 3.0).rgb;
465 float dispersion = 0.003 + treble * 0.014;
466 vec3 refracted = vec3(texture(samp, mirror_repeat(live_uv + surface_normal.xy * dispersion)).r,
467 softened.g,
468 texture(samp, mirror_repeat(live_uv - surface_normal.xy * dispersion)).b);
469 vec3 live = mix(sharp, refracted, 0.48 + amp_smooth * 0.15);
470
471 float luminance = dot(live, vec3(0.299, 0.587, 0.114));
472 vec3 live_palette = acid_palette(field + time_f * 0.025 + bass, global_hue);
473 vec3 scaled_live = color_scale(live, live_palette, bass * 0.5 + middle * 0.3 + treble * 0.2);
474 vec3 mapped = 0.5 + 0.5 * cos(clamp(scaled_live, 0.0, 1.0) * PI * 0.5 +
475 live_palette);
476 vec3 accumulated = mix(scaled_live, mapped * (0.45 + luminance), 0.44);
477 accumulated += acid_palette(field * 0.55 + time_f * 0.04, global_hue) *
478 pow(max(0.0, 1.0 - surface_normal.z), 2.0) * 0.7;
479 float total_weight = 1.0;
480
481 for (int index = 0; index < 8; ++index) {
482 float age = float(index + 1);
483 float old_bass = sample_history(index, 0.03);
484 float old_middle = sample_history(index, 0.22);
485 float old_treble = sample_history(index, 0.58);
486 float old_air = sample_history(index, 0.82);
487 vec2 history_uv =
488 cache_transform(tc, center, age, old_bass, old_middle, old_treble, surface_normal.xy);
489 vec3 history = sample_cache(index, history_uv).rgb;
490 float old_energy =
491 old_bass * 0.45 + old_middle * 0.28 + old_treble * 0.17 + old_air * 0.10;
492 vec3 history_tint =
493 acid_palette(field * 0.12 + age * 0.061 + old_energy * 0.7, global_hue);
494 vec3 cache_scale = vec3(1.0 + age * 0.035 + old_middle * 0.22,
495 1.0 - age * 0.021 + old_bass * 0.12,
496 1.0 + age * 0.016 + old_air * 0.28);
497 history = color_scale(history * max(cache_scale, vec3(0.05)), history_tint, old_energy);
498 float weight = pow(0.77, age);
499 accumulated += history * weight;
500 total_weight += weight;
501 }
502
503 accumulated /= total_weight;
504 float crest = pow(max(sin(field * 19.0 - time_f * 2.4), 0.0), 7.0);
505 accumulated += acid_palette(field + time_f * 0.09, global_hue) * crest *
506 (0.25 + air * 1.35);
507 accumulated = (accumulated - 0.5) * (1.08 + amp_smooth * 0.28) + 0.5;
508 accumulated = mix(accumulated, vec3(1.0) - accumulated, smoothstep(0.91, 1.0, amp_peak));
509
510 color = vec4(tone_map(accumulated), texture(samp, live_uv).a);
511}
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
vec2 cache_transform(vec2 uv, vec2 center, float age, float bass, float middle, float treble, vec2 flow)
Evaluates cache transform for this shader effect.
vec4 soft_sample(sampler2D image, vec2 uv, vec2 texel, float spread)
Evaluates soft sample for this shader effect.
vec2 kaleidoscope(vec2 point, float sides)
Evaluates kaleidoscope for this shader effect.
float fbm(vec2 point)
Evaluates fbm for this shader effect.
#define amp_smooth
#define CACHE_HISTORY_LAYER(index)
float value_noise(vec2 point)
Evaluates value noise for this shader effect.
vec2 hex_cell(vec2 point)
Evaluates hex cell for this shader effect.
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.
float hash_21(vec2 point)
Evaluates hash 21 for this shader effect.
#define amp_low
#define amp_high
#define SPECTRUM_HISTORY_LAYER(index)
float ping_pong(float value, float size)
Evaluates ping pong for this shader effect.
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.
float effect_field(vec2 point, float bass, float middle, float treble)
Evaluates effect field for this shader effect.
#define EFFECT_ID
#define amp_peak
vec3 tone_map(vec3 value)
Evaluates tone map for this shader effect.
vec3 wave(ivec2 p, ivec2 size)
Evaluates wave for this shader effect.
vec3 color_scale(vec3 video, vec3 acid_color, float energy)
Evaluates color scale for this shader effect.
vec3 acid_palette(float phase, float hue_offset)
Evaluates acid palette for this shader effect.
float energy()
Evaluates energy for this shader effect.
vec3 aurora(float t)
Evaluates aurora for this shader effect.
vec3 crystal(float t)
Evaluates crystal 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.
vec2 cell(vec2 p)
Evaluates cell for this shader effect.
#define TAU
#define PI
float diamond(vec2 p)
Evaluates diamond for this shader effect.
Definition dmd_gpt.frag:29
vec2 fold(vec2 uv, float zoom, float t, vec2 c, float aspect)
Evaluates fold for this shader effect.
#define frequency
Definition ol.frag:13