ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_spectrum_diamond_echo.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_diamond_echo.frag
20 * @brief Vulkan fragment shader: ant spectrum diamond echo.
21 */
22// ant_spectrum_diamond_echo
23// Diamond-fold kaleidoscope with cascading echo reflections and gradient glow
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 rot for this shader effect.
46 * @param a Input value for the calculation.
47 * @return Computed mat2 value.
48 */
49mat2 rot(float a) {
50 float s = sin(a), c = cos(a);
51 return mat2(c, -s, s, c);
52}
53
54/**
55 * @brief Evaluates diamondFold for this shader effect.
56 * @param p Input value for the calculation.
57 * @return Computed vec2 value.
58 */
59vec2 diamondFold(vec2 p) {
60 p = abs(p);
61 if (p.y > p.x) p = p.yx;
62 return p;
63}
64
65/**
66 * @brief Evaluates mirror for this shader effect.
67 * @param uv Input value for the calculation.
68 * @return Computed vec2 value.
69 */
70vec2 mirror(vec2 uv) {
71 vec2 m = mod(uv, 2.0);
72 return mix(m, 2.0 - m, step(1.0, m));
73}
74
75/**
76 * @brief Executes the fragment shader entry point.
77 */
78void main() {
79 float bass = texture(spectrum, 0.03).r;
80 float mid = texture(spectrum, 0.22).r;
81 float hiMid = texture(spectrum, 0.40).r;
82 float treble = texture(spectrum, 0.58).r;
83 float air = texture(spectrum, 0.78).r;
84
85 float aspect = iResolution.x / iResolution.y;
86 vec2 uv = (tc - 0.5) * vec2(aspect, 1.0);
87
88 // Multi-pass diamond fold
89 vec2 p = uv;
90 for (int i = 0; i < 5; i++) {
91 p = diamondFold(p);
92 p = p * (1.2 + bass * 0.2) - 0.3;
93 p *= rot(iTime * 0.08 + float(i) * 0.4 + mid * 0.3);
94 }
95
96 // Echo cascade: each echo at different fold depth
97 vec3 result = vec3(0.0);
98 float totalW = 0.0;
99 for (float e = 0.0; e < 6.0; e++) {
100 vec2 ep = uv;
101 for (int i = 0; i < 5; i++) {
102 ep = diamondFold(ep);
103 ep = ep * (1.2 + bass * 0.2 + e * 0.02) - 0.3;
104 ep *= rot(iTime * 0.08 + float(i) * 0.4 + mid * 0.3 + e * 0.05);
105 }
106 vec2 texUV = mirror(ep * 0.5 + 0.5);
107 vec3 s = texture(samp, texUV).rgb;
108 s *= rainbow(e * 0.16 + iTime * 0.3 + hiMid);
109 float w = 1.0 / (1.0 + e * 0.5);
110 result += s * w;
111 totalW += w;
112 }
113 result /= totalW;
114
115 // Diamond glow pattern
116 float dGlow = length(p);
117 vec3 grad = rainbow(dGlow + iTime * 0.4 + bass * 2.0);
118 result = mix(result, result * grad * 1.3, 0.3 + treble * 0.2);
119
120 // Color shift
121 result = mix(result, result.brg, smoothstep(0.3, 0.7, sin(iTime * 0.6)));
122
123 // Air shimmer
124 result += air * 0.08 * rainbow(iTime * 0.4 + length(uv));
125
126 result = mix(result, vec3(1.0) - result, smoothstep(0.9, 1.0, amp_peak));
127 color = vec4(result, 1.0);
128}
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 iResolution
Definition 3high.frag:18
#define amp_peak
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
Definition air-bowl.frag:52
vec2 mirror(vec2 uv)
Evaluates mirror for this shader effect.
vec3 rainbow(float t)
Evaluates rainbow for this shader effect.
vec2 diamondFold(vec2 p)
Evaluates diamondFold for this shader effect.
#define PI
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.