ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
bowl-by_time.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file bowl-by_time.frag
5 * @brief Vulkan fragment shader: bowl-by time.
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 length Input value for the calculation.
30 * @return Computed float value.
31 */
32float pingPong(float x, float length) {
33 float m = mod(x, length * 2.0);
34 return m <= length ? m : length * 2.0 - m;
35}
36
37/**
38 * @brief Evaluates h1 for this shader effect.
39 * @param n Input value for the calculation.
40 * @return Computed float value.
41 */
42float h1(float n){ return fract(sin(n)*43758.5453123); }
43/**
44 * @brief Evaluates h2 for this shader effect.
45 * @param n Input value for the calculation.
46 * @return Computed vec2 value.
47 */
48vec2 h2(float n){ return fract(sin(vec2(n, n+1.0))*vec2(43758.5453,22578.1459)); }
49
50/**
51 * @brief Executes the fragment shader entry point.
52 */
53void main(void){
54 float rate = 0.6;
55 float t = time_f * rate;
56 float t0 = floor(t);
57 float a = fract(t);
58 float w = a*a*(3.0-2.0*a);
59 vec2 p0 = vec2(0.15) + h2(t0)*0.7;
60 vec2 p1 = vec2(0.15) + h2(t0+1.0)*0.7;
61 vec2 center = mix(p0, p1, w);
62
63 vec2 p = tc - center;
64 float r = length(p);
65 float ang = atan(p.y, p.x);
66
67 float swirl = 2.2 + 0.8*sin(time_f*0.35);
68 float spin = 0.6*sin(time_f*0.2);
69 ang += swirl * r + spin;
70
71 float bend = 0.35;
72 float rp = r + bend * r * r;
73
74 vec2 uv = center + vec2(cos(ang), sin(ang)) * rp;
75
76 uv += 0.02 * vec2(sin((tc.y+time_f)*4.0), cos((tc.x-time_f)*3.5));
77
78 uv = vec2(pingPong(uv.x, 1.0), pingPong(uv.y, 1.0));
79
80 color = texture(samp, uv);
81}
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 h2(vec2 p)
Evaluates h2 for this shader effect.
Definition air-bowl.frag:45
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.
float n(vec2 p)
Evaluates n for this shader effect.
vec2 spin(vec2 p, float a)
Evaluates spin for this shader effect.