ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
twist-code-double-helix.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file twist-code-double-helix.frag
5 * @brief Vulkan fragment shader: twist-code-double-helix.
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/**
27 * @brief Evaluates whirl for this shader effect.
28 * @param uv Input value for the calculation.
29 * @param center Input value for the calculation.
30 * @param direction Input value for the calculation.
31 * @return Computed vec2 value.
32 */
33vec2 whirl(vec2 uv, vec2 center, float direction) {
34 float aspect = max(iResolution.x, 1.0) / max(iResolution.y, 1.0);
35 vec2 ar = vec2(aspect, 1.0);
36 vec2 p = (uv - center) * ar;
37 float r = length(p) + 0.025;
38 float a = atan(p.y, p.x);
39 a += direction * (1.0 / r + time_f * 1.25);
40 r += sin(r * 48.0 - time_f * 9.0 + direction * a * 6.0) * 0.045;
41 return vec2(cos(a), sin(a)) * r / ar + center;
42}
43
44/**
45 * @brief Executes the fragment shader entry point.
46 */
47void main(void) {
48 vec2 orbit = vec2(cos(time_f * 0.7), sin(time_f * 0.7)) * 0.17;
49 vec2 u0 = whirl(tc, vec2(0.5) + orbit, 1.0);
50 vec2 u1 = whirl(tc, vec2(0.5) - orbit, -1.0);
51 vec2 uv = fract(mix(u0, u1, 0.5 + 0.5 * sin((tc.x + tc.y) * 35.0 - time_f * 6.0)));
52 vec4 c0 = texture(samp, uv);
53 vec4 c1 = texture(samp, fract(mix(u1, u0, 0.36)));
54 float braid = 0.5 + 0.5 * sin((tc.x - tc.y) * 50.0 + time_f * 8.0);
55 color = vec4(mix(c0.rgb, c1.bgr, braid * 0.42), c0.a);
56}
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
vec2 whirl(vec2 uv, vec2 center, float direction)
Evaluates whirl for this shader effect.