ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_cache_spectrum8_liquid_light.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_liquid_light.frag
23 * @brief Vulkan fragment shader: ant cache spectrum8 liquid light.
24 */
25// ant_cache_spectrum8_liquid_light
26// Holographic interference fused with Liquid Light Rainbow fluid FBM warp + chromatic aberration
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;
52const float PI = 3.14159265359;
53
54/**
55 * @brief Evaluates specHist for this shader effect.
56 * @param i Input value for the calculation.
57 * @param f Input value for the calculation.
58 * @return Computed float value.
59 */
60float specHist(int i, float f) {
61 if (i == 0) return texture(spectrum0, f).r;
62 if (i == 1) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(1)))).r;
63 if (i == 2) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(2)))).r;
64 if (i == 3) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(3)))).r;
65 if (i == 4) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(4)))).r;
66 if (i == 5) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(5)))).r;
67 if (i == 6) return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(6)))).r;
68 return texture(spectrum_history, vec2(f, float(SPECTRUM_HISTORY_LAYER(7)))).r;
69}
70
71/**
72 * @brief Evaluates cacheHist for this shader effect.
73 * @param i Input value for the calculation.
74 * @param uv Input value for the calculation.
75 * @return Computed vec4 value.
76 */
77vec4 cacheHist(int i, vec2 uv) {
78 if (i == 0) return texture(samp, uv);
79 if (i == 1) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(0))));
80 if (i == 2) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(1))));
81 if (i == 3) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(2))));
82 if (i == 4) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(3))));
83 if (i == 5) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(4))));
84 if (i == 6) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(5))));
85 if (i == 7) return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(6))));
86 return texture(history, vec3(uv, float(CACHE_HISTORY_LAYER(7))));
87}
88
89/**
90 * @brief Evaluates palette for this shader effect.
91 * @param t Input value for the calculation.
92 * @param d Input value for the calculation.
93 * @return Computed vec3 value.
94 */
95vec3 palette(float t, vec3 d) {
96 return 0.5 + 0.5 * cos(TAU * (vec3(1.0) * t + d));
97}
98
99/**
100 * @brief Evaluates hash for this shader effect.
101 * @param p Input value for the calculation.
102 * @return Computed float value.
103 */
104float hash(vec2 p) {
105 return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
106}
107
108/**
109 * @brief Evaluates vnoise for this shader effect.
110 * @param p Input value for the calculation.
111 * @return Computed float value.
112 */
113float vnoise(vec2 p) {
114 vec2 i = floor(p), f = fract(p);
115 vec2 u = f * f * (3.0 - 2.0 * f);
116 return mix(mix(hash(i), hash(i + vec2(1, 0)), u.x),
117 mix(hash(i + vec2(0, 1)), hash(i + vec2(1, 1)), u.x), u.y);
118}
119
120/**
121 * @brief Evaluates fbm for this shader effect.
122 * @param p Input value for the calculation.
123 * @return Computed float value.
124 */
125float fbm(vec2 p) {
126 float v = 0.0, a = 0.5;
127 mat2 r = mat2(0.87758, 0.47943, -0.47943, 0.87758);
128 for (int k = 0; k < 5; k++) { v += a * vnoise(p); p = r * p * 2.02; a *= 0.5; }
129 return v;
130}
131
132/**
133 * @brief Evaluates sampleLiquidSlot for this shader effect.
134 * @param i Input value for the calculation.
135 * @param uv Input value for the calculation.
136 * @param t Input value for the calculation.
137 * @param h Input value for the calculation.
138 * @param h2 Input value for the calculation.
139 * @return Computed vec3 value.
140 */
141vec3 sampleLiquidSlot(int i, vec2 uv, float t, float h, float h2) {
142 vec2 p = uv - 0.5;
143 p.x *= iResolution.x / iResolution.y;
144 vec2 q = vec2(fbm(p + vec2(0.0, 0.0) + 0.05 * t),
145 fbm(p + vec2(5.2, 1.3) + 0.05 * t));
146 vec2 r = vec2(fbm(p + 4.0 * q + vec2(t * 0.2)),
147 fbm(p + 4.0 * q + vec2(t * 0.1, 2.8)));
148 vec2 fluid = uv + r * (0.18 + h * 0.35);
149
150 // Holographic fringe
151 float ang = float(i) * 0.4 + h2 * 3.0;
152 vec2 dir = vec2(cos(ang), sin(ang));
153 float fringe = sin(dot(p, dir) * (40.0 + h * 80.0) + t * (1.0 + h * 4.0));
154 fringe = pow(fringe * 0.5 + 0.5, 4.0);
155 fluid += dir * fringe * 0.04 * (1.0 + h);
156
157 vec3 c;
158 c.r = cacheHist(i, fluid + vec2(h * 0.012, 0.0)).r;
159 c.g = cacheHist(i, fluid).g;
160 c.b = cacheHist(i, fluid - vec2(h * 0.012, 0.0)).b;
161
162 vec3 neon = palette(length(q) + length(r) + float(i) * 0.13, vec3(0.0, 0.33, 0.66));
163 return c * neon * 2.2 + neon * fringe * 0.4;
164}
165
166/**
167 * @brief Executes the fragment shader entry point.
168 */
169void main() {
170 float t = iTime * 0.6;
171 vec3 acc = vec3(0.0);
172 for (int i = 0; i < 8; i++) {
173 float h = specHist(i, 0.05 + float(i) * 0.06);
174 float h2 = specHist(i, 0.55);
175 acc += sampleLiquidSlot(i, tc, t + float(i) * 0.7, h, h2) * pow(0.83, float(i));
176 }
177 acc /= 3.0;
178 acc *= 1.25 + amp_smooth * 1.1;
179
180 // Deep purple vignette from liquid_light
181 vec2 vUV = tc * (1.0 - tc.yx);
182 float vig = pow(vUV.x * vUV.y * 15.0, 0.2);
183 acc = mix(vec3(0.05, 0.0, 0.1), acc * vig, vig);
184
185 color = vec4(clamp(acc, 0.0, 1.0), 1.0);
186}
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
float fbm(vec2 point)
Evaluates fbm for this shader effect.
#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
float hash(vec2 p)
Evaluates hash for this shader effect.
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 vnoise(vec2 p)
Evaluates vnoise for this shader effect.
vec3 sampleLiquidSlot(int i, vec2 uv, float t, float h, float h2)
Evaluates sampleLiquidSlot for this shader effect.
vec3 neon(float t)
Evaluates neon for this shader effect.
float h(vec2 p)
Evaluates h for this shader effect.
#define TAU
#define PI