ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
bowl.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file bowl.frag
5 * @brief Vulkan fragment shader: bowl.
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 iResolution ext.u0.zw
18#define time_f ext.u2.y
19
20layout(location = 0) out vec4 color;
21layout(location = 0) in vec2 tc;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25
26/**
27 * @brief Evaluates pingPong for this shader effect.
28 * @param x Input value for the calculation.
29 * @param len Input value for the calculation.
30 * @return Computed float value.
31 */
32float pingPong(float x, float len) {
33 float m = mod(x, len * 2.0);
34 return abs(m - len);
35}
36
37/**
38 * @brief Evaluates rand for this shader effect.
39 * @param n Input value for the calculation.
40 * @return Computed float value.
41 */
42float rand(float n) {
43 return fract(sin(n) * 43758.5453123);
44}
45
46/**
47 * @brief Executes the fragment shader entry point.
48 */
49void main(void) {
50 vec2 center = vec2(0.5, 0.5);
51 vec2 off = tc - center;
52 float maxR = length(vec2(0.5));
53 float r = length(off);
54 float nr = r / maxR;
55 float ang = atan(off.y, off.x);
56
57 float distortion = 0.5;
58 float dr = nr + distortion * (nr * nr);
59 dr = clamp(dr, 0.0, 1.0) * maxR;
60 vec2 d = center + dr * vec2(cos(ang), sin(ang));
61
62 float dir = sign(rand(floor(time_f * 0.2)) - 0.5);
63 float phase = rand(floor(time_f * 0.1)) * 6.2831853;
64 float rotateSpeed = 1.0;
65 float warpSpeed = 0.1;
66
67 ang += dir * (phase + time_f * rotateSpeed);
68
69 vec2 dp = d - center;
70 float ca = cos(ang), sa = sin(ang);
71 vec2 rot = vec2(ca * dp.x - sa * dp.y, sa * dp.x + ca * dp.y) + center;
72
73 float t = time_f * warpSpeed;
74 vec2 w = vec2(pingPong(rot.x + t, 1.0), pingPong(rot.y + t, 1.0));
75
76 color = texture(samp, w);
77}
float rand(vec2 co)
Evaluates rand for this shader effect.
Definition 3high.frag:40
layout(set=0, binding=1, std140) uniform SpriteExtended
Definition 3high.frag:7
ext
Definition 3high.frag:16
void main(void)
Executes the fragment shader entry point.
Definition 3high.frag:47
#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 rot(vec2 v, float a)
Evaluates rot for this shader effect.
Definition air-bowl.frag:52
float n(vec2 p)
Evaluates n for this shader effect.