ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_spectrum_echo_chamber.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_peak ext.u2.w
14#define amp_smooth ext.u3.w
15#define iResolution ext.u0.zw
16#define iTime ext.u0.y
17
18/**
19 * @file ant_spectrum_echo_chamber.frag
20 * @brief Vulkan fragment shader: ant spectrum echo chamber.
21 */
22// ant_spectrum_echo_chamber
23// Infinite mirrored echo chamber with spectrum-driven depth and gradient colors
24layout(location = 0) in vec2 tc;
25layout(location = 0) out vec4 color;
26layout(set = 0, binding = 0) uniform sampler2D samp;
27
28
29
30
31layout(set = 0, binding = 3) uniform sampler1D spectrum;
32
33const float PI = 3.14159265;
34
35/**
36 * @brief Evaluates rainbow for this shader effect.
37 * @param t Input value for the calculation.
38 * @return Computed vec3 value.
39 */
40vec3 rainbow(float t) {
41 return 0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.33, 0.67)));
42}
43
44/**
45 * @brief Evaluates mirror for this shader effect.
46 * @param uv Input value for the calculation.
47 * @return Computed vec2 value.
48 */
49vec2 mirror(vec2 uv) {
50 vec2 m = mod(uv, 2.0);
51 return mix(m, 2.0 - m, step(1.0, m));
52}
53
54/**
55 * @brief Executes the fragment shader entry point.
56 */
57void main() {
58 float bass = texture(spectrum, 0.04).r;
59 float mid = texture(spectrum, 0.20).r;
60 float hiMid = texture(spectrum, 0.35).r;
61 float treble = texture(spectrum, 0.55).r;
62 float air = texture(spectrum, 0.78).r;
63
64 vec2 uv = tc;
65 vec2 centered = uv - 0.5;
66
67 // Four-way mirror
68 centered = abs(centered);
69 uv = centered + 0.5;
70
71 // Zoom echo: multiple scaled mirror samples
72 vec3 result = vec3(0.0);
73 float totalWeight = 0.0;
74
75 for (float i = 0.0; i < 8.0; i++) {
76 float scale = 1.0 + i * (0.15 + bass * 0.1);
77 float rotation = i * 0.1 * (1.0 + mid);
78 vec2 echoUV = (uv - 0.5);
79 float c = cos(rotation), s = sin(rotation);
80 echoUV = mat2(c, -s, s, c) * echoUV;
81 echoUV = echoUV * scale + 0.5;
82 echoUV = mirror(echoUV);
83
84 float freq = texture(spectrum, i * 0.08 + 0.02).r;
85 vec3 samp_col = texture(samp, echoUV).rgb;
86
87 // Color shift per echo layer
88 float hueOff = i * 0.12 + iTime * 0.2;
89 samp_col *= rainbow(hueOff + freq);
90
91 float w = 1.0 / (1.0 + i * 0.5);
92 result += samp_col * w;
93 totalWeight += w;
94 }
95 result /= totalWeight;
96
97 // Gradient overlay
98 float dist = length(centered);
99 vec3 grad = rainbow(dist * 4.0 + iTime * 0.4);
100 result = mix(result, result * grad, 0.3 + treble * 0.2);
101
102 // Ripple distortion
103 float ripple = sin(dist * 30.0 - iTime * 4.0) * hiMid * 0.02;
104 vec3 rippled = texture(samp, mirror(uv + ripple)).rgb;
105 result = mix(result, rippled, 0.2);
106
107 // Air shimmer
108 result += air * 0.08 * rainbow(iTime + dist * 2.0);
109
110 // Peak
111 result = mix(result, vec3(1.0) - result, smoothstep(0.9, 1.0, amp_peak));
112
113 color = vec4(result, 1.0);
114}
layout(set=0, binding=1, std140) uniform SpriteExtended
Definition 3high.frag:7
ext
Definition 3high.frag:16
void main(void)
Executes the fragment shader entry point.
Definition 3high.frag:47
#define amp_peak
vec3 ripple(ivec2 p, ivec2 size)
Evaluates ripple for this shader effect.
vec2 mirror(vec2 uv)
Evaluates mirror for this shader effect.
vec3 rainbow(float t)
Evaluates rainbow for this shader effect.
#define PI
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.
mat2 rotation(float angle)
Evaluates rotation for this shader effect.