ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
twist-code-hypercube-vortex.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file twist-code-hypercube-vortex.frag
5 * @brief Vulkan fragment shader: twist-code-hypercube-vortex.
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 rotate2 for this shader effect.
28 * @param p Input value for the calculation.
29 * @param a Input value for the calculation.
30 * @return Computed vec2 value.
31 */
32vec2 rotate2(vec2 p, float a) {
33 float c = cos(a), s = sin(a);
34 return mat2(c, -s, s, c) * p;
35}
36
37/**
38 * @brief Evaluates mirrorRepeat for this shader effect.
39 * @param p Input value for the calculation.
40 * @return Computed vec2 value.
41 */
42vec2 mirrorRepeat(vec2 p) {
43 return 1.0 - abs(mod(p, 2.0) - 1.0);
44}
45
46/**
47 * @brief Evaluates mirrorRepeat for this shader effect.
48 * @param p Input value for the calculation.
49 * @return Computed float value.
50 */
51float mirrorRepeat(float p) {
52 return 1.0 - abs(mod(p, 2.0) - 1.0);
53}
54
55/**
56 * @brief Executes the fragment shader entry point.
57 */
58void main(void) {
59 float aspect = max(iResolution.x, 1.0) / max(iResolution.y, 1.0);
60 vec2 ar = vec2(aspect, 1.0);
61 vec2 p = (tc - 0.5) * ar;
62 vec2 diamond = rotate2(p, 0.78539816339);
63 float squareR = max(abs(diamond.x), abs(diamond.y)) + 0.001;
64 float a = atan(p.y, p.x);
65 float cubeWave = sin(squareR * 72.0 - time_f * 13.0 + a * 8.0);
66 a += time_f * 0.9 + 1.15 / squareR + cubeWave * 0.26;
67 float shell = mirrorRepeat(-log(squareR) * 0.82 + time_f * 0.65);
68 vec2 q = vec2(cos(a), sin(a)) * (squareR + cubeWave * 0.04);
69 q = mirrorRepeat(q * (2.0 + shell) + 0.5) - 0.5;
70 q = abs(q) * 2.0;
71 // Two mirrored angular windings close exactly across atan's -PI/PI cut.
72 vec2 uv = mirrorRepeat(q / ar + vec2(shell, a / 3.14159265359));
73 vec4 c0 = texture(samp, uv);
74 vec4 c1 = texture(samp, mirrorRepeat(1.0 - uv.yx + shell * 0.13));
75 float frame = pow(abs(cubeWave), 5.0);
76 color = vec4(mix(c0.rgb, c1.bgr, 0.3 + frame * 0.3) * (0.65 + frame * 0.65), c0.a);
77}
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
float diamond(vec2 p)
Evaluates diamond for this shader effect.
Definition dmd_gpt.frag:29
vec2 rotate2(vec2 p, float angle)
Evaluates rotate2 for this shader effect.
vec2 mirrorRepeat(vec2 value)
Evaluates mirrorRepeat for this shader effect.