ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_gem_metal_helix.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 time_f ext.u2.y
17
18/**
19 * @file ant_gem_metal_helix.frag
20 * @brief Vulkan fragment shader: ant gem metal helix.
21 */
22// ant_gem_metal_helix
23// Double helix metallic bands with DNA-like twist and spectrum color encoding
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
33/**
34 * @brief Evaluates metalSpectrum for this shader effect.
35 * @param t Input value for the calculation.
36 * @return Computed vec3 value.
37 */
38vec3 metalSpectrum(float t) {
39 return vec3(0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.33, 0.67))));
40}
41
42/**
43 * @brief Executes the fragment shader entry point.
44 */
45void main(void) {
46 float bass = texture(spectrum, 0.04).r;
47 float mid = texture(spectrum, 0.22).r;
48 float hiMid = texture(spectrum, 0.40).r;
49 float treble = texture(spectrum, 0.58).r;
50 float air = texture(spectrum, 0.80).r;
51
52 vec2 uv = tc * 2.0 - 1.0;
53 uv.x *= iResolution.x / iResolution.y;
54
55 float r = length(uv);
56 float angle = atan(uv.y, uv.x);
57
58 // Double helix: two sinusoidal strands along vertical axis
59 float twist = 8.0 + bass * 6.0;
60 float speed = time_f * 3.0;
61
62 float strand1 = sin(uv.y * twist - speed) * (0.15 + mid * 0.1);
63 float strand2 = sin(uv.y * twist - speed + 3.14159) * (0.15 + mid * 0.1);
64
65 // Distance to each strand
66 float d1 = abs(uv.x - strand1);
67 float d2 = abs(uv.x - strand2);
68
69 float width = 0.04 + treble * 0.03;
70 float glow1 = exp(-d1 * d1 / (width * width));
71 float glow2 = exp(-d2 * d2 / (width * width));
72
73 // Connecting rungs between strands
74 float rungPhase = uv.y * twist - speed;
75 float rungInterval = mod(rungPhase, 3.14159);
76 float isRung = smoothstep(0.1, 0.0, abs(rungInterval - 1.57));
77 float rungX = mix(strand1, strand2, (uv.x - strand1) / max(strand2 - strand1, 0.001));
78 float onRung = isRung * step(min(strand1, strand2), uv.x) * step(uv.x, max(strand1, strand2));
79 float rungGlow = onRung * 0.5;
80
81 // Warp texture along helix
82 float helixWarp = (glow1 + glow2) * 0.03;
83 vec2 sampUV = tc + vec2(helixWarp, 0.0);
84
85 // Chromatic split
86 float chroma = 0.008 + air * 0.02;
87 vec3 baseTex;
88 baseTex.r = texture(samp, sampUV + vec2(chroma, 0.0)).r;
89 baseTex.g = texture(samp, sampUV).g;
90 baseTex.b = texture(samp, sampUV - vec2(chroma, 0.0)).b;
91
92 // Color each strand differently
93 vec3 color1 = metalSpectrum(uv.y * 0.5 + time_f * 0.2);
94 vec3 color2 = metalSpectrum(uv.y * 0.5 + time_f * 0.2 + 0.5);
95 vec3 rungColor = metalSpectrum(rungPhase * 0.1 + time_f * 0.15);
96
97 vec3 helixColor = color1 * glow1 + color2 * glow2 + rungColor * rungGlow;
98 helixColor *= 1.5 + hiMid * 2.0;
99
100 vec3 finalColor = baseTex + helixColor;
101
102 // Central glow
103 float center = exp(-r * (5.0 - amp_smooth * 3.0));
104 finalColor += vec3(1.0, 0.97, 0.92) * center * (1.3 + amp_peak * 1.8);
105
106 // Ripple underlay
107 float ripple = sin(r * 15.0 - time_f * 2.0) * 0.5 + 0.5;
108 finalColor += metalSpectrum(r + time_f * 0.1) * ripple * 0.1 * bass;
109
110 color = vec4(finalColor, 1.0);
111}
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 amp_smooth
#define amp_peak
vec3 ripple(ivec2 p, ivec2 size)
Evaluates ripple for this shader effect.
vec3 metalSpectrum(float t)
Evaluates metalSpectrum for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.
vec2 twist(vec2 coord, float twistAmount, float time, float direction)
Evaluates twist for this shader effect.