ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
frac_shader02_dmd6i_air.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file frac_shader02_dmd6i_air.frag
5 * @brief Vulkan fragment shader: frac shader02 dmd6i air.
6 */
7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
8 vec4 mouse;
9 vec4 u0;
10 vec4 u1;
11 vec4 u2;
12 vec4 u3;
13 vec4 custom_uniforms[16];
14 vec4 audio_bands;
15 vec4 audio_history;
17#define amp ext.u1.y
18#define amp_high ext.audio_bands.z
19#define amp_low ext.audio_bands.x
20#define amp_mid ext.audio_bands.y
21#define amp_peak ext.u2.w
22#define amp_rms ext.u3.z
23#define amp_smooth ext.u3.w
24#define iMouse ext.mouse
25#define iResolution ext.u0.zw
26#define iamp ext.u1.z
27#define seed ext.custom_uniforms[2].z
28#define time_f ext.u2.y
29#define uamp ext.u1.y
30
31layout(location = 0) out vec4 color;
32layout(location = 0) in vec2 tc;
33layout(set = 0, binding = 0) uniform sampler2D samp;
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48const float PI = 3.1415926535897932384626433832795;
49
50/**
51 * @brief Evaluates pingPong for this shader effect.
52 * @param x Input value for the calculation.
53 * @param length Input value for the calculation.
54 * @return Computed float value.
55 */
56float pingPong(float x, float length) {
57 float m = mod(x, length * 2.0);
58 return m <= length ? m : length * 2.0 - m;
59}
60
61/**
62 * @brief Evaluates hsv2rgb for this shader effect.
63 * @param c Input value for the calculation.
64 * @return Computed vec3 value.
65 */
66vec3 hsv2rgb(vec3 c) {
67 vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
68 vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
69 return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
70}
71
72/**
73 * @brief Evaluates rotateUV for this shader effect.
74 * @param uv Input value for the calculation.
75 * @param angle Input value for the calculation.
76 * @param c Input value for the calculation.
77 * @param aspect Input value for the calculation.
78 * @return Computed vec2 value.
79 */
80vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect) {
81 float s = sin(angle), cc = cos(angle);
82 vec2 p = uv - c;
83 p.x *= aspect;
84 p = mat2(cc, -s, s, cc) * p;
85 p.x /= aspect;
86 return p + c;
87}
88
89/**
90 * @brief Evaluates reflectUV for this shader effect.
91 * @param uv Input value for the calculation.
92 * @param segments Input value for the calculation.
93 * @param c Input value for the calculation.
94 * @param aspect Input value for the calculation.
95 * @return Computed vec2 value.
96 */
97vec2 reflectUV(vec2 uv, float segments, vec2 c, float aspect) {
98 vec2 p = uv - c;
99 p.x *= aspect;
100 float ang = atan(p.y, p.x);
101 float rad = length(p);
102 float stepA = 6.28318530718 / segments;
103 ang = mod(ang, stepA);
104 ang = abs(ang - stepA * 0.5);
105 vec2 r = vec2(cos(ang), sin(ang)) * rad;
106 r.x /= aspect;
107 return r + c;
108}
109
110/**
111 * @brief Evaluates fractalFold for this shader effect.
112 * @param uv Input value for the calculation.
113 * @param zoom Input value for the calculation.
114 * @param t Input value for the calculation.
115 * @param c Input value for the calculation.
116 * @param aspect Input value for the calculation.
117 * @return Computed vec2 value.
118 */
119vec2 fractalFold(vec2 uv, float zoom, float t, vec2 c, float aspect) {
120 vec2 p = uv;
121 for (int i = 0; i < 6; i++) {
122 p = abs((p - c) * (zoom + 0.15 * sin(t * (0.35 + amp_low * 0.2) + float(i)))) - 0.5 + c;
123 p = rotateUV(p, t * 0.12 + float(i) * 0.07, c, aspect);
124 }
125 return p;
126}
127
128/**
129 * @brief Evaluates neonPalette for this shader effect.
130 * @param t Input value for the calculation.
131 * @return Computed vec3 value.
132 */
133vec3 neonPalette(float t) {
134 vec3 pink = vec3(1.0, 0.15, 0.75);
135 vec3 blue = vec3(0.10, 0.55, 1.0);
136 vec3 green = vec3(0.10, 1.00, 0.45);
137 float ph = fract(t * 0.08);
138 vec3 k1 = mix(pink, blue, smoothstep(0.00, 0.33, ph));
139 vec3 k2 = mix(blue, green, smoothstep(0.33, 0.66, ph));
140 vec3 k3 = mix(green, pink, smoothstep(0.66, 1.00, ph));
141 float a = step(ph, 0.33);
142 float b = step(0.33, ph) * step(ph, 0.66);
143 float c = step(0.66, ph);
144 return normalize(a * k1 + b * k2 + c * k3) * 1.05;
145}
146
147/**
148 * @brief Evaluates softTone for this shader effect.
149 * @param c Input value for the calculation.
150 * @return Computed vec3 value.
151 */
152vec3 softTone(vec3 c) {
153 c = pow(max(c, 0.0), vec3(0.95));
154 float l = dot(c, vec3(0.299, 0.587, 0.114));
155 c = mix(vec3(l), c, 0.9);
156 return clamp(c, 0.0, 1.0);
157}
158
159/**
160 * @brief Evaluates tentBlur3 for this shader effect.
161 * @param img Input value for the calculation.
162 * @param uv Input value for the calculation.
163 * @param res Input value for the calculation.
164 * @return Computed vec3 value.
165 */
166vec3 tentBlur3(sampler2D img, vec2 uv, vec2 res) {
167 vec2 ts = 1.0 / res;
168 vec3 s00 = textureGrad(img, uv + ts * vec2(-1.0, -1.0), dFdx(uv), dFdy(uv)).rgb;
169 vec3 s10 = textureGrad(img, uv + ts * vec2(0.0, -1.0), dFdx(uv), dFdy(uv)).rgb;
170 vec3 s20 = textureGrad(img, uv + ts * vec2(1.0, -1.0), dFdx(uv), dFdy(uv)).rgb;
171 vec3 s01 = textureGrad(img, uv + ts * vec2(-1.0, 0.0), dFdx(uv), dFdy(uv)).rgb;
172 vec3 s11 = textureGrad(img, uv, dFdx(uv), dFdy(uv)).rgb;
173 vec3 s21 = textureGrad(img, uv + ts * vec2(1.0, 0.0), dFdx(uv), dFdy(uv)).rgb;
174 vec3 s02 = textureGrad(img, uv + ts * vec2(-1.0, 1.0), dFdx(uv), dFdy(uv)).rgb;
175 vec3 s12 = textureGrad(img, uv + ts * vec2(0.0, 1.0), dFdx(uv), dFdy(uv)).rgb;
176 vec3 s22 = textureGrad(img, uv + ts * vec2(1.0, 1.0), dFdx(uv), dFdy(uv)).rgb;
177 return (s00 + 2.0 * s10 + s20 + 2.0 * s01 + 4.0 * s11 + 2.0 * s21 + s02 + 2.0 * s12 + s22) / 16.0;
178}
179
180/**
181 * @brief Evaluates preBlendColor for this shader effect.
182 * @param uv Input value for the calculation.
183 * @param tSlow Input value for the calculation.
184 * @param tFast Input value for the calculation.
185 * @param aspect Input value for the calculation.
186 * @return Computed vec3 value.
187 */
188vec3 preBlendColor(vec2 uv, float tSlow, float tFast, float aspect) {
189 vec3 tex = tentBlur3(samp, uv, iResolution);
190 vec2 gdir = normalize(vec2(cos(tSlow * 0.27), sin(tSlow * 0.31)));
191 float s = dot((uv - 0.5) * vec2(aspect, 1.0), gdir);
192 float w = max(fwidth(s) * 4.0, 0.002);
193 float band = smoothstep(-0.5 - w, -0.5 + w, sin(s * 2.2 + tFast * 0.9));
194 vec3 neon = neonPalette(tFast);
195 vec3 grad = mix(tex, mix(tex, neon, 0.6), 0.35 + 0.25 * band);
196 grad = mix(grad, tex, 0.10);
197 grad = softTone(grad);
198 return grad;
199}
200
201/**
202 * @brief Evaluates diamondRadius for this shader effect.
203 * @param p Input value for the calculation.
204 * @return Computed float value.
205 */
206float diamondRadius(vec2 p) {
207 p = sin(abs(p));
208 return max(p.x, p.y);
209}
210
211/**
212 * @brief Evaluates diamondFold for this shader effect.
213 * @param uv Input value for the calculation.
214 * @param c Input value for the calculation.
215 * @param aspect Input value for the calculation.
216 * @return Computed vec2 value.
217 */
218vec2 diamondFold(vec2 uv, vec2 c, float aspect) {
219 vec2 p = (uv - c) * vec2(aspect, 1.0);
220 p = abs(p);
221 if (p.y > p.x) p = p.yx;
222 p.x /= aspect;
223 return p + c;
224}
225
226/**
227 * @brief Evaluates rot2 for this shader effect.
228 * @param v Input value for the calculation.
229 * @param a Input value for the calculation.
230 * @return Computed vec2 value.
231 */
232vec2 rot2(vec2 v, float a){
233 float c = cos(a), s = sin(a);
234 return vec2(c*v.x - s*v.y, s*v.x + c*v.y);
235}
236
237/**
238 * @brief Evaluates h2 for this shader effect.
239 * @param p Input value for the calculation.
240 * @return Computed vec2 value.
241 */
242vec2 h2(vec2 p){
243 return fract(sin(vec2(dot(p,vec2(127.1,311.7)),
244 dot(p,vec2(269.5,183.3))))*43758.5453);
245}
246
247/**
248 * @brief Evaluates limitHighlights for this shader effect.
249 * @param c Input value for the calculation.
250 * @return Computed vec3 value.
251 */
252vec3 limitHighlights(vec3 c){
253 float m = max(c.r, max(c.g, c.b));
254 if(m > 0.9) c *= 0.9 / m;
255 return c;
256}
257
258/**
259 * @brief Executes the fragment shader entry point.
260 */
261void main(void) {
262 float a = clamp(amp, 0.0, 1.0);
263 float ua = clamp(uamp, 0.0, 1.0);
264 float aMix = clamp(amp * 0.7 + uamp * 1.3, 0.0, 4.0);
265 float a01 = clamp(aMix / 2.5, 0.0, 1.0);
266
267 float aspect = iResolution.x / iResolution.y;
268 vec2 ar = vec2(aspect, 1.0);
269
270 float tBase = time_f;
271 float tSlow = tBase * mix(0.2, 0.9, a01);
272 float tFast = tBase * mix(0.7, 3.5, a01);
273
274 vec2 m = (iMouse.z > 0.5) ? (iMouse.xy / iResolution)
275 : fract(vec2(0.37 + 0.11 * sin(tSlow*0.63 + seed),
276 0.42 + 0.13 * cos(tSlow*0.57 + seed*2.0)));
277
278 vec4 baseTex = texture(samp, tc);
279
280 vec2 uvForGlow = tc * 2.0 - 1.0;
281 uvForGlow.x *= aspect;
282 float rGlow = pingPong(sin(length(uvForGlow) * tSlow), 5.0);
283 float radius = sqrt(aspect * aspect + 1.0) + 0.5;
284 float glow = smoothstep(radius, radius - 0.25, rGlow);
285
286 vec2 uv = tc;
287 float speedScale = 1.0 + 2.0 * a01 + 3.0 * ua;
288
289 float speedR = 5.0 * speedScale;
290 float speedG = 6.5 * speedScale;
291 float speedB = 4.0 * speedScale;
292 float ampR = 0.03 * (0.7 + 0.6 * a01);
293 float ampG = 0.025 * (0.7 + 0.6 * a01);
294 float ampB = 0.035 * (0.7 + 0.6 * a01);
295 float waveR = 10.0;
296 float waveG = 12.0;
297 float waveB = 8.0;
298
299 float rR = sin(uv.x*waveR + tFast*speedR)*ampR
300 + sin(uv.y*waveR*0.8 + tFast*speedR*1.2)*ampR;
301 float rG = sin(uv.x*waveG*1.5 + tFast*speedG)*ampG
302 + sin(uv.y*waveG*0.3 + tFast*speedG*0.7)*ampG;
303 float rB = sin(uv.x*waveB*0.5 + tFast*speedB)*ampB
304 + sin(uv.y*waveB*1.7 + tFast*speedB*1.3)*ampB;
305
306 vec2 tcR = uv + vec2(rR, rR);
307 vec2 tcG = uv + vec2(rG, -0.5*rG);
308 vec2 tcB = uv + vec2(0.3*rB, rB);
309
310 vec3 pats[4] = vec3[](vec3(1,0,1), vec3(0,1,0), vec3(1,0,0), vec3(0,0,1));
311 float pspd = 4.0;
312 int pidx = int(mod(floor(tBase*pspd + seed*4.0), 4.0));
313 vec3 mir = pats[pidx];
314
315 vec2 dR = tcR - m;
316 vec2 dG = tcG - m;
317 vec2 dB = tcB - m;
318
319 float fallR = smoothstep(0.55, 0.0, length(dR));
320 float fallG = smoothstep(0.55, 0.0, length(dG));
321 float fallB = smoothstep(0.55, 0.0, length(dB));
322
323 float sw = (0.12 + 0.38*ua + 0.25*a);
324 vec2 tangR = rot2(normalize(dR + 1e-4), 1.5707963);
325 vec2 tangG = rot2(normalize(dG + 1e-4), 1.5707963);
326 vec2 tangB = rot2(normalize(dB + 1e-4), 1.5707963);
327
328 vec2 airR = tangR * sw * fallR * (0.06+0.22*a) * (0.6+0.4*cos(uv.y*40.0 + tFast*3.0 + seed));
329 vec2 airG = tangG * sw * fallG * (0.06+0.22*a) * (0.6+0.4*cos(uv.y*38.0 + tFast*3.3 + seed*1.7));
330 vec2 airB = tangB * sw * fallB * (0.06+0.22*a) * (0.6+0.4*cos(uv.y*42.0 + tFast*2.9 + seed*0.9));
331
332 vec2 jit = (h2(uv*vec2(233.3,341.9) + tFast + seed) - 0.5)
333 * (0.0006 + 0.004*ua);
334
335 tcR += airR + jit;
336 tcG += airG + jit;
337 tcB += airB + jit;
338
339 vec2 fR = vec2(mir.r>0.5 ? 1.0 - tcR.x : tcR.x, tcR.y);
340 vec2 fG = vec2(mir.g>0.5 ? 1.0 - tcG.x : tcG.x, tcG.y);
341 vec2 fB = vec2(mir.b>0.5 ? 1.0 - tcB.x : tcB.x, tcB.y);
342
343 float seg = 4.0 + 2.0 * sin(tSlow * 0.33 + a01 * 2.0);
344 vec2 kUV = reflectUV(tc, seg, m, aspect);
345 kUV = diamondFold(kUV, m, aspect);
346 float foldZoom = 1.45 + 0.55 * sin(tSlow * 0.42 + a01 * 3.0);
347 kUV = fractalFold(kUV, foldZoom, tFast, m, aspect);
348 kUV = rotateUV(kUV, tSlow * 0.23 + a01 * 1.1, m, aspect);
349 kUV = diamondFold(kUV, m, aspect);
350
351 vec2 p = (kUV - m) * ar;
352 vec2 q = abs(p);
353 if (q.y > q.x) q = q.yx;
354
355 float base = 1.82 + 0.18 * pingPong(sin(tSlow * 0.2) * (PI * tSlow), 5.0);
356 float period = log(base) * pingPong(tSlow * PI, 5.0);
357 float tz = tSlow * 0.65;
358 float rD = diamondRadius(p) + 1e-6;
359
360 float ang = atan(q.y, q.x) + tz * 0.35
361 + 0.35 * sin(rD * 18.0 + tFast * 0.6);
362 float k = fract((log(rD) - tz) / period);
363 float rw = exp(k * period);
364 vec2 pwrap = vec2(cos(ang), sin(ang)) * rw;
365
366 vec2 u0 = fract(pwrap / ar + m);
367 vec2 u1 = fract((pwrap * 1.045) / ar + m);
368 vec2 u2 = fract((pwrap * 0.955) / ar + m);
369
370 vec2 dirK = normalize(pwrap + 1e-6);
371 vec2 off = dirK * (0.0015 + 0.001 * sin(tFast * 1.3)) * vec2(1.0, 1.0 / aspect);
372
373 float vign = 1.0 - smoothstep(0.75, 1.2, length((tc - m) * ar));
374 vign = mix(0.9, (1.15 + amp_smooth * 0.2), vign);
375
376 vec2 sR = mix(u0, fR, 0.6);
377 vec2 sG = mix(u1, fG, 0.6);
378 vec2 sB = mix(u2, fB, 0.6);
379
380 vec3 rC = preBlendColor(sR + off, tSlow, tFast, aspect);
381 vec3 gC = preBlendColor(sG, tSlow, tFast, aspect);
382 vec3 bC = preBlendColor(sB - off, tSlow, tFast, aspect);
383
384 vec3 kaleidoRGB = vec3(rC.r, gC.g, bC.b);
385
386 float ring = smoothstep(0.0, 0.7, sin(log(rD + 1e-3) * 9.5 + tFast * 1.2));
387 ring = ring * pingPong(tSlow * PI, 5.0);
388 float pulse = 0.5 + 0.5 * sin(tFast * 2.0 + rD * 28.0 + k * 12.0);
389 pulse *= mix(0.4, 1.4, a01);
390
391 vec3 outCol = kaleidoRGB;
392 outCol *= (0.75 + 0.25 * ring) * (0.85 + 0.15 * pulse) * vign;
393
394 vec3 bloom = outCol * outCol * 0.10
395 + pow(max(outCol - 0.6, 0.0), vec3(2.0)) * 0.06;
396
397 float pulseAdd = 0.004 * (0.5 + 0.5 * sin(tFast * 3.7 + seed));
398 outCol += bloom;
399 outCol += pulseAdd * ua;
400
401 outCol = clamp(outCol, vec3(0.0), vec3(1.0));
402 outCol = limitHighlights(outCol);
403
404 vec3 finalRGB = mix(baseTex.rgb, outCol, pingPong(glow * PI, 5.0) * (0.6 + 0.3 * a01));
405 finalRGB = limitHighlights(finalRGB);
406 finalRGB = clamp(finalRGB, 0.0, 1.0);
407
408
409 // --- Audio Reactivity: direct output modulation ---
410 float _ab = clamp(amp_peak, 0.0, 1.0);
411 float _abass = clamp(amp_low, 0.0, 1.0);
412 finalRGB *= 1.0 + _ab * 0.6;
413 finalRGB = mix(finalRGB, finalRGB * vec3(1.0 + _abass * 0.3, 1.0 - _abass * 0.15, 1.0 + clamp(amp_high, 0.0, 1.0) * 0.25), _ab);
414 // --- End Audio Reactivity ---
415
416 color = vec4(finalRGB, baseTex.a);
417}
layout(set=0, binding=1, std140) uniform SpriteExtended
Definition 3high.frag:7
#define iMouse
Definition 3high.frag:17
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 time_f
Definition 3high.frag:19
vec3 limitHighlights(vec3 c)
Evaluates limitHighlights for this shader effect.
#define uamp
Definition abc.frag:21
#define amp
Definition abc.frag:17
#define amp_smooth
#define amp_low
#define amp_high
#define amp_peak
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec2 h2(vec2 p)
Evaluates h2 for this shader effect.
Definition air-bowl.frag:45
#define seed
Definition air-bowl.frag:20
vec2 rot2(vec2 p, float a)
Evaluates rot2 for this shader effect.
vec2 fractalFold(vec2 p, float zoom, float t, int i)
Evaluates fractalFold for this shader effect.
vec2 mir(vec2 v)
Evaluates mir for this shader effect.
vec3 neon(float t)
Evaluates neon for this shader effect.
vec3 bloom(float t)
Evaluates bloom for this shader effect.
vec2 diamondFold(vec2 p)
Evaluates diamondFold for this shader effect.
vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect)
Evaluates rotateUV for this shader effect.
Definition aura2.frag:59
vec3 tentBlur3(sampler2D img, vec2 uv, vec2 res)
Evaluates tentBlur3 for this shader effect.
Definition aura2.frag:145
vec3 neonPalette(float t)
Evaluates neonPalette for this shader effect.
Definition aura2.frag:112
vec2 reflectUV(vec2 uv, float segments, vec2 c, float aspect)
Evaluates reflectUV for this shader effect.
Definition aura2.frag:76
vec3 softTone(vec3 c)
Evaluates softTone for this shader effect.
Definition aura2.frag:131
float diamondRadius(vec2 p)
Evaluates diamondRadius for this shader effect.
Definition aura2.frag:182
vec3 preBlendColor(vec2 uv)
Evaluates preBlendColor for this shader effect.
Definition aura2.frag:164
vec3 hsv2rgb(vec3 c)
Evaluates hsv2rgb for this shader effect.
Definition aura.frag:43
#define PI