ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_cache_spectrum8_geometric_polar.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 history_head int(ext.u3.x)
16#define iResolution ext.u0.zw
17#define iTime ext.u0.y
18#define spectrum_history_head int(ext.audio_history.x)
19#define spectrum_history_size int(ext.audio_history.y)
20
21/**
22 * @file ant_cache_spectrum8_geometric_polar.frag
23 * @brief Vulkan fragment shader: ant cache spectrum8 geometric polar.
24 */
25// ant_cache_spectrum8_geometric_polar
26// Holographic fringe x geometric2 polar sin/cos lattice modulated by spectrum slots
27// Audio history (spectrum0..7) + Frame cache history (samp,samp1..samp8) - EXTREME
28layout(location = 0) in vec2 tc;
29layout(location = 0) out vec4 color;
30layout(set = 0, binding = 0) uniform sampler2D samp;
31layout(set = 0, binding = 2) uniform sampler2DArray history;
32
33#ifndef SIZE
34#define SIZE 8
35#endif
36#ifndef CACHE_HISTORY_LAYER
37#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
38#endif
39layout(set = 0, binding = 3) uniform sampler1D spectrum0;
40layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
41
42
43#ifndef SPECTRUM_HISTORY_LAYER
44#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
45#endif
46
47
48
49
50
51const float TAU = 6.28318530718;
52
53/**
54 * @brief Evaluates specHist for this shader effect.
55 * @param i Input value for the calculation.
56 * @param f Input value for the calculation.
57 * @return Computed float value.
58 */
59float specHist(int i, float f) {
60 if (i == 0) return texture(spectrum0, f).r;
61 if (i == 1) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(1)))).r;
62 if (i == 2) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(2)))).r;
63 if (i == 3) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(3)))).r;
64 if (i == 4) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(4)))).r;
65 if (i == 5) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(5)))).r;
66 if (i == 6) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(6)))).r;
67 return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(7)))).r;
68}
69
70/**
71 * @brief Evaluates cacheHist for this shader effect.
72 * @param i Input value for the calculation.
73 * @param uv Input value for the calculation.
74 * @return Computed vec4 value.
75 */
76vec4 cacheHist(int i, vec2 uv) {
77 if (i == 0) return texture(samp, uv);
78 if (i == 1) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(0))));
79 if (i == 2) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(1))));
80 if (i == 3) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(2))));
81 if (i == 4) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(3))));
82 if (i == 5) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(4))));
83 if (i == 6) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(5))));
84 if (i == 7) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(6))));
85 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(7))));
86}
87
88/**
89 * @brief Evaluates palette for this shader effect.
90 * @param t Input value for the calculation.
91 * @param d Input value for the calculation.
92 * @return Computed vec3 value.
93 */
94vec3 palette(float t, vec3 d) {
95 return 0.5 + 0.5 * cos(TAU * (vec3(1.0) * t + d));
96}
97
98/**
99 * @brief Executes the fragment shader entry point.
100 */
101void main() {
102 float aspect = iResolution.x / iResolution.y;
103 vec2 uv = (tc - 0.5) * vec2(aspect, 1.0);
104 float rad = length(uv);
105 float theta = atan(uv.y, uv.x);
106
107 vec3 acc = vec3(0.0);
108 vec3 lattice = vec3(0.0);
109 for (int i = 0; i < 8; i++) {
110 float h = specHist(i, 0.05 + float(i) * 0.06);
111 float h2 = specHist(i, 0.55);
112
113 // Holographic fringe + sample
114 float ang = float(i) * 0.4 + h2 * 3.0;
115 vec2 dir = vec2(cos(ang), sin(ang));
116 float fringe = sin(dot(uv, dir) * (40.0 + h * 80.0) + iTime * (1.0 + h * 4.0));
117 fringe = pow(fringe * 0.5 + 0.5, 4.0);
118 vec2 suv = tc + dir * fringe * 0.04 * (1.0 + h);
119
120 vec3 c;
121 c.r = cacheHist(i, suv + vec2(h * 0.08, 0.0)).r;
122 c.g = cacheHist(i, suv).g;
123 c.b = cacheHist(i, suv - vec2(h * 0.08, 0.0)).b;
124 vec3 tint = palette(float(i) * 0.13 + h * 4.0, vec3(0.0, 0.33, 0.66));
125 acc += (c + tint * fringe * 0.4) * (1.0 + h * 5.0) * pow(0.83, float(i));
126
127 // Polar lattice per slot - sin(N*theta) * cos(N*r)
128 float N = 6.0 + float(i) * 2.0;
129 float pat = abs(sin(N * theta + iTime * 0.5 + h * 4.0)
130 * cos(N * rad - iTime * 0.7 + h2 * 4.0));
131 lattice += tint * pat * (0.18 + h * 0.6);
132 }
133 acc /= 3.0;
134 lattice /= 4.0;
135 vec3 outc = acc + lattice * (0.6 + amp_peak * 1.2);
136 outc *= 1.25 + amp_smooth * 1.1;
137 // sin() coloring nod from geometric2
138 outc = mix(outc, abs(sin(outc * (1.5 + amp_peak))), 0.18);
139 color = vec4(clamp(outc, 0.0, 1.0), 1.0);
140}
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_smooth
#define CACHE_HISTORY_LAYER(index)
vec3 palette(float phase)
Evaluates palette for this shader effect.
#define SPECTRUM_HISTORY_LAYER(index)
#define amp_peak
vec2 h2(vec2 p)
Evaluates h2 for this shader effect.
Definition air-bowl.frag:45
float specHist(int i, float f)
Evaluates specHist for this shader effect.
vec4 cacheHist(int i, vec2 uv)
Evaluates cacheHist for this shader effect.
float h(vec2 p)
Evaluates h for this shader effect.
float N(vec2 p)
Evaluates N for this shader effect.
#define TAU
float lattice(vec2 point, float bass, float middle, float high)
Evaluates lattice for this shader effect.