ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
frac_mouse_z.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file frac_mouse_z.frag
5 * @brief Vulkan fragment shader: frac mouse z.
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 hsv2rgb for this shader effect.
93 * @param c Input value for the calculation.
94 * @return Computed vec3 value.
95 */
96vec3 hsv2rgb(vec3 c){
97 vec4 K=vec4(1.0,2.0/3.0,1.0/3.0,3.0);
98 vec3 p=abs(fract(c.xxx+K.xyz)*6.0-K.www);
99 return c.z*mix(K.xxx,clamp(p-K.xxx,0.0,1.0),c.y);
100}
101
102/**
103 * @brief Evaluates warp for this shader effect.
104 * @param uv Input value for the calculation.
105 * @param t Input value for the calculation.
106 * @return Computed vec2 value.
107 */
108vec2 warp(vec2 uv, float t){
109 float s1=sin((uv.x+uv.y)*8.0+t*0.8);
110 float s2=cos((uv.x-uv.y)*9.0-t*0.6);
111 float s3=sin((uv.x*2.0)*5.0+t*1.1)+cos((uv.y*2.0)*7.0-t*1.3);
112 return uv + 0.02*vec2(s1+s3*0.5, s2-s3*0.5);
113}
114
115/**
116 * @brief Evaluates logPolarWrap for this shader effect.
117 * @param uv Input value for the calculation.
118 * @param c Input value for the calculation.
119 * @param ar Input value for the calculation.
120 * @param tz Input value for the calculation.
121 * @param base Input value for the calculation.
122 * @return Computed vec2 value.
123 */
124vec2 logPolarWrap(vec2 uv, vec2 c, vec2 ar, float tz, float base){
125 vec2 p=(uv-c)*ar;
126 float r=length(p)+1e-6;
127 float a=atan(p.y,p.x)+tz*0.3;
128 float per=log(base);
129 float k=fract((log(r)-tz)/per);
130 float rw=exp(k*per);
131 vec2 q=vec2(cos(a),sin(a))*rw;
132 return fract(q/ar+c);
133}
134
135/**
136 * @brief Evaluates fold for this shader effect.
137 * @param uv Input value for the calculation.
138 * @param zoom Input value for the calculation.
139 * @param t Input value for the calculation.
140 * @param c Input value for the calculation.
141 * @param aspect Input value for the calculation.
142 * @return Computed vec2 value.
143 */
144vec2 fold(vec2 uv, float zoom, float t, vec2 c, float aspect){
145 vec2 p=uv;
146 for(int i=0;i<7;i++){
147 p = abs((p - c) * zoom) - 0.5 + c;
148 p = rotateUV(p, t*0.12 + float(i)*0.05, c, aspect);
149 p = warp(p, t + float(i)*0.37);
150 }
151 return p;
152}
153
154/**
155 * @brief Executes the fragment shader entry point.
156 */
157void main(){
158 float aspect=iResolution.x/iResolution.y;
159 vec2 ar=vec2(aspect,1.0);
160 vec2 m=(iMouse.z>0.5)?(iMouse.xy/iResolution):vec2(0.5);
161 vec2 uv=tc;
162
163 vec4 baseTex=texture(samp, tc);
164
165 float seg=mix(5.0, 12.0, 0.5+0.5*sin(time_f*0.35));
166 vec2 kUV=reflectUV(uv, seg, m, aspect);
167
168 float mouseAmp=(iMouse.z>0.5)?(0.3+0.4*abs(sin((iMouse.x+iMouse.y)*0.001+time_f*0.2))):0.45;
169 float foldZoom=1.35 + (0.45 + amp_low * 0.4)*sin(time_f*0.45) + mouseAmp*0.25;
170 kUV=fold(kUV, foldZoom, time_f, m, aspect);
171 kUV=rotateUV(kUV, time_f*0.22, m, aspect);
172
173 float tz=time_f*0.6;
174 float base=1.72 + 0.2*sin(time_f*0.2);
175 vec2 zp0=logPolarWrap(kUV, m, ar, tz, base);
176 vec2 zp1=logPolarWrap(kUV+0.003*vec2(1.0,0.0), m, ar, tz+0.08, base);
177 vec2 zp2=logPolarWrap(kUV+0.003*vec2(0.0,1.0), m, ar, tz+0.16, base);
178
179 vec2 zpw0=warp(zp0, time_f);
180 vec2 zpw1=warp(zp1, time_f+0.7);
181 vec2 zpw2=warp(zp2, time_f+1.4);
182
183 vec4 s0=texture(samp, zpw0);
184 vec4 s1=texture(samp, zpw1);
185 vec4 s2=texture(samp, zpw2);
186
187 vec3 chroma=vec3(s0.r, s1.g, s2.b);
188
189 float ring=sin(10.0*length((kUV-m)*ar)-time_f*3.0)*0.5+0.5;
190 float swirl=sin(6.2831853*(zpw0.x+zpw0.y)+time_f*1.4)*0.5+0.5;
191 float mask=smoothstep(0.0,1.0,ring*0.6+swirl*0.4);
192
193 vec3 hsv=vec3(fract(time_f*0.07 + ring*0.25 + swirl*0.25), 0.8, 0.9);
194 vec3 rainbow=hsv2rgb(hsv);
195
196 vec3 kaleido = mix(chroma, chroma*rainbow, 0.65);
197 vec4 kaleidoTex=vec4(kaleido,1.0);
198
199 float blendFactor=0.55 + 0.15*sin(time_f*0.33);
200 vec4 mixA = mix(kaleidoTex, baseTex, blendFactor*(0.6+0.4*mask));
201
202 vec3 pulse = 0.5 + 0.5*sin(vec3(1.7,2.3,3.1)*time_f + (zpw0.xyx+zpw0.yxx)*9.0);
203 vec4 glow = vec4(mixA.rgb * pulse, 1.0);
204
205 vec4 mod1 = sin(glow * (1.0 + 0.7*pingPong(time_f, 9.0)));
206 vec4 mod2 = sin(mod1 * (1.0 + 0.9*pingPong(time_f, 13.0)));
207
208 vec4 t = texture(samp, tc);
209 vec4 outc = mod2 * t * (0.7 + 0.3*mask);
210
211 outc.rgb = clamp(outc.rgb, 0.08, 0.92);
212 color = vec4(outc.rgb, 1.0);
213
214 // --- Audio Reactivity: direct output modulation ---
215 float _ab = clamp(amp_peak, 0.0, 1.0);
216 float _abass = clamp(amp_low, 0.0, 1.0);
217 color.rgb *= 1.0 + _ab * 0.6;
218 color.rgb = mix(color.rgb, color.rgb * vec3(1.0 + _abass * 0.3, 1.0 - _abass * 0.15, 1.0 + clamp(amp_high, 0.0, 1.0) * 0.25), _ab);
219 // --- End Audio Reactivity ---
220
221}
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
vec3 rainbow(float t)
Evaluates rainbow for this shader effect.
vec2 kaleido(vec2 p, float seg)
Evaluates kaleido for this shader effect.
vec2 swirl(vec2 uv, float centerRadius, float swirlAmount)
Evaluates swirl 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 hsv2rgb(vec3 c)
Evaluates hsv2rgb for this shader effect.
Definition aura.frag:43
vec2 warp(vec2 p, vec2 o, float k)
Evaluates warp for this shader effect.
float s3
Definition eye2.frag:24
vec2 fold(vec2 uv, float zoom, float t, vec2 c, float aspect)
Evaluates fold for this shader effect.
vec2 logPolarWrap(vec2 uv, vec2 c, vec2 ar, float tz, float base)
Evaluates logPolarWrap for this shader effect.
float s2(float x)
Evaluates s2 for this shader effect.