ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
frac_shader01_dark.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file frac_shader01_dark.frag
5 * @brief Vulkan fragment shader: frac shader01 dark.
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
42/**
43 * @brief Evaluates pingPong for this shader effect.
44 * @param x Input value for the calculation.
45 * @param length Input value for the calculation.
46 * @return Computed float value.
47 */
48float pingPong(float x, float length){
49 float m = mod(x, length*2.0);
50 return m <= length ? m : length*2.0 - m;
51}
52
53/**
54 * @brief Evaluates rotateUV for this shader effect.
55 * @param uv Input value for the calculation.
56 * @param angle Input value for the calculation.
57 * @param c Input value for the calculation.
58 * @param aspect Input value for the calculation.
59 * @return Computed vec2 value.
60 */
61vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect){
62 float s = sin(angle), cc = cos(angle);
63 vec2 p = uv - c;
64 p.x *= aspect;
65 p = mat2(cc, -s, s, cc) * p;
66 p.x /= aspect;
67 return p + c;
68}
69
70/**
71 * @brief Evaluates reflectUV for this shader effect.
72 * @param uv Input value for the calculation.
73 * @param segments Input value for the calculation.
74 * @param c Input value for the calculation.
75 * @param aspect Input value for the calculation.
76 * @return Computed vec2 value.
77 */
78vec2 reflectUV(vec2 uv, float segments, vec2 c, float aspect){
79 vec2 p = uv - c;
80 p.x *= aspect;
81 float ang = atan(p.y, p.x);
82 float rad = length(p);
83 float stepA = 6.28318530718 / segments;
84 ang = mod(ang, stepA);
85 ang = abs(ang - stepA * 0.5);
86 vec2 r = vec2(cos(ang), sin(ang)) * rad;
87 r.x /= aspect;
88 return r + c;
89}
90
91/**
92 * @brief Evaluates fractalFold for this shader effect.
93 * @param uv Input value for the calculation.
94 * @param zoom Input value for the calculation.
95 * @param t Input value for the calculation.
96 * @param c Input value for the calculation.
97 * @param aspect Input value for the calculation.
98 * @return Computed vec2 value.
99 */
100vec2 fractalFold(vec2 uv, float zoom, float t, vec2 c, float aspect){
101 vec2 p = uv;
102 for(int i=0;i<6;i++){
103 p = abs((p - c) * (zoom + 0.15*sin(t*(0.35 + amp_low * 0.2)+float(i)))) - 0.5 + c;
104 p = rotateUV(p, t*0.12 + float(i)*0.07, c, aspect);
105 }
106 return p;
107}
108
109/**
110 * @brief Evaluates hsv2rgb for this shader effect.
111 * @param c Input value for the calculation.
112 * @return Computed vec3 value.
113 */
114vec3 hsv2rgb(vec3 c){
115 vec4 K = vec4(1.0, 2.0/3.0, 1.0/3.0, 3.0);
116 vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
117 return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
118}
119
120/**
121 * @brief Evaluates movingGradient for this shader effect.
122 * @param uv Input value for the calculation.
123 * @param c Input value for the calculation.
124 * @param t Input value for the calculation.
125 * @param aspect Input value for the calculation.
126 * @return Computed vec3 value.
127 */
128vec3 movingGradient(vec2 uv, vec2 c, float t, float aspect){
129 vec2 ar = vec2(aspect, 1.0);
130 vec2 p = (uv - c) * ar;
131 vec2 d = normalize(vec2(cos(t*0.27), sin(t*0.31)));
132 float s = dot(p, d);
133 float band = 0.5 + 0.5*sin(s*6.28318530718*0.35 + t*0.9);
134 float h = fract(s*0.22 + t*0.07 + 0.15*sin(t*0.33));
135 float S = 0.75 + 0.25*sin(t*0.21 + s*2.0);
136 float V = 0.6 + 0.125*band; // dimmer
137 vec3 base = hsv2rgb(vec3(h, S, V));
138 float edge = smoothstep(0.2, 0.8, band);
139 return mix(base*0.6, base, edge);
140}
141
142/**
143 * @brief Evaluates triFold for this shader effect.
144 * @param uv Input value for the calculation.
145 * @param c Input value for the calculation.
146 * @param aspect Input value for the calculation.
147 * @return Computed vec2 value.
148 */
149vec2 triFold(vec2 uv, vec2 c, float aspect){
150 vec2 p = (uv - c) * vec2(aspect, 1.0);
151 vec2 b1 = vec2(1.0, 0.0);
152 vec2 b2 = vec2(0.5, 0.86602540378);
153 float u = dot(p, b1);
154 float v = dot(p, b2);
155 vec2 f = fract(vec2(u, v));
156 if(f.x + f.y > 1.0) f = vec2(1.0) - f;
157 vec2 q = f.x*b1 + f.y*b2;
158 q.x /= aspect;
159 return q + c;
160}
161
162/**
163 * @brief Evaluates diamondRadius for this shader effect.
164 * @param p Input value for the calculation.
165 * @return Computed float value.
166 */
167float diamondRadius(vec2 p){
168 p = abs(p);
169 return max(p.x, p.y);
170}
171
172/**
173 * @brief Evaluates luma for this shader effect.
174 * @param c Input value for the calculation.
175 * @return Computed float value.
176 */
177float luma(vec3 c){ return dot(c, vec3(0.299,0.587,0.114)); }
178
179/**
180 * @brief Evaluates bilateral9 for this shader effect.
181 * @param uv Input value for the calculation.
182 * @param radiusScale Input value for the calculation.
183 * @param sigma_r Input value for the calculation.
184 * @return Computed vec3 value.
185 */
186vec3 bilateral9(vec2 uv, float radiusScale, float sigma_r){
187 vec2 texel = 1.0 / iResolution;
188 vec2 o = texel * radiusScale;
189 vec3 c0 = texture(samp, uv).rgb;
190 float L0 = luma(c0);
191 vec2 offs[9] = vec2[](
192 vec2(0,0),
193 vec2( o.x, 0), vec2(-o.x, 0),
194 vec2(0, o.y), vec2(0, -o.y),
195 vec2( o.x, o.y), vec2(-o.x, o.y),
196 vec2( o.x, -o.y), vec2(-o.x, -o.y)
197 );
198 float wsum = 0.0;
199 vec3 acc = vec3(0.0);
200 for(int i=0;i<9;i++){
201 vec3 c = texture(samp, uv + offs[i]).rgb;
202 float dl = luma(c) - L0;
203 float wr = exp(-(dl*dl)/(2.0*sigma_r*sigma_r));
204 float dsq = dot(offs[i]/texel, offs[i]/texel);
205 float ws = exp(-dsq/2.0);
206 float w = wr*ws;
207 acc += c*w;
208 wsum += w;
209 }
210 return acc / max(wsum, 1e-6);
211}
212
213/**
214 * @brief Evaluates localVar9 for this shader effect.
215 * @param uv Input value for the calculation.
216 * @param radiusScale Input value for the calculation.
217 * @return Computed float value.
218 */
219float localVar9(vec2 uv, float radiusScale){
220 vec2 texel = 1.0 / iResolution;
221 vec2 o = texel * radiusScale;
222 float m = 0.0;
223 float s = 0.0;
224 int n = 0;
225 for(int y=-1;y<=1;y++){
226 for(int x=-1;x<=1;x++){
227 vec3 c = texture(samp, uv + vec2(x,y)*o).rgb;
228 float L = luma(c);
229 m += L;
230 s += L*L;
231 n++;
232 }
233 }
234 m /= float(n);
235 s /= float(n);
236 return max(s - m*m, 0.0);
237}
238
239/**
240 * @brief Executes the fragment shader entry point.
241 */
242void main(){
243 float aspect = iResolution.x / iResolution.y;
244 vec2 ar = vec2(aspect, 1.0);
245 vec2 m = (iMouse.z > 0.5) ? (iMouse.xy / iResolution) : vec2(0.5);
246 vec2 uv = tc;
247 vec4 originalTexture = texture(samp, tc);
248
249 float seg = 3.0;
250 vec2 kUV = reflectUV(uv, seg, m, aspect);
251 kUV = triFold(kUV, m, aspect);
252 float foldZoom = 1.45 + (0.55 + amp_low * 0.4) * sin(time_f * 0.42);
253 kUV = fractalFold(kUV, foldZoom, time_f, m, aspect);
254 kUV = rotateUV(kUV, time_f * (0.23 + amp_low * 0.15), m, aspect);
255 kUV = triFold(kUV, m, aspect);
256
257 vec2 p = (kUV - m) * ar;
258 vec2 q = abs(p);
259 if(q.y > q.x) q = q.yx;
260
261 float base = 1.82 + 0.18*sin(time_f*0.2);
262 float period = log(base);
263 float tz = time_f * (0.65 + amp_low * 0.3);
264 float rD = diamondRadius(p) + 1e-6;
265 float ang = atan(q.y, q.x) + tz * 0.35 + 0.35*sin(rD*18.0 + time_f*0.6);
266 float k = fract((log(rD) - tz) / period);
267 float rw = exp(k * period);
268 vec2 pwrap = vec2(cos(ang), sin(ang)) * rw;
269
270 vec2 u0 = fract(pwrap / ar + m);
271 vec2 u1 = fract((pwrap*1.045) / ar + m);
272 vec2 u2 = fract((pwrap*0.955) / ar + m);
273
274 vec2 dir = normalize(pwrap + 1e-6);
275 vec2 off = dir * ((0.0015 + amp_high * 0.002) + 0.001 * sin(time_f*1.3)) * vec2(1.0, 1.0/aspect);
276
277 float hue = fract(ang*0.25 + time_f*0.08 + k*0.5);
278 float sat = 0.75 - 0.25*cos(time_f*0.7 + rD*10.0);
279 float val = 0.8 + 0.2*sin(time_f*0.9 + k*6.28318530718);
280 vec3 tint = hsv2rgb(vec3(hue, sat, val));
281
282 float ring = smoothstep(0.0, 0.7, sin(log(rD+1e-3)*9.5 + time_f*1.2));
283 float pulse = 0.5 + (0.5 + amp_rms * 0.3)*sin(time_f*2.0 + rD*28.0 + k*12.0);
284
285 float vign = 1.0 - smoothstep(0.75, 1.2, length((tc - m)*ar));
286 vign = mix(0.85, 1.2, vign);
287
288 float blendFactor = 0.58;
289
290 float v0 = localVar9(u0, 1.0);
291 float v1 = localVar9(u1, 1.0);
292 float v2 = localVar9(u2, 1.0);
293 float pix = (v0+v1+v2)/3.0;
294
295 float sStrong = smoothstep(0.02, 0.20, pix);
296 float radA = mix(0.75, 2.25, sStrong);
297 float sigma_r = mix(0.10, 0.22, sStrong);
298
299 vec3 bc0 = bilateral9(u0 + off, radA, sigma_r);
300 vec3 bc1 = bilateral9(u1, radA, sigma_r);
301 vec3 bc2 = bilateral9(u2 - off, radA, sigma_r);
302
303 vec3 kaleidoRGB = vec3(bc0.r, bc1.g, bc2.b);
304
305 vec4 kaleidoColor = vec4(kaleidoRGB, 1.0) * vec4(tint, 1.0);
306 vec4 merged = mix(kaleidoColor, originalTexture, blendFactor);
307
308 merged.rgb *= (0.75 + 0.25*ring) * (0.85 + 0.15*pulse) * vign;
309
310 vec3 bloom = merged.rgb * merged.rgb * 0.18 + pow(max(merged.rgb-0.6,0.0), vec3(2.0))*0.12;
311 vec3 outCol = merged.rgb + bloom;
312
313 float wob = 0.9 + 0.1*sin(time_f + rD*14.0 + k*9.0);
314 outCol *= wob;
315
316 vec3 grad = movingGradient(tc, m, time_f, aspect) * 0.5; // 1/2 brightness
317 float gradBase = 0.35 + 0.25*sin(time_f*0.5 + rD*7.0 + k*9.0);
318 float gradAmt = 0.5 * mix(gradBase*0.5, 0.95, sStrong); // 1/2 influence
319 vec3 screenBlend = 1.0 - (1.0 - outCol) * (1.0 - grad);
320 outCol = mix(outCol, screenBlend, gradAmt);
321
322 vec4 t = texture(samp, tc);
323 outCol = mix(outCol, outCol*t.rgb, 0.8);
324
325 outCol = sin(outCol * (0.5 + 0.5*pingPong(time_f, 12.0)));
326 outCol = clamp(outCol, vec3(0.08), vec3(0.96));
327
328
329 // --- Audio Reactivity: direct output modulation ---
330 float _ab = clamp(amp_peak, 0.0, 1.0);
331 float _abass = clamp(amp_low, 0.0, 1.0);
332 outCol *= 1.0 + _ab * 0.6;
333 outCol = mix(outCol, outCol * vec3(1.0 + _abass * 0.3, 1.0 - _abass * 0.15, 1.0 + clamp(amp_high, 0.0, 1.0) * 0.25), _ab);
334 // --- End Audio Reactivity ---
335
336 color = vec4(outCol, 1.0);
337}
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_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 bloom(float t)
Evaluates bloom for this shader effect.
vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect)
Evaluates rotateUV for this shader effect.
Definition aura2.frag:59
vec2 reflectUV(vec2 uv, float segments, vec2 c, float aspect)
Evaluates reflectUV for this shader effect.
Definition aura2.frag:76
float diamondRadius(vec2 p)
Evaluates diamondRadius for this shader effect.
Definition aura2.frag:182
vec3 hue(float t)
Evaluates hue for this shader effect.
Definition auraXi1.frag:65
float luma(vec3 c)
Evaluates luma for this shader effect.
Definition auraXi1.frag:58
vec3 hsv2rgb(vec3 c)
Evaluates hsv2rgb for this shader effect.
Definition aura.frag:43
float sat(float x)
Evaluates sat for this shader effect.
Definition blue_2.frag:52
#define amp_rms
Definition breathe.frag:21
vec3 screenBlend(vec3 a, vec3 b)
Evaluates screenBlend for this shader effect.
float h(vec2 p)
Evaluates h for this shader effect.
float n(vec2 p)
Evaluates n for this shader effect.
float V(vec2 p, out vec2 id)
Evaluates V for this shader effect.
float S(int i, float f)
Evaluates S for this shader effect.
vec3 movingGradient(vec2 uv, vec2 c, float t, float aspect)
Evaluates movingGradient for this shader effect.
vec3 bilateral9(vec2 uv, float radiusScale, float sigma_r)
Evaluates bilateral9 for this shader effect.
float localVar9(vec2 uv, float radiusScale)
Evaluates localVar9 for this shader effect.
vec2 triFold(vec2 uv, vec2 c, float aspect)
Evaluates triFold for this shader effect.