ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_cache_spectrum8_mirror_tile_rotor.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_mirror_tile_rotor.frag
23 * @brief Vulkan fragment shader: ant cache spectrum8 mirror tile rotor.
24 */
25// ant_cache_spectrum8_mirror_tile_rotor
26// Holographic fringe x mirror_c tiled-section rotation kaleidoscope (per cache slot)
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 Evaluates rot for this shader effect.
100 * @param a Input value for the calculation.
101 * @return Computed mat2 value.
102 */
103mat2 rot(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }
104/**
105 * @brief Evaluates mir for this shader effect.
106 * @param v Input value for the calculation.
107 * @return Computed vec2 value.
108 */
109vec2 mir(vec2 v) { return abs(mod(v, 2.0) - 1.0); }
110
111/**
112 * @brief Executes the fragment shader entry point.
113 */
114void main() {
115 float aspect = iResolution.x / iResolution.y;
116 vec2 uv = (tc - 0.5) * vec2(aspect, 1.0);
117
118 vec3 acc = vec3(0.0);
119 for (int i = 0; i < 8; i++) {
120 float h = specHist(i, 0.05 + float(i) * 0.06);
121 float h2 = specHist(i, 0.55);
122
123 // Tiled rotor sections per slot - tile size shrinks with slot
124 vec2 px = tc * iResolution.xy;
125 vec2 sectionSize = vec2(120.0 - float(i) * 10.0);
126 vec2 sIdx = floor(px / sectionSize);
127 vec2 lUV = mod(px, sectionSize) / sectionSize;
128 float ang = iTime * (0.3 + h * 1.5) + length(sIdx) * (0.4 + h2 * 0.6) + float(i) * 0.5;
129 lUV = rot(ang) * (lUV - 0.5) + 0.5;
130 lUV = mir(lUV);
131 vec2 suv = (sIdx + lUV) * sectionSize / iResolution.xy;
132
133 // Holographic fringe shift atop tile
134 float fAng = float(i) * 0.4 + h2 * 3.0;
135 vec2 dir = vec2(cos(fAng), sin(fAng));
136 float fringe = sin(dot(uv, dir) * (40.0 + h * 80.0) + iTime * (1.0 + h * 4.0));
137 fringe = pow(fringe * 0.5 + 0.5, 4.0);
138 suv += dir * fringe * 0.03 * (1.0 + h);
139
140 vec3 c;
141 c.r = cacheHist(i, suv + vec2(h * 0.06, 0.0)).r;
142 c.g = cacheHist(i, suv).g;
143 c.b = cacheHist(i, suv - vec2(h * 0.06, 0.0)).b;
144
145 vec3 tint = palette(float(i) * 0.13 + h * 4.0, vec3(0.0, 0.33, 0.66));
146 acc += (c + tint * fringe * 0.5) * (1.0 + h * 5.0) * pow(0.83, float(i));
147 }
148 acc /= 3.0;
149 acc *= 1.3 + amp_smooth * 1.2;
150 color = vec4(clamp(acc, 0.0, 1.0), 1.0);
151}
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)
vec2 h2(vec2 p)
Evaluates h2 for this shader effect.
Definition air-bowl.frag:45
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
Definition air-bowl.frag:52
float specHist(int i, float f)
Evaluates specHist for this shader effect.
vec4 cacheHist(int i, vec2 uv)
Evaluates cacheHist for this shader effect.
vec2 mir(vec2 v)
Evaluates mir for this shader effect.
float h(vec2 p)
Evaluates h for this shader effect.
#define TAU