ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_new_infinity_plasma.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_new_infinity_plasma.frag
20 * @brief Vulkan fragment shader: ant new infinity plasma.
21 */
22// ant_new_infinity_plasma
23// Mix of ant_spectrum_mirror_infinity + ant_light_color_plasma_helix:
24// infinite recursion of plasma-warped kaleidoscope samples fading
25// into a rainbow depth well.
26layout(location = 0) in vec2 tc;
27layout(location = 0) out vec4 color;
28layout(set = 0, binding = 0) uniform sampler2D samp;
29
30
31
32
33layout(set = 0, binding = 3) uniform sampler1D spectrum;
34
35const float PI = 3.14159265;
36
37/**
38 * @brief Evaluates rainbow for this shader effect.
39 * @param t Input value for the calculation.
40 * @return Computed vec3 value.
41 */
42vec3 rainbow(float t) {
43 return 0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.33, 0.67)));
44}
45
46/**
47 * @brief Evaluates rot for this shader effect.
48 * @param a Input value for the calculation.
49 * @return Computed mat2 value.
50 */
51mat2 rot(float a) { float s = sin(a), c = cos(a); return mat2(c, -s, s, c); }
52
53/**
54 * @brief Evaluates kaleido for this shader effect.
55 * @param p Input value for the calculation.
56 * @param seg Input value for the calculation.
57 * @return Computed vec2 value.
58 */
59vec2 kaleido(vec2 p, float seg) {
60 float ang = atan(p.y, p.x);
61 float r = length(p);
62 float s = 2.0 * PI / seg;
63 ang = abs(mod(ang, s) - s * 0.5);
64 return vec2(cos(ang), sin(ang)) * r;
65}
66
67/**
68 * @brief Evaluates mirror for this shader effect.
69 * @param u Input value for the calculation.
70 * @return Computed vec2 value.
71 */
72vec2 mirror(vec2 u) {
73 vec2 m = mod(u, 2.0);
74 return mix(m, 2.0 - m, step(1.0, m));
75}
76
77/**
78 * @brief Executes the fragment shader entry point.
79 */
80void main() {
81 float bass = texture(spectrum, 0.04).r;
82 float mid = texture(spectrum, 0.22).r;
83 float hiMid = texture(spectrum, 0.40).r;
84 float treble = texture(spectrum, 0.58).r;
85 float air = texture(spectrum, 0.80).r;
86
87 float aspect = iResolution.x / iResolution.y;
88 vec2 uv = (tc - 0.5) * vec2(aspect, 1.0);
89
90 // Plasma field pre-warp
91 float pl = 0.0;
92 pl += sin((uv.x * 5.0 + iTime) * (1.0 + bass));
93 pl += sin((uv.y * 5.0 + iTime * 0.7) * (1.0 + mid));
94 pl += sin((uv.x + uv.y + iTime) * 3.0);
95 pl += cos(length(uv * 10.0 + iTime) * (2.0 + treble * 3.0));
96 pl *= 0.25;
97
98 vec3 result = vec3(0.0);
99 float totalW = 0.0;
100 float seg = floor(6.0 + bass * 6.0);
101
102 for (float d = 0.0; d < 8.0; d++) {
103 float zoom = pow(1.18 + mid * 0.1, d);
104 vec2 p = uv * zoom;
105 // Plasma-coupled rotation per depth
106 p *= rot(d * 0.1 + iTime * 0.05 + pl * 0.15);
107 p += vec2(pl * 0.06, pl * 0.04);
108
109 vec2 kUV = kaleido(p, seg);
110 kUV = abs(kUV);
111 if (kUV.y > kUV.x) kUV = kUV.yx;
112 vec2 texUV = mirror(kUV * 0.5 + 0.5);
113
114 float co = d * 0.002 * (1.0 + treble);
115 vec3 s;
116 s.r = texture(samp, mirror(texUV + vec2(co, 0.0))).r;
117 s.g = texture(samp, texUV).g;
118 s.b = texture(samp, mirror(texUV - vec2(co, 0.0))).b;
119 s *= rainbow(d * 0.1 + length(kUV) + iTime * 0.15 + hiMid);
120
121 float w = 1.0 / (1.0 + d * 0.5);
122 result += s * w;
123 totalW += w;
124 }
125 result /= totalW;
126
127 // Plasma highlight overlay
128 result += rainbow(pl + iTime * 0.2) * pow(max(pl, 0.0), 2.0) * (0.2 + air * 0.3);
129
130 // Center glow
131 result += exp(-length(uv) * 5.0) * rainbow(iTime * 0.4 + bass) * 0.15;
132
133 result = mix(result, result.gbr, air * 0.3);
134 result *= 0.9 + amp_smooth * 0.25;
135 result = mix(result, vec3(1.0) - result, smoothstep(0.9, 1.0, amp_peak));
136
137 color = vec4(result, 1.0);
138}
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
vec2 mirror(vec2 uv)
Evaluates mirror for this shader effect.
vec3 rainbow(float t)
Evaluates rainbow for this shader effect.
vec2 kaleido(vec2 p, float seg)
Evaluates kaleido for this shader effect.
#define PI
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.