ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
frac_shader01.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file frac_shader01.frag
5 * @brief Vulkan fragment shader: frac shader01.
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.75 + 0.25*band;
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 Executes the fragment shader entry point.
144 */
145void main(){
146 float aspect = iResolution.x / iResolution.y;
147 vec2 ar = vec2(aspect, 1.0);
148 vec2 m = (iMouse.z > 0.5) ? (iMouse.xy / iResolution) : vec2(0.5);
149 vec2 uv = tc;
150 vec4 originalTexture = texture(samp, tc);
151
152 float seg = 6.0 + (2.0 + amp_mid * 2.0)*sin(time_f*0.33);
153 vec2 kUV = reflectUV(uv, seg, m, aspect);
154 float foldZoom = 1.45 + (0.55 + amp_low * 0.4) * sin(time_f * 0.42);
155 kUV = fractalFold(kUV, foldZoom, time_f, m, aspect);
156 kUV = rotateUV(kUV, time_f * (0.23 + amp_low * 0.15), m, aspect);
157
158 vec2 p = (kUV - m) * ar;
159 float base = 1.82 + 0.18*sin(time_f*0.2);
160 float period = log(base);
161 float tz = time_f * (0.65 + amp_low * 0.3);
162 float r = length(p) + 1e-6;
163 float ang = atan(p.y, p.x) + tz * 0.35 + 0.35*sin(r*9.0 + time_f*0.8);
164 float k = fract((log(r) - tz) / period);
165 float rw = exp(k * period);
166 vec2 pwrap = vec2(cos(ang), sin(ang)) * rw;
167
168 vec2 u0 = fract(pwrap / ar + m);
169 vec2 u1 = fract((pwrap*1.045) / ar + m);
170 vec2 u2 = fract((pwrap*0.955) / ar + m);
171
172 vec2 dir = normalize(pwrap + 1e-6);
173 vec2 off = dir * ((0.0015 + amp_high * 0.002) + 0.001 * sin(time_f*1.3)) * vec2(1.0, 1.0/aspect);
174
175 float hue = fract(ang*0.15 + time_f*0.08 + k*0.5);
176 float sat = 0.8 - 0.2*cos(time_f*0.7 + r*6.0);
177 float val = 0.8 + 0.2*sin(time_f*0.9 + k*6.28318530718);
178 vec3 tint = hsv2rgb(vec3(hue, sat, val));
179
180 float ring = smoothstep(0.0, 0.7, sin(log(r+1e-3)*8.0 + time_f*1.2));
181 float pulse = 0.5 + (0.5 + amp_rms * 0.3)*sin(time_f*2.0 + r*18.0 + k*12.0);
182
183 float vign = 1.0 - smoothstep(0.75, 1.2, length((tc - m)*ar));
184 vign = mix(0.85, 1.2, vign);
185
186 float blendFactor = 0.58;
187
188 float rC = texture(samp, u0 + off).r;
189 float gC = texture(samp, u1).g;
190 float bC = texture(samp, u2 - off).b;
191 vec3 kaleidoRGB = vec3(rC, gC, bC);
192
193 vec4 kaleidoColor = vec4(kaleidoRGB, 1.0) * vec4(tint, 1.0);
194 vec4 merged = mix(kaleidoColor, originalTexture, blendFactor);
195
196 merged.rgb *= (0.75 + 0.25*ring) * (0.85 + 0.15*pulse) * vign;
197
198 vec3 bloom = merged.rgb * merged.rgb * 0.18 + pow(max(merged.rgb-0.6,0.0), vec3(2.0))*0.12;
199 vec3 outCol = merged.rgb + bloom;
200
201 float wob = 0.9 + 0.1*sin(time_f + r*12.0 + k*9.0);
202 outCol *= wob;
203
204 vec3 grad = movingGradient(tc, m, time_f, aspect);
205 float gradAmt = 0.35 + 0.25*sin(time_f*0.5 + r*5.0 + k*9.0);
206 vec3 screenBlend = 1.0 - (1.0 - outCol) * (1.0 - grad);
207 outCol = mix(outCol, screenBlend, gradAmt);
208
209 vec4 t = texture(samp, tc);
210 outCol = mix(outCol, outCol*t.rgb, 0.8);
211
212 outCol = sin(outCol * (0.5 + 0.5*pingPong(time_f, 12.0)));
213 outCol = clamp(outCol, vec3(0.08), vec3(0.96));
214
215
216 // --- Audio Reactivity: direct output modulation ---
217 float _ab = clamp(amp_peak, 0.0, 1.0);
218 float _abass = clamp(amp_low, 0.0, 1.0);
219 outCol *= 1.0 + _ab * 0.6;
220 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);
221 // --- End Audio Reactivity ---
222
223 color = vec4(outCol, 1.0);
224}
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_mid
#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
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
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 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.