ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_gem_neon_silk.frag
Go to the documentation of this file.
1#version 450
2
3layout(set = 0, binding = 1, std140) uniform SpriteExtended {
4 vec4 mouse;
5 vec4 u0;
6 vec4 u1;
7 vec4 u2;
8 vec4 u3;
9 vec4 custom_uniforms[16];
10 vec4 audio_bands;
11 vec4 audio_history;
13#define amp_peak ext.u2.w
14#define amp_smooth ext.u3.w
15#define iResolution ext.u0.zw
16#define iTime ext.u0.y
17
18/**
19 * @file ant_gem_neon_silk.frag
20 * @brief Vulkan fragment shader: ant gem neon silk.
21 */
22// ant_gem_neon_silk
23// Spiderweb silk filaments with neon fractal glow and treble shimmer
24layout(location = 0) in vec2 tc;
25layout(location = 0) out vec4 color;
26layout(set = 0, binding = 0) uniform sampler2D samp;
27
28
29
30
31layout(set = 0, binding = 3) uniform sampler1D spectrum;
32
33const float TAU = 6.28318530718;
34
35/**
36 * @brief Evaluates neon for this shader effect.
37 * @param t Input value for the calculation.
38 * @return Computed vec3 value.
39 */
40vec3 neon(float t) {
41 return 0.5 + 0.5 * cos(TAU * (t + vec3(0.0, 0.33, 0.67)));
42}
43
44/**
45 * @brief Evaluates rot for this shader effect.
46 * @param a Input value for the calculation.
47 * @return Computed mat2 value.
48 */
49mat2 rot(float a) {
50 float s = sin(a), c = cos(a);
51 return mat2(c, -s, s, c);
52}
53
54/**
55 * @brief Executes the fragment shader entry point.
56 */
57void main() {
58 float bass = texture(spectrum, 0.03).r;
59 float mid = texture(spectrum, 0.20).r;
60 float hiMid = texture(spectrum, 0.42).r;
61 float treble = texture(spectrum, 0.60).r;
62 float air = texture(spectrum, 0.80).r;
63
64 float aspect = iResolution.x / iResolution.y;
65 vec2 p = (tc - 0.5) * vec2(aspect, 1.0);
66 vec2 p0 = p;
67
68 // Rotation driven by bass
69 p = rot(iTime * 0.3 + bass * 1.5) * p;
70
71 // Spiderweb radial segments
72 float rad = length(p) + 1e-6;
73 float ang = atan(p.y, p.x);
74 float N = 8.0 + floor(mid * 8.0);
75 float stepA = TAU / N;
76 float a = mod(ang + iTime * 0.05, stepA);
77 a = abs(a - stepA * 0.5);
78
79 // Silk strands
80 float radialSilk = smoothstep(0.035, 0.0, abs(a));
81 float ringSilk = smoothstep(0.05, 0.0, abs(fract(log(rad) * 2.5 + bass * 0.5 + iTime * 0.2) - 0.5));
82 float web = max(radialSilk, ringSilk);
83
84 // Kaleidoscope sample coordinates
85 vec2 kaleido = vec2(cos(a), sin(a)) * rad;
86 kaleido.x /= aspect;
87 vec2 sampUV = kaleido + 0.5;
88
89 // Neon fractal glow rings layered on texture
90 vec3 neonAccum = vec3(0.0);
91 vec2 fuv = p;
92 for (float i = 0.0; i < 5.0; i++) {
93 fuv = fract(fuv * (1.4 + hiMid * 0.3)) - 0.5;
94 fuv = rot(iTime * 0.1 + i * 0.6) * fuv;
95 fuv = abs(fuv);
96 if (fuv.y > fuv.x) fuv = fuv.yx;
97
98 float d = length(fuv) * exp(-length(p0));
99 d = sin(d * (8.0 + treble * 6.0) + iTime) / 8.0;
100 d = abs(d);
101 d = pow(0.01 / d, 1.1);
102
103 neonAccum += neon(length(p0) + i * 0.15 + iTime * 0.2) * d;
104 }
105
106 // Texture sampling with treble shimmer offset
107 float shimmer = treble * 0.03 * sin(iTime * 12.0 + rad * 20.0);
108 vec3 col;
109 col.r = texture(samp, sampUV + vec2(shimmer, 0.0)).r;
110 col.g = texture(samp, sampUV).g;
111 col.b = texture(samp, sampUV - vec2(shimmer, 0.0)).b;
112
113 // Blend neon glow onto silk lines
114 vec3 silkGlow = neon(iTime * 0.15 + rad + bass) * web * (2.5 + air * 3.0);
115 col += silkGlow * 0.4;
116
117 // Mix fractal neon into result
118 col = mix(col, col + neonAccum * 0.3, 0.4 + mid * 0.2);
119
120 col *= 0.85 + amp_smooth * 0.3;
121 col = mix(col, vec3(1.0) - col, smoothstep(0.93, 1.0, amp_peak));
122
123 color = vec4(col, 1.0);
124}
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 amp_smooth
#define amp_peak
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
Definition air-bowl.frag:52
vec3 neon(float t)
Evaluates neon for this shader effect.
vec2 kaleido(vec2 p, float seg)
Evaluates kaleido for this shader effect.
float N(vec2 p)
Evaluates N for this shader effect.
#define TAU
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.