ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
gkale_echo.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file gkale_echo.frag
5 * @brief Vulkan fragment shader: gkale echo.
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) in vec2 tc;
21layout(location = 0) out vec4 color;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25/**
26 * @brief Evaluates pingPong for this shader effect.
27 * @param x Input value for the calculation.
28 * @param length Input value for the calculation.
29 * @return Computed float value.
30 */
31float pingPong(float x, float length) {
32 float modVal = mod(x, length * 2.0);
33 return modVal <= length ? modVal : length * 2.0 - modVal;
34}
35/**
36 * @brief Evaluates firstEffect for this shader effect.
37 * @param tc Input value for the calculation.
38 * @return Computed vec4 value.
39 */
40vec4 firstEffect(vec2 tc) {
41 vec2 center = vec2(0.5, 0.5);
42 float angle = time_f;
43 vec2 tc1 = tc;
44 vec2 tc2 = tc - center;
45 tc2 *= 0.8;
46 tc2 = vec2(
47 tc2.x * cos(angle + 1.0) - tc2.y * sin(angle + 1.0),
48 tc2.x * sin(angle + 1.0) + tc2.y * cos(angle + 1.0)
49 );
50 tc2 += center;
51 tc2 = fract(tc2);
52 vec2 tc3 = tc - center;
53 tc3 *= 0.6;
54 tc3 = vec2(
55 tc3.x * cos(angle + 2.0) - tc3.y * sin(angle + 2.0),
56 tc3.x * sin(angle + 2.0) + tc3.y * cos(angle + 2.0)
57 );
58 tc3 += center;
59 tc3 = fract(tc3);
60 vec2 tc4 = tc - center;
61 tc4 *= 0.4;
62 tc4 = vec2(
63 tc4.x * cos(angle + 3.0) - tc4.y * sin(angle + 3.0),
64 tc4.x * sin(angle + 3.0) + tc4.y * cos(angle + 3.0)
65 );
66 tc4 += center;
67 tc4 = fract(tc4);
68 vec4 color1 = texture(samp, tc1);
69 vec4 color2 = texture(samp, tc2);
70 vec4 color3 = texture(samp, tc3);
71 vec4 color4 = texture(samp, tc4);
72 return (color1 + color2 + color3 + color4) * 0.25;
73}
74/**
75 * @brief Executes the fragment shader entry point.
76 */
77void main(void) {
78 vec2 uv = tc * 2.0 - 1.0;
79 uv.x *= iResolution.x / iResolution.y;
80 float angle = atan(uv.y, uv.x);
81 float radius = length(uv) * 1.4142;
82 float segments = 8.0;
83 angle = mod(angle, 6.28318 / segments);
84 angle = abs(angle - 3.14159 / segments);
85 uv = vec2(cos(angle), sin(angle)) * radius;
86 uv = uv * 0.5 + 0.5;
87 uv = clamp(uv, 0.0, 1.0);
88 float time_t = pingPong(time_f * 0.5, 7.0) + 2.0;
89 vec4 texColor = firstEffect(uv);
90 float pattern = cos(radius * 10.0 - time_t * 5.0);
91 vec3 colorShift = vec3(
92 0.5 + 0.5 * cos(pattern + time_t + 0.0),
93 0.5 + 0.5 * cos(pattern + time_t + 2.094),
94 0.5 + 0.5 * cos(pattern + time_t + 4.188)
95 );
96 vec3 finalColor = texColor.rgb * colorShift;
97 color = vec4(finalColor, texColor.a);
98 color = mix(color, firstEffect(tc), 0.5);
99 color = sin(color * time_t);
100 color.a = 1.0;
101}
102
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 iResolution
Definition 3high.frag:18
#define time_f
Definition 3high.frag:19
vec4 colorShift(vec4 col)
Evaluates colorShift for this shader effect.
Definition af_scale.frag:84
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec4 firstEffect(vec2 tc)
Evaluates firstEffect for this shader effect.