ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
apart_mouse.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file apart_mouse.frag
5 * @brief Vulkan fragment shader: apart 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 rotX for this shader effect.
30 * @param a Input value for the calculation.
31 * @return Computed mat3 value.
32 */
33mat3 rotX(float a){float s=sin(a),c=cos(a);return mat3(1,0,0, 0,c,-s, 0,s,c);}
34/**
35 * @brief Evaluates rotY for this shader effect.
36 * @param a Input value for the calculation.
37 * @return Computed mat3 value.
38 */
39mat3 rotY(float a){float s=sin(a),c=cos(a);return mat3(c,0,s, 0,1,0,-s,0,c);}
40/**
41 * @brief Evaluates rotZ for this shader effect.
42 * @param a Input value for the calculation.
43 * @return Computed mat3 value.
44 */
45mat3 rotZ(float a){float s=sin(a),c=cos(a);return mat3(c,-s,0, s,c,0, 0,0,1);}
46
47/**
48 * @brief Evaluates pseudoRandomDirection for this shader effect.
49 * @param t Input value for the calculation.
50 * @return Computed vec2 value.
51 */
53 vec2 v = vec2(sin(t * 1.3), cos(t * 1.7));
54 return normalize(v);
55}
56
57/**
58 * @brief Executes the fragment shader entry point.
59 */
60void main(void) {
61 float aspect = iResolution.x / iResolution.y;
62 vec2 ar = vec2(aspect, 1.0);
63 vec2 m = (iMouse.z > 0.5) ? (iMouse.xy / iResolution) : vec2(0.5);
64
65
66 float zoom = mix(0.1, 1.4, 0.5 + 0.5 * sin(time_f * 0.6));
67 vec2 p = (tc - m) * ar / zoom;
68 float ax = 0.3 * sin(time_f * 0.7);
69 float ay = 0.25 * cos(time_f * 0.6);
70 float az = 0.4 * time_f;
71 mat3 R = rotZ(az) * rotY(ay) * rotX(ax);
72
73 vec3 q = R * vec3(p, 1.0);
74 float zf = 1.0 / (1.0 + q.z * 0.8);
75 vec2 pr = q.xy * zf;
76
77 float dist = length(pr);
78 float ang = atan(pr.y, pr.x) + time_f * 2.0;
79 float radius = dist * (1.0 + 0.1 * sin(time_f * 3.0 + dist * 10.0));
80 vec2 dir = pseudoRandomDirection(time_f + dist * 5.0);
81
82 vec2 spiral = vec2(cos(ang), sin(ang)) * radius * 0.5 + dir * 0.1 * sin(time_f * 2.0);
83 vec2 uv = spiral / ar + m;
84 uv = clamp(uv, 0.0, 1.0);
85
86 color = texture(samp, uv);
87}
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
mat3 rotY(float a)
Evaluates rotY for this shader effect.
mat3 rotZ(float a)
Evaluates rotZ for this shader effect.
vec2 pseudoRandomDirection(float time)
Evaluates pseudoRandomDirection for this shader effect.
Definition apart.frag:31
mat3 rotX(float a)
Evaluates rotX for this shader effect.
mat2 R(float a)
Evaluates R for this shader effect.