ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
frac_shader02_dmd9i.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file frac_shader02_dmd9i.frag
5 * @brief Vulkan fragment shader: frac shader02 dmd9i.
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_high ext.audio_bands.z
18#define amp_low ext.audio_bands.x
19#define amp_mid ext.audio_bands.y
20#define amp_peak ext.u2.w
21#define amp_rms ext.u3.z
22#define amp_smooth ext.u3.w
23#define iMouse ext.mouse
24#define iResolution ext.u0.zw
25#define iamp ext.u1.z
26#define time_f ext.u2.y
27
28layout(location = 0) out vec4 color;
29layout(location = 0) in vec2 tc;
30layout(set = 0, binding = 0) uniform sampler2D samp;
31
32
33
34
35
36
37
38
39
40
41
42const float PI = 3.1415926535897932384626433832795;
43
44/**
45 * @brief Evaluates pingPong for this shader effect.
46 * @param x Input value for the calculation.
47 * @param length Input value for the calculation.
48 * @return Computed float value.
49 */
50float pingPong(float x, float length) {
51 float m = mod(x, length * 2.0);
52 return m <= length ? m : length * 2.0 - m;
53}
54
55/**
56 * @brief Evaluates hsv2rgb for this shader effect.
57 * @param c Input value for the calculation.
58 * @return Computed vec3 value.
59 */
60vec3 hsv2rgb(vec3 c) {
61 vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
62 vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
63 return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
64}
65
66/**
67 * @brief Evaluates rotateUV for this shader effect.
68 * @param uv Input value for the calculation.
69 * @param angle Input value for the calculation.
70 * @param c Input value for the calculation.
71 * @param aspect Input value for the calculation.
72 * @return Computed vec2 value.
73 */
74vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect) {
75 float s = sin(angle), cc = cos(angle);
76 vec2 p = uv - c;
77 p.x *= aspect;
78 p = mat2(cc, -s, s, cc) * p;
79 p.x /= aspect;
80 return p + c;
81}
82
83/**
84 * @brief Evaluates reflectUV for this shader effect.
85 * @param uv Input value for the calculation.
86 * @param segments Input value for the calculation.
87 * @param c Input value for the calculation.
88 * @param aspect Input value for the calculation.
89 * @return Computed vec2 value.
90 */
91vec2 reflectUV(vec2 uv, float segments, vec2 c, float aspect) {
92 vec2 p = uv - c;
93 p.x *= aspect;
94 float ang = atan(p.y, p.x);
95 float rad = length(p);
96 float stepA = 6.28318530718 / sin(segments * pingPong(time_f, 5.0));
97 ang = mod(ang, stepA);
98 ang = abs(ang - stepA * 0.5);
99 vec2 r = vec2(cos(ang), sin(ang)) * rad;
100 r.x /= aspect;
101 return r + c;
102}
103
104/**
105 * @brief Evaluates fractalFold for this shader effect.
106 * @param uv Input value for the calculation.
107 * @param zoom Input value for the calculation.
108 * @param t Input value for the calculation.
109 * @param c Input value for the calculation.
110 * @param aspect Input value for the calculation.
111 * @return Computed vec2 value.
112 */
113vec2 fractalFold(vec2 uv, float zoom, float t, vec2 c, float aspect) {
114 vec2 p = uv;
115 for (int i = 0; i < 6; i++) {
116 p = abs((p - c) * (sin(pingPong(zoom * time_f * PI, 5.0)) + 0.15 * sin(t * (0.35 + amp_low * 0.2) + float(i)))) - 0.5 + c;
117 p = rotateUV(p, t * 0.12 + float(i) * 0.07, c, aspect);
118 }
119 return p;
120}
121
122/**
123 * @brief Evaluates neonPalette for this shader effect.
124 * @param t Input value for the calculation.
125 * @return Computed vec3 value.
126 */
127vec3 neonPalette(float t) {
128 vec3 pink = vec3(1.0, 0.15, 0.75);
129 vec3 blue = vec3(0.10, 0.55, 1.0);
130 vec3 green = vec3(0.10, 1.00, 0.45);
131 float ph = fract(t * 0.08);
132 vec3 k1 = mix(pink, blue, smoothstep(0.00, 0.33, ph));
133 vec3 k2 = mix(blue, green, smoothstep(0.33, 0.66, ph));
134 vec3 k3 = mix(green, pink, smoothstep(0.66, 1.00, ph));
135 float a = step(ph, 0.33);
136 float b = step(0.33, ph) * step(ph, 0.66);
137 float c = step(0.66, ph);
138 return normalize(a * k1 + b * k2 + c * k3) * 1.05;
139}
140
141/**
142 * @brief Evaluates softTone for this shader effect.
143 * @param c Input value for the calculation.
144 * @return Computed vec3 value.
145 */
146vec3 softTone(vec3 c) {
147 c = pow(max(c, 0.0), vec3(0.95));
148 float l = dot(c, vec3(0.299, 0.587, 0.114));
149 c = mix(vec3(l), c, 0.9);
150 return clamp(c, 0.0, 1.0);
151}
152
153/**
154 * @brief Evaluates tentBlur3 for this shader effect.
155 * @param img Input value for the calculation.
156 * @param uv Input value for the calculation.
157 * @param res Input value for the calculation.
158 * @return Computed vec3 value.
159 */
160vec3 tentBlur3(sampler2D img, vec2 uv, vec2 res) {
161 vec2 ts = 1.0 / res;
162 vec3 s00 = textureGrad(img, uv + ts * vec2(-1.0, -1.0), dFdx(uv), dFdy(uv)).rgb;
163 vec3 s10 = textureGrad(img, uv + ts * vec2(0.0, -1.0), dFdx(uv), dFdy(uv)).rgb;
164 vec3 s20 = textureGrad(img, uv + ts * vec2(1.0, -1.0), dFdx(uv), dFdy(uv)).rgb;
165 vec3 s01 = textureGrad(img, uv + ts * vec2(-1.0, 0.0), dFdx(uv), dFdy(uv)).rgb;
166 vec3 s11 = textureGrad(img, uv, dFdx(uv), dFdy(uv)).rgb;
167 vec3 s21 = textureGrad(img, uv + ts * vec2(1.0, 0.0), dFdx(uv), dFdy(uv)).rgb;
168 vec3 s02 = textureGrad(img, uv + ts * vec2(-1.0, 1.0), dFdx(uv), dFdy(uv)).rgb;
169 vec3 s12 = textureGrad(img, uv + ts * vec2(0.0, 1.0), dFdx(uv), dFdy(uv)).rgb;
170 vec3 s22 = textureGrad(img, uv + ts * vec2(1.0, 1.0), dFdx(uv), dFdy(uv)).rgb;
171 return (s00 + 2.0 * s10 + s20 + 2.0 * s01 + 4.0 * s11 + 2.0 * s21 + s02 + 2.0 * s12 + s22) / 16.0;
172}
173
174/**
175 * @brief Evaluates preBlendColor for this shader effect.
176 * @param uv Input value for the calculation.
177 * @return Computed vec3 value.
178 */
179vec3 preBlendColor(vec2 uv) {
180 vec3 tex = tentBlur3(samp, uv, iResolution);
181 float aspect = iResolution.x / iResolution.y;
182 vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
183 float r = length(p);
184 float t = time_f;
185 vec3 neon = neonPalette(t + r * 1.3);
186 float neonAmt = smoothstep(0.1, 0.8, r);
187 neonAmt = (0.3 + amp_mid * 0.15) + 0.4 * (1.0 - neonAmt);
188 vec3 grad = mix(tex, neon, neonAmt);
189 grad = mix(grad, tex, 0.2);
190 grad = softTone(grad);
191 return grad;
192}
193
194/**
195 * @brief Evaluates diamondRadius for this shader effect.
196 * @param p Input value for the calculation.
197 * @return Computed float value.
198 */
199float diamondRadius(vec2 p) {
200 p = sin(abs(p * (pingPong(time_f * PI, 5.0))));
201 return max(p.x, p.y);
202}
203
204/**
205 * @brief Evaluates diamondFold for this shader effect.
206 * @param uv Input value for the calculation.
207 * @param c Input value for the calculation.
208 * @param aspect Input value for the calculation.
209 * @return Computed vec2 value.
210 */
211vec2 diamondFold(vec2 uv, vec2 c, float aspect) {
212 vec2 p = (uv - c) * vec2(aspect, 1.0);
213 p = abs(p);
214 if (p.y > p.x) p = p.yx;
215 p.x /= aspect;
216 return p + c;
217}
218
219/**
220 * @brief Executes the fragment shader entry point.
221 */
222void main(void) {
223 vec4 baseTex = texture(samp, tc);
224 vec2 uv = tc * 2.0 - 1.0;
225 float aspect = iResolution.x / iResolution.y;
226 uv.x *= aspect;
227 float r = pingPong(sin(length(uv) * time_f), 5.0);
228 float radius = sqrt(aspect * aspect + 1.0) + 0.5;
229 float glow = smoothstep(radius, radius - (0.25 + amp_low * 0.3), r);
230 vec2 m = (iMouse.z > 0.5) ? (iMouse.xy / iResolution) : vec2(0.5);
231 vec2 ar = vec2(aspect, 1.0);
232 vec3 baseCol = preBlendColor(tc);
233 float seg = 4.0 + (2.0 + amp_mid * 2.0) * sin(time_f * 0.33);
234 vec2 kUV = reflectUV(tc, seg, m, aspect);
235 kUV = diamondFold(kUV, m, aspect);
236 float foldZoom = 1.45 + 0.55 * sin(pingPong(time_f * PI, 25.0) * 0.42);
237 kUV = fractalFold(kUV, foldZoom, time_f, m, aspect);
238 kUV = rotateUV(kUV, time_f * (0.23 + amp_low * 0.15), m, aspect);
239 kUV = diamondFold(kUV, m, aspect);
240 vec2 p = (kUV - m) * ar;
241 vec2 q = abs(p);
242 if (q.y > q.x) q = q.yx;
243 float base = 1.82 + 0.18 * pingPong(sin(time_f * 0.2) * (PI * time_f), 5.0);
244 float period = log(base) * pingPong(time_f * PI, 5.0);
245 float tz = time_f * (0.65 + amp_low * 0.3);
246 float rD = diamondRadius(p) + 1e-6;
247 float ang = atan(q.y, q.x) + tz * 0.35 + 0.35 * sin(rD * 18.0 + time_f * 0.6);
248 float k = fract((log(rD) - tz) / period);
249 float rw = exp(k * period);
250 vec2 pwrap = vec2(cos(ang), sin(ang)) * rw;
251 vec2 u0 = fract(pwrap / ar + m);
252 vec2 u1 = fract((pwrap * 1.045) / ar + m);
253 vec2 u2 = fract((pwrap * 0.955) / ar + m);
254 vec2 dir = normalize(pwrap + 1e-6);
255 vec2 off = dir * ((0.0015 + amp_high * 0.002) + 0.001 * sin(time_f * 1.3)) * vec2(1.0, 1.0 / aspect);
256 float vign = 1.0 - smoothstep(0.75, 1.2, length((tc - m) * ar));
257 vign = mix(0.9, (1.15 + amp_smooth * 0.2), vign);
258 vec3 rC = preBlendColor(u0 + off);
259 vec3 gC = preBlendColor(u1);
260 vec3 bC = preBlendColor(u2 - off);
261 vec3 kaleidoRGB = vec3(rC.r, gC.g, bC.b);
262 float ring = smoothstep(0.0, 0.7, sin(log(rD + 1e-3) * 9.5 + time_f * 1.2));
263 ring = ring * pingPong((time_f * PI), 5.0) * (1.0 + amp_mid * 0.3);
264 float pulse = 0.5 + (0.5 + amp_rms * 0.3) * sin(time_f * 2.0 + rD * 28.0 + k * 12.0);
265 vec3 outCol = kaleidoRGB;
266 outCol *= (0.75 + 0.25 * ring) * (0.85 + 0.15 * pulse) * vign;
267 vec3 bloom = outCol * outCol * 0.18 + pow(max(outCol - 0.6, 0.0), vec3(2.0)) * 0.12;
268
269 outCol += bloom;
270 outCol = mix(outCol, baseCol, pingPong(pulse * PI, 5.0) * 0.18);
271 outCol = clamp(outCol, vec3(0.05), vec3(0.97));
272 vec3 finalRGB = mix(baseTex.rgb, outCol, pingPong(glow * PI, 5.0) * 0.8);
273
274 // --- Audio Reactivity: direct output modulation ---
275 float _ab = clamp(amp_peak, 0.0, 1.0);
276 float _abass = clamp(amp_low, 0.0, 1.0);
277 finalRGB *= 1.0 + _ab * 0.6;
278 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);
279 // --- End Audio Reactivity ---
280
281 color = vec4(finalRGB, baseTex.a);
282}
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
#define amp_smooth
#define amp_mid
#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 fractalFold(vec2 p, float zoom, float t, int i)
Evaluates fractalFold 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 amp_rms
Definition breathe.frag:21
#define PI