ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
fractal_mirror_swirl_mirror.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file fractal_mirror_swirl_mirror.frag
5 * @brief Vulkan fragment shader: fractal mirror swirl mirror.
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 rotate2D for this shader effect.
42 * @param p Input value for the calculation.
43 * @param angle Input value for the calculation.
44 * @return Computed vec2 value.
45 */
46vec2 rotate2D(vec2 p, float angle) {
47 float s = sin(angle), c = cos(angle);
48 return mat2(c, -s, s, c) * p;
49}
50
51/**
52 * @brief Evaluates swirl for this shader effect.
53 * @param uv Input value for the calculation.
54 * @param center Input value for the calculation.
55 * @param radius Input value for the calculation.
56 * @param strength Input value for the calculation.
57 * @return Computed vec2 value.
58 */
59vec2 swirl(vec2 uv, vec2 center, float radius, float strength) {
60 float dist = distance(uv, center);
61 if (dist < radius) {
62 float percent = (radius - dist) / radius;
63 float theta = percent * percent * strength;
64 uv = rotate2D(uv - center, theta) + center;
65 }
66 return uv;
67}
68
69/**
70 * @brief Evaluates fractalFold for this shader effect.
71 * @param uv Input value for the calculation.
72 * @param zoom Input value for the calculation.
73 * @param t Input value for the calculation.
74 * @param c Input value for the calculation.
75 * @param iters Input value for the calculation.
76 * @return Computed vec2 value.
77 */
78vec2 fractalFold(vec2 uv, float zoom, float t, vec2 c, int iters) {
79 vec2 p = uv;
80 for (int i = 0; i < iters; i++) {
81 p = abs((p - c) * (zoom + 0.15 * sin(t * 0.35 + float(i)))) - 0.5 + c;
82 p = rotate2D(p - c, t * 0.12 + float(i) * 0.07) + c;
83 }
84 return p;
85}
86
87/**
88 * @brief Executes the fragment shader entry point.
89 */
90void main(void) {
91 float aLow = clamp(amp_low, 0.0, 1.0);
92 float aMid = clamp(amp_mid, 0.0, 1.0);
93 float aHigh = clamp(amp_high, 0.0, 1.0);
94 float aPk = clamp(amp_peak, 0.0, 1.0);
95 float t = time_f;
96
97 vec2 uv = 1.0 - abs(1.0 - 2.0 * tc);
98 float swirlStr = sin(t * 0.6) * 4.0 * (1.0 + aMid * 2.0);
99 uv = swirl(uv, vec2(0.5), 0.7 + 0.2 * aLow, swirlStr);
100
101 float zoom = 1.3 + 0.4 * aLow;
102 uv = fractalFold(uv, zoom, t, vec2(0.5), 4);
103 uv = 1.0 - abs(1.0 - 2.0 * fract(uv));
104
105 vec4 tex = texture(samp, uv);
106 tex.rgb *= 1.0 + aPk * 0.6;
107 tex.rgb = mix(tex.rgb, tex.rgb * vec3(1.0 + aLow * 0.3, 1.0, 1.0 + aHigh * 0.3), aPk);
108 color = tex;
109}
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 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 swirl(vec2 uv, float centerRadius, float swirlAmount)
Evaluates swirl for this shader effect.
mat2 rotate2D(float a)
Evaluates rotate2D for this shader effect.
#define strength
Definition ol.frag:16