ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
twist-code-cosmic-auger.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file twist-code-cosmic-auger.frag
5 * @brief Vulkan fragment shader: twist-code-cosmic-auger.
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
26const float TAU = 6.28318530718;
27
28/**
29 * @brief Evaluates mirrorRepeat for this shader effect.
30 * @param p Input value for the calculation.
31 * @return Computed vec2 value.
32 */
33vec2 mirrorRepeat(vec2 p) {
34 return 1.0 - abs(mod(p, 2.0) - 1.0);
35}
36
37/**
38 * @brief Evaluates auger for this shader effect.
39 * @param uv Input value for the calculation.
40 * @param phase Input value for the calculation.
41 * @return Computed vec2 value.
42 */
43vec2 auger(vec2 uv, float phase) {
44 float aspect = max(iResolution.x, 1.0) / max(iResolution.y, 1.0);
45 vec2 ar = vec2(aspect, 1.0);
46 vec2 p = (uv - 0.5) * ar;
47 float r = length(p) + 0.001;
48 float a = atan(p.y, p.x);
49 float teeth = sin(a * 20.0 - log(r) * 31.0 - time_f * 13.0 + phase);
50 float bore = 1.45 / r + time_f * 1.35 + teeth * 0.32;
51 a += bore;
52 r += teeth * 0.052 + sin(r * 88.0 - time_f * 17.0) * 0.026;
53 return mirrorRepeat(vec2(cos(a), sin(a)) * r / ar + 0.5);
54}
55
56/**
57 * @brief Executes the fragment shader entry point.
58 */
59void main(void) {
60 vec2 u0 = auger(tc, 0.0);
61 vec2 u1 = auger(tc, 0.21);
62 vec2 u2 = auger(tc, -0.21);
63 vec3 drilled = vec3(texture(samp, u1).r,
64 texture(samp, u0).g,
65 texture(samp, u2).b);
66 float r = length(tc - 0.5) + 0.001;
67 float ring = pow(0.5 + 0.5 * sin(-log(r) * 28.0 - time_f * 15.0), 3.0);
68 vec3 echo = texture(samp, mirrorRepeat(vec2(atan(tc.y - 0.5, tc.x - 0.5) / TAU * 4.0,
69 -log(r) + time_f))).bgr;
70 vec3 rgb = mix(drilled, echo, 0.18 + ring * 0.32);
71 rgb *= 0.62 + ring * 0.85;
72 color = vec4(rgb, texture(samp, u0).a);
73}
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
#define TAU
vec2 mirrorRepeat(vec2 value)
Evaluates mirrorRepeat for this shader effect.
vec2 auger(vec2 uv, float phase)
Evaluates auger for this shader effect.