ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
spiral-code-chromatic-tunnel.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file spiral-code-chromatic-tunnel.frag
5 * @brief Vulkan fragment shader: spiral-code-chromatic-tunnel.
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 time_f ext.u2.y
18
19layout(location = 0) in vec2 tc;
20layout(location = 0) out vec4 color;
21layout(set = 0, binding = 0) uniform sampler2D samp;
22
23
24const float TAU = 6.28318530718;
25
26/**
27 * @brief Evaluates rotation for this shader effect.
28 * @param angle Input value for the calculation.
29 * @return Computed mat2 value.
30 */
31mat2 rotation(float angle) {
32 float sine = sin(angle);
33 float cosine = cos(angle);
34 return mat2(cosine, -sine, sine, cosine);
35}
36
37/**
38 * @brief Evaluates mirrorUV for this shader effect.
39 * @param uv Input value for the calculation.
40 * @return Computed vec2 value.
41 */
42vec2 mirrorUV(vec2 uv) {
43 return 1.0 - abs(mod(uv, 2.0) - 1.0);
44}
45
46/**
47 * @brief Executes the fragment shader entry point.
48 */
49void main(void) {
50 vec2 size = vec2(textureSize(samp, 0));
51 float aspect = size.x / max(size.y, 1.0);
52 vec2 p = (tc - 0.5) * vec2(aspect, 1.0);
53 float radius = length(p) + 0.002;
54 float depth = fract(-log(radius) * 0.48 + time_f * 0.16);
55 float twist = depth * TAU * 0.72 - time_f * TAU * 0.045;
56 float tunnelRadius = mix(0.06, 0.72, depth);
57 vec2 direction = p / radius;
58 vec2 tunnelPoint = rotation(twist) * direction * tunnelRadius;
59 vec2 uv = mirrorUV(0.5 + tunnelPoint / vec2(aspect, 1.0));
60
61 vec2 tangent = normalize(vec2(-p.y, p.x) + vec2(0.0001)) / vec2(aspect, 1.0);
62 float split = 0.006 + depth * 0.004;
63 vec3 result;
64 result.r = texture(samp, mirrorUV(uv + tangent * split)).r;
65 result.g = texture(samp, uv).g;
66 result.b = texture(samp, mirrorUV(uv - tangent * split)).b;
67 float ring = pow(0.5 + 0.5 * sin(depth * TAU * 7.0), 16.0);
68 result += vec3(0.14, 0.20, 0.26) * ring * (1.0 - radius) * 0.30;
69 color = vec4(result, texture(samp, tc).a);
70}
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
vec2 mirrorUV(vec2 uv)
Evaluates mirrorUV for this shader effect.
#define TAU
mat2 rotation(float angle)
Evaluates rotation for this shader effect.
vec2 twist(vec2 coord, float twistAmount, float time, float direction)
Evaluates twist for this shader effect.