ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
code-update-quantum-ribbon-vault.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file code-update-quantum-ribbon-vault.frag
5 * @brief Vulkan fragment shader: code-update-quantum-ribbon-vault.
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 amp_peak ext.u2.w
18#define amp_smooth ext.u3.w
19#define iResolution ext.u0.zw
20#define iTime ext.u0.y
21
22// Braided quantum ribbons folded into a mirrored, depth-shifting vault.
23layout(location = 0) in vec2 tc;
24layout(location = 0) out vec4 color;
25layout(set = 0, binding = 0) uniform sampler2D samp;
26layout(set = 0, binding = 3) uniform sampler1D spectrum;
27
28
29const float T = 6.28318530718;
30/**
31 * @brief Evaluates R for this shader effect.
32 * @param x Input value for the calculation.
33 * @return Computed mat2 value.
34 */
35mat2 R(float x) {
36 float c = cos(x), s = sin(x);
37 return mat2(c, -s, s, c);
38}
39/**
40 * @brief Evaluates P for this shader effect.
41 * @param x Input value for the calculation.
42 * @return Computed vec3 value.
43 */
44vec3 P(float x) {
45 return .5 + .5 * cos(T * (x + vec3(.0, .28, .66)));
46}
47/**
48 * @brief Executes the fragment shader entry point.
49 */
50void main() {
51 float b = texture(spectrum, .03).r, m = texture(spectrum, .2).r, t = texture(spectrum, .59).r,
52 a = texture(spectrum, .87).r;
53 float A = iResolution.x / iResolution.y;
54 vec2 p = (tc - .5) * vec2(A, 1), q = p;
55 q *= R(iTime * .09);
56 q = abs(q);
57 if (q.x < q.y)
58 q = q.yx;
59 float ribbons = 0.;
60 for (int i = 0; i < 5; i++) {
61 float fi = float(i);
62 float strand =
63 sin(q.x * (15. + fi * 3.) + sin(q.y * (7. + fi)) * 2. + iTime * (.7 - fi * .08));
64 ribbons += pow(1. - abs(strand), 18.) / pow(1.35, fi);
65 q = abs(q * 1.32 - vec2(.31, .22));
66 q *= R(.32 + fi * .27);
67 }
68 vec2 uv = fract(q / vec2(A, 1) + .5);
69 float ca = .004 + .023 * t;
70 vec3 c = vec3(texture(samp, uv + ca).r, texture(samp, uv).g, texture(samp, uv - ca).b) *
71 (.46 + .58 * P(length(q) * .3));
72 c += P(ribbons * .15 + atan(p.y, p.x) / T - iTime * .06) * ribbons * (.45 + 1.7 * a);
73 c += P(iTime * .08) * exp(-length(p) * 15.) * (.4 + 2. * b);
74 c *= .9 + .3 * amp_smooth;
75 c = mix(c, 1. - c, smoothstep(.96, 1., amp_peak));
76 color = vec4(1. - exp(-max(c, 0.) * 1.26), 1);
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 amp_smooth
#define amp_peak
mat2 R(float a)
Evaluates R for this shader effect.
vec3 P(float x)
Evaluates P for this shader effect.
float ribbons(vec2 point, float bass, float middle, float high)
Evaluates ribbons for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.