ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
fractal_mirror_bass_zoom.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file fractal_mirror_bass_zoom.frag
5 * @brief Vulkan fragment shader: fractal mirror bass zoom.
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 iResolution ext.u0.zw
25#define time_f ext.u2.y
26
27layout(location = 0) out vec4 color;
28layout(location = 0) in vec2 tc;
29layout(set = 0, binding = 0) uniform sampler2D samp;
30
31
32
33
34
35
36
37
38
39
40/**
41 * @brief Evaluates rotateUV for this shader effect.
42 * @param uv Input value for the calculation.
43 * @param angle Input value for the calculation.
44 * @param c Input value for the calculation.
45 * @param aspect Input value for the calculation.
46 * @return Computed vec2 value.
47 */
48vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect) {
49 float s = sin(angle), cc = cos(angle);
50 vec2 p = uv - c;
51 p.x *= aspect;
52 p = mat2(cc, -s, s, cc) * p;
53 p.x /= aspect;
54 return p + c;
55}
56
57/**
58 * @brief Evaluates fractalFold for this shader effect.
59 * @param uv Input value for the calculation.
60 * @param zoom Input value for the calculation.
61 * @param t Input value for the calculation.
62 * @param c Input value for the calculation.
63 * @param aspect Input value for the calculation.
64 * @param iters Input value for the calculation.
65 * @return Computed vec2 value.
66 */
67vec2 fractalFold(vec2 uv, float zoom, float t, vec2 c, float aspect, int iters) {
68 vec2 p = uv;
69 for (int i = 0; i < iters; i++) {
70 p = abs((p - c) * (zoom + 0.15 * sin(t * 0.35 + float(i)))) - 0.5 + c;
71 p = rotateUV(p, t * 0.12 + float(i) * 0.07, c, aspect);
72 }
73 return p;
74}
75
76/**
77 * @brief Executes the fragment shader entry point.
78 */
79void main(void) {
80 float aLow = clamp(amp_low, 0.0, 1.0);
81 float aMid = clamp(amp_mid, 0.0, 1.0);
82 float aHigh = clamp(amp_high, 0.0, 1.0);
83 float aPk = clamp(amp_peak, 0.0, 1.0);
84 float t = time_f;
85 float aspect = iResolution.x / iResolution.y;
86 vec2 ctr = vec2(0.5);
87
88 vec2 uv = 1.0 - abs(1.0 - 2.0 * tc);
89 float bassZoom = 1.0 + 1.5 * aLow;
90 uv = (uv - ctr) * bassZoom + ctr;
91
92 float zoom = 1.2 + 0.6 * aLow + 0.3 * sin(t * 0.3);
93 int iters = 4 + int(aLow * 4.0);
94 uv = fractalFold(uv, zoom, t * (0.5 + aLow * 0.5), ctr, aspect, iters);
95 uv = 1.0 - abs(1.0 - 2.0 * fract(uv));
96
97 vec4 tex = texture(samp, uv);
98 tex.rgb *= 1.0 + aPk * 0.6;
99 tex.rgb = mix(tex.rgb, tex.rgb * vec3(1.0 + aLow * 0.4, 1.0 - aLow * 0.15, 1.0 + aHigh * 0.25), aPk);
100 color = tex;
101}
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 time_f
Definition 3high.frag:19
#define amp_mid
#define amp_low
#define amp_high
#define amp_peak
vec2 fractalFold(vec2 p, float zoom, float t, int i)
Evaluates fractalFold for this shader effect.
vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect)
Evaluates rotateUV for this shader effect.
Definition aura2.frag:59