ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
comb3_geo_mouse.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file comb3_geo_mouse.frag
5 * @brief Vulkan fragment shader: comb3 geo mouse.
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 iMouse ext.mouse
18#define iResolution ext.u0.zw
19#define time_f ext.u2.y
20
21layout(location = 0) out vec4 color;
22layout(location = 0) in vec2 tc;
23layout(set = 0, binding = 0) uniform sampler2D samp;
24
25
26
27
28/**
29 * @brief Evaluates pingPong for this shader effect.
30 * @param x Input value for the calculation.
31 * @param length Input value for the calculation.
32 * @return Computed float value.
33 */
34float pingPong(float x, float length) {
35 float m = mod(x, length * 2.0);
36 return m <= length ? m : length * 2.0 - m;
37}
38
39/**
40 * @brief Evaluates h1 for this shader effect.
41 * @param n Input value for the calculation.
42 * @return Computed float value.
43 */
44float h1(float n){return fract(sin(n)*43758.5453123);}
45/**
46 * @brief Evaluates h2 for this shader effect.
47 * @param n Input value for the calculation.
48 * @return Computed vec2 value.
49 */
50vec2 h2(float n){return fract(sin(vec2(n, n+1.0))*vec2(43758.5453,22578.1459));}
51
52/**
53 * @brief Evaluates rotateUV for this shader effect.
54 * @param uv Input value for the calculation.
55 * @param a Input value for the calculation.
56 * @param c Input value for the calculation.
57 * @param aspect Input value for the calculation.
58 * @return Computed vec2 value.
59 */
60vec2 rotateUV(vec2 uv, float a, vec2 c, float aspect) {
61 float s = sin(a), cv = cos(a);
62 vec2 p = uv - c;
63 p.x *= aspect;
64 p = mat2(cv, -s, s, cv) * p;
65 p.x /= aspect;
66 return p + c;
67}
68
69/**
70 * @brief Evaluates reflectUV for this shader effect.
71 * @param uv Input value for the calculation.
72 * @param segments Input value for the calculation.
73 * @param c Input value for the calculation.
74 * @param aspect Input value for the calculation.
75 * @return Computed vec2 value.
76 */
77vec2 reflectUV(vec2 uv, float segments, vec2 c, float aspect) {
78 vec2 p = uv - c;
79 p.x *= aspect;
80 float ang = atan(p.y, p.x);
81 float r = length(p);
82 float seg = 6.28318530718 / segments;
83 ang = mod(ang, seg);
84 ang = abs(ang - seg * 0.5);
85 vec2 q = vec2(cos(ang), sin(ang)) * r;
86 q.x /= aspect;
87 return q + c;
88}
89
90/**
91 * @brief Evaluates tileMirror for this shader effect.
92 * @param uv Input value for the calculation.
93 * @param tiles Input value for the calculation.
94 * @param c Input value for the calculation.
95 * @return Computed vec2 value.
96 */
97vec2 tileMirror(vec2 uv, float tiles, vec2 c) {
98 vec2 p = (uv - c) * tiles;
99 p = abs(fract(p) * 2.0 - 1.0);
100 return p / tiles + c;
101}
102
103/**
104 * @brief Evaluates swirl for this shader effect.
105 * @param uv Input value for the calculation.
106 * @param c Input value for the calculation.
107 * @param aspect Input value for the calculation.
108 * @param k Input value for the calculation.
109 * @return Computed vec2 value.
110 */
111vec2 swirl(vec2 uv, vec2 c, float aspect, float k) {
112 vec2 p = uv - c;
113 p.x *= aspect;
114 float r = length(p) + 1e-6;
115 float a = atan(p.y, p.x) + k * r;
116 vec2 q = vec2(cos(a), sin(a)) * r;
117 q.x /= aspect;
118 return q + c;
119}
120
121/**
122 * @brief Evaluates fractalZoom for this shader effect.
123 * @param uv Input value for the calculation.
124 * @param zoom Input value for the calculation.
125 * @param t Input value for the calculation.
126 * @param c Input value for the calculation.
127 * @param aspect Input value for the calculation.
128 * @return Computed vec2 value.
129 */
130vec2 fractalZoom(vec2 uv, float zoom, float t, vec2 c, float aspect) {
131 vec2 p = uv;
132 for (int i = 0; i < 5; i++) {
133 p = abs((p - c) * zoom) - 0.5 + c;
134 p = rotateUV(p, t * 0.1, c, aspect);
135 }
136 return p;
137}
138
139/**
140 * @brief Executes the fragment shader entry point.
141 */
142void main() {
143 float aspect = iResolution.x / iResolution.y;
144 vec2 m = (iMouse.z > 0.5) ? (iMouse.xy / iResolution) : vec2(0.5);
145 vec2 uv = tc;
146
147 float t = time_f;
148 float modef = mod(floor(t * 0.1666667), 4.0);
149 int mode = int(modef);
150 float seed = floor(t * 0.1666667);
151 float seg = 4.0 + floor(h1(seed) * 8.0);
152 float tiles = 2.0 + floor(h1(seed + 3.1) * 6.0);
153 float k = (h1(seed + 7.7) * 2.0 - 1.0) * (0.6 + 0.6 * sin(t * 0.37));
154 float zoom = 1.3 + 0.6 * sin(t * 0.5 + h1(seed + 1.7) * 6.2831853);
155
156 vec2 duv = uv;
157 if (mode == 0) duv = reflectUV(uv, seg, m, aspect);
158 if (mode == 1) duv = tileMirror(rotateUV(uv, 0.4 * sin(t * 0.6), m, aspect), tiles, m);
159 if (mode == 2) duv = swirl(uv, m, aspect, k * 6.0);
160 if (mode == 3) duv = fractalZoom(uv, zoom, t, m, aspect);
161
162 vec2 d = uv - m;
163 float dist = length(d);
164 float r = 0.45;
165 float w = 1.0 - smoothstep(0.0, r, dist);
166 vec2 warp = normalize(d + 1e-5) * sin(dist * (18.0 + seg) - t * (2.0 + h1(seed)*3.0)) * 0.12 * w;
167 duv += warp;
168
169 duv = vec2(pingPong(duv.x + 0.05 * sin(t), 1.0), pingPong(duv.y + 0.05 * cos(t), 1.0));
170
171 vec4 base = texture(samp, uv);
172 vec4 fx = texture(samp, duv);
173 float blend = 0.45 + 0.25 * sin(t * 0.8);
174 vec4 mixedCol = mix(base, fx, blend);
175
176 mixedCol.rgb *= 0.5 + 0.5 * sin(duv.xyx * (2.0 + seg * 0.1) + t);
177
178 vec4 c1 = sin(mixedCol * pingPong(t, 10.0));
179 vec4 t0 = texture(samp, tc);
180 vec4 c2 = sin(c1 * t0 * 0.8 * pingPong(t, 15.0));
181
182 color = c2;
183 color.a = 1.0;
184}
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
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec2 h2(vec2 p)
Evaluates h2 for this shader effect.
Definition air-bowl.frag:45
#define seed
Definition air-bowl.frag:20
float h1(float n)
Evaluates h1 for this shader effect.
Definition air-bowl.frag:39
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
float n(vec2 p)
Evaluates n for this shader effect.
vec2 warp(vec2 p, vec2 o, float k)
Evaluates warp for this shader effect.
vec2 fractalZoom(vec2 uv, float zoom, float time, vec2 center)
Evaluates fractalZoom for this shader effect.
vec2 tileMirror(vec2 uv, float tiles, vec2 c)
Evaluates tileMirror for this shader effect.
float tiles(vec2 p)
Evaluates tiles for this shader effect.