ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
frac_shader02_dmd6iFold.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file frac_shader02_dmd6iFold.frag
5 * @brief Vulkan fragment shader: frac shader02 dmd6iFold.
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 / segments;
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 < 8; i++) {
116 p = abs((p - c) * (zoom + 0.15 * sin(t * (0.35 + amp_low * 0.2) + float(i)))) - 0.5 + c;
117 if (i % 2 == 0) 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 Executes the fragment shader entry point.
155 */
156void main() {
157 vec2 uv = tc;
158 float aspect = iResolution.x / iResolution.y;
159 vec2 m = iMouse.xy / iResolution.xy;
160
161 if(iMouse.z == 0.0)
162 m = uv / aspect;
163 // Initial fractal folding
164 uv = fractalFold(uv, 1.45 + 0.55 * sin(time_f * 0.42), time_f, m, aspect);
165
166 // Neon color palette
167 vec3 col = neonPalette(sin(time_f * aspect));
168
169 // Transparency manipulation
170 float alpha = 0.8 - 0.6 * abs(sin(time_f + length(uv - m) * 10.0));
171
172 vec3 fcol = texture(samp, tc).rgb;
173
174 col = sin(col * (1.0+pingPong(time_f, 10.0))) * fcol;
175 col *= alpha;
176
177 // Output color
178
179 // --- Audio Reactivity: direct output modulation ---
180 float _ab = clamp(amp_peak, 0.0, 1.0);
181 float _abass = clamp(amp_low, 0.0, 1.0);
182 col *= 1.0 + _ab * 0.6;
183 col = mix(col, col * vec3(1.0 + _abass * 0.3, 1.0 - _abass * 0.15, 1.0 + clamp(amp_high, 0.0, 1.0) * 0.25), _ab);
184 // --- End Audio Reactivity ---
185
186 color = vec4(col, 1.0);
187}
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.
vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect)
Evaluates rotateUV for this shader effect.
Definition aura2.frag:59
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
vec3 hsv2rgb(vec3 c)
Evaluates hsv2rgb for this shader effect.
Definition aura.frag:43
#define alpha
Definition color_g.frag:17
#define PI