ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
code-frac-aurora-vault.frag
Go to the documentation of this file.
1#version 450
2
3layout(set = 0, binding = 1, std140) uniform SpriteExtended {
4 vec4 mouse;
5 vec4 u0;
6 vec4 u1;
7 vec4 u2;
8 vec4 u3;
9 vec4 custom_uniforms[16];
10 vec4 audio_bands;
11 vec4 audio_history;
13#define amp_high ext.audio_bands.z
14#define amp_low ext.audio_bands.x
15#define amp_mid ext.audio_bands.y
16#define amp_peak ext.u2.w
17#define amp_rms ext.u3.z
18#define amp_smooth ext.u3.w
19#define iMouse ext.mouse
20#define iResolution ext.u0.zw
21#define iamp ext.u1.z
22#define time_f ext.u2.y
23
24/**
25 * @file code-frac-aurora-vault.frag
26 * @brief Vulkan fragment shader: code-frac-aurora-vault.
27 */
28// code-frac-aurora-vault: generated remix of the frac shader family.
29layout(location = 0) out vec4 color;
30layout(location = 0) in vec2 tc;
31layout(set = 0, binding = 0) uniform sampler2D samp;
32
33
34
35
36
37
38
39
40
41
42
43const float PI = 3.14159265359;
44const float TAU = 6.28318530718;
45const int STYLE = 0;
46const float SEGMENTS = 7.0;
47const float FOLD_SCALE = 1.62;
48const float SPIN = 0.18;
49const float WARP = 0.56;
50const float TEX_MIX = 0.58;
51const float HUE_RATE = 0.95;
52
53/**
54 * @brief Evaluates rot for this shader effect.
55 * @param a Input value for the calculation.
56 * @return Computed mat2 value.
57 */
58mat2 rot(float a) {
59 float s = sin(a), c = cos(a);
60 return mat2(c, -s, s, c);
61}
62
63/**
64 * @brief Evaluates hsv2rgb for this shader effect.
65 * @param c Input value for the calculation.
66 * @return Computed vec3 value.
67 */
68vec3 hsv2rgb(vec3 c) {
69 vec3 p = abs(fract(c.xxx + vec3(0.0, 0.666667, 0.333333)) * 6.0 - 3.0);
70 return c.z * mix(vec3(1.0), clamp(p - 1.0, 0.0, 1.0), c.y);
71}
72
73/**
74 * @brief Evaluates kaleido for this shader effect.
75 * @param p Input value for the calculation.
76 * @param n Input value for the calculation.
77 * @return Computed vec2 value.
78 */
79vec2 kaleido(vec2 p, float n) {
80 float a = atan(p.y, p.x);
81 float slice = TAU / max(n, 2.0);
82 a = abs(mod(a + 0.5 * slice, slice) - 0.5 * slice);
83 return length(p) * vec2(cos(a), sin(a));
84}
85
86/**
87 * @brief Evaluates foldField for this shader effect.
88 * @param p Input value for the calculation.
89 * @param t Input value for the calculation.
90 * @return Computed vec2 value.
91 */
92vec2 foldField(vec2 p, float t) {
93 for (int i = 0; i < 6; ++i) {
94 float fi = float(i);
95 p = abs(p) - vec2(0.34 + 0.05 * sin(t + fi), 0.28 + 0.04 * cos(t * 0.7 - fi));
96 p *= rot(SPIN + 0.08 * sin(t * 0.3 + fi * 1.7));
97 p *= FOLD_SCALE - 0.055 * fi + amp_low * 0.08;
98 }
99 return p;
100}
101
102/**
103 * @brief Evaluates styleWarp for this shader effect.
104 * @param p Input value for the calculation.
105 * @param t Input value for the calculation.
106 * @return Computed vec2 value.
107 */
108vec2 styleWarp(vec2 p, float t) {
109 float r = max(length(p), 0.001);
110 float a = atan(p.y, p.x);
111 if (STYLE == 0) p += 0.13 * vec2(sin(p.y * 9.0 + t), cos(p.x * 7.0 - t));
112 else if (STYLE == 1) p = vec2(a / TAU + t * 0.05, 0.18 / r + t * 0.08);
113 else if (STYLE == 2) p = vec2(max(abs(p.x), abs(p.y)), min(abs(p.x), abs(p.y))) * sign(p);
114 else if (STYLE == 3) p *= 1.0 + 0.24 * sin(a * 6.0 - t * 1.4);
115 else if (STYLE == 4) p += 0.10 * sin(p.yx * 11.0 + vec2(t, -t));
116 else if (STYLE == 5) p = abs(fract(p * 2.2 + 0.5) - 0.5) * 1.4;
117 else if (STYLE == 6) p *= rot(WARP / r + t * 0.17);
118 else if (STYLE == 7) p = vec2(log(r) * 0.34 - t * 0.08, a / TAU);
119 else if (STYLE == 8) p += normalize(p + vec2(0.001)) * sin(r * 18.0 - t * 3.0) * 0.12;
120 else if (STYLE == 9) p.x += floor(p.y * 18.0 + t * 3.0) * 0.018 * sin(t);
121 else if (STYLE == 10) p *= 0.78 + 0.22 * cos(a * 8.0 + t * 1.5);
122 else if (STYLE == 11) p += vec2(sin(p.y * 15.0), sin(p.x * 13.0)) * 0.08;
123 else if (STYLE == 12) p = fract(p * (1.5 + 0.2 * sin(t)) + 0.5) - 0.5;
124 else if (STYLE == 13) p *= rot(t * 0.25 + r * 3.0);
125 else if (STYLE == 14) p += 0.12 * vec2(sin(r * 14.0 - t), cos(r * 12.0 + t));
126 else if (STYLE == 15) p = abs(p * rot(a + t * 0.1)) - 0.24;
127 else if (STYLE == 16) p *= 0.65 + 0.35 * sin(a * 5.0 - r * 8.0 + t);
128 else if (STYLE == 17) p += step(0.82, fract(p.y * 9.0 + t)) * vec2(sin(t * 7.0) * 0.12, 0.0);
129 else if (STYLE == 18) p *= rot(r * 5.0 - t * 0.35);
130 else if (STYLE == 19) p += normalize(p + vec2(0.001)) * sin(r * 25.0 - t * 2.0) * 0.07;
131 else if (STYLE == 20) p = normalize(p + vec2(0.001)) * (0.16 / r + fract(r * 4.0 - t * 0.1));
132 else if (STYLE == 21) p = abs(fract(p * vec2(3.0, 1.75) + 0.5) - 0.5);
133 else if (STYLE == 22) p = sign(p) * pow(abs(p) + vec2(0.001), vec2(0.72));
134 else if (STYLE == 23) p *= 0.75 + 0.25 * cos(a * 7.0 + sin(r * 10.0) - t);
135 else p = abs(fract(p * 2.0 + vec2(t * 0.03, -t * 0.02) + 0.5) - 0.5);
136 return p;
137}
138
139/**
140 * @brief Evaluates sampleSplit for this shader effect.
141 * @param uv Input value for the calculation.
142 * @param dir Input value for the calculation.
143 * @param amount Input value for the calculation.
144 * @return Computed vec3 value.
145 */
146vec3 sampleSplit(vec2 uv, vec2 dir, float amount) {
147 vec2 px = vec2(1.0 / max(iResolution.x, 1.0), 1.0 / max(iResolution.y, 1.0));
148 vec2 d = dir * px * amount;
149 return vec3(texture(samp, fract(uv + d)).r,
150 texture(samp, fract(uv)).g,
151 texture(samp, fract(uv - d)).b);
152}
153
154/**
155 * @brief Executes the fragment shader entry point.
156 */
157void main() {
158 float aspect = iResolution.x / max(iResolution.y, 1.0);
159 vec2 center = iMouse.z > 0.5 ? iMouse.xy / iResolution : vec2(0.5);
160 vec2 p = (tc - center) * vec2(aspect, 1.0);
161 float t = time_f;
162 float bass = clamp(amp_low, 0.0, 1.0);
163 float mids = clamp(amp_mid, 0.0, 1.0);
164 float highs = clamp(amp_high, 0.0, 1.0);
165
166 p *= rot(t * SPIN * (0.35 + bass * 0.35));
167 p = kaleido(p, SEGMENTS + floor(mids * 4.0));
168 p = styleWarp(p, t);
169 vec2 f = foldField(p, t * 0.32);
170 float radius = length(f) + 0.0001;
171 float angle = atan(f.y, f.x);
172 float logBand = fract(log(radius) * (1.8 + WARP) - t * (0.18 + bass * 0.16));
173 vec2 wrapped = vec2(cos(angle + logBand * WARP), sin(angle + logBand * WARP));
174 wrapped *= exp2(logBand * 1.35 - 1.1);
175
176 vec2 uv = fract(wrapped / vec2(aspect, 1.0) + center);
177 vec2 direction = normalize(wrapped + vec2(0.0001));
178 vec3 split = sampleSplit(uv, direction, 1.5 + highs * 7.0);
179 vec3 source = texture(samp, tc).rgb;
180
181 float ring = 0.5 + 0.5 * sin(log(radius) * (9.0 + float(STYLE % 6)) + t * 1.4);
182 float edge = exp(-7.0 * abs(fract(logBand * 4.0) - 0.5));
183 float hue = fract(angle / TAU + t * 0.035 * HUE_RATE + logBand * 0.45 + float(STYLE) * 0.047);
184 vec3 palette = hsv2rgb(vec3(hue, 0.72 + highs * 0.25, 0.72 + ring * 0.35));
185 vec3 fractalCol = split * mix(vec3(1.0), palette, 0.58) * (0.72 + 0.38 * ring);
186 fractalCol += palette * edge * (0.10 + amp_peak * 0.22);
187
188 vec3 outCol = mix(source, fractalCol, TEX_MIX);
189 outCol += max(outCol - 0.58, 0.0) * (0.24 + amp_smooth * 0.18);
190 float vignette = 1.0 - smoothstep(0.55, 1.35, length((tc - center) * vec2(aspect, 1.0)));
191 outCol *= 0.78 + 0.22 * vignette;
192 outCol *= 1.0 + clamp(amp_peak, 0.0, 1.0) * 0.35;
193 outCol = mix(outCol, outCol * vec3(1.0 + bass * 0.30, 1.0 + mids * 0.12, 1.0 + highs * 0.26), 0.65);
194 outCol = outCol / (1.0 + max(outCol - 1.0, 0.0));
195
196 color = vec4(clamp(outCol, 0.0, 1.0), texture(samp, tc).a);
197}
198
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
vec3 palette(float phase)
Evaluates palette for this shader effect.
#define amp_low
#define amp_high
#define amp_peak
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
Definition air-bowl.frag:52
vec2 kaleido(vec2 p, float seg)
Evaluates kaleido for this shader effect.
vec3 hue(float t)
Evaluates hue for this shader effect.
Definition auraXi1.frag:65
vec3 hsv2rgb(vec3 c)
Evaluates hsv2rgb for this shader effect.
Definition aura.frag:43
vec2 foldField(vec2 p, float t)
Evaluates foldField for this shader effect.
const float HUE_RATE
const float SPIN
vec2 styleWarp(vec2 p, float t)
Evaluates styleWarp for this shader effect.
const float FOLD_SCALE
const float TEX_MIX
const int STYLE
vec3 sampleSplit(vec2 uv, vec2 dir, float amount)
Evaluates sampleSplit for this shader effect.
const float SEGMENTS
const float WARP
float n(vec2 p)
Evaluates n for this shader effect.
#define TAU
#define PI