ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
code-update-cosmic-loom.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file code-update-cosmic-loom.frag
5 * @brief Vulkan fragment shader: code-update-cosmic-loom.
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// Interwoven luminous ribbons forming a rotating celestial tapestry.
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, .37, .7)));
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, .6).r,
52 a = texture(spectrum, .87).r;
53 float A = iResolution.x / iResolution.y;
54 vec2 p = (tc - .5) * vec2(A, 1);
55 p *= R(iTime * .07);
56 float warp = .08 * sin(p.yx * 6. + iTime * vec2(.7, -.5)).x * m;
57 vec2 q = p + warp;
58 float wx = sin(q.x * (18. + b * 9.) + sin(q.y * 7. - iTime) * 2.),
59 wy = sin(q.y * (21. + m * 8.) + sin(q.x * 6. + iTime * .8) * 2.);
60 float loom = pow(1. - abs(wx), 18.) + pow(1. - abs(wy), 18.);
61 float over = step(0., sin((floor((q.x + 2.) * 9.) + floor((q.y + 2.) * 9.)) * 1.57));
62 vec2 uv = tc + vec2(wy, wx) * (.008 + .018 * t);
63 vec3 c = texture(samp, uv).rgb * (.52 + .56 * P(q.x * .25 - q.y * .2));
64 vec3 thread = mix(P(q.x + iTime * .04), P(q.y - iTime * .05), over);
65 c += thread * loom * (.55 + 1.5 * a);
66 float star = pow(max(cos(atan(p.y, p.x) * 14. - length(p) * 30. + iTime), 0.), 32.) *
67 exp(-length(p) * 2.);
68 c += P(iTime * .08) * star * (.35 + 2. * b);
69 c *= .9 + .32 * amp_smooth;
70 c = mix(c, 1. - c, smoothstep(.96, 1., amp_peak));
71 color = vec4(1. - exp(-max(c, 0.) * 1.25), 1);
72}
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.
vec2 warp(vec2 p, vec2 o, float k)
Evaluates warp for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.