ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
code-update-event-horizon-crown.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file code-update-event-horizon-crown.frag
5 * @brief Vulkan fragment shader: code-update-event-horizon-crown.
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// Gravitational log-polar lens with accretion crown and RGB caustics.
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 TAU = 6.28318530718;
30/**
31 * @brief Evaluates pal for this shader effect.
32 * @param x Input value for the calculation.
33 * @return Computed vec3 value.
34 */
35vec3 pal(float x) {
36 return .5 + .5 * cos(TAU * (x + vec3(.0, .18, .48)));
37}
38/**
39 * @brief Evaluates lens for this shader effect.
40 * @param p Input value for the calculation.
41 * @param z Input value for the calculation.
42 * @return Computed vec2 value.
43 */
44vec2 lens(vec2 p, float z) {
45 float r = length(p) + .018, a = atan(p.y, p.x);
46 a += 1.25 / r + z;
47 return vec2(cos(a), sin(a)) * abs(log(r) * .19 + .36);
48}
49/**
50 * @brief Executes the fragment shader entry point.
51 */
52void main() {
53 float b = texture(spectrum, .03).r, m = texture(spectrum, .2).r, t = texture(spectrum, .6).r,
54 a = texture(spectrum, .88).r;
55 float asp = iResolution.x / iResolution.y;
56 vec2 p = (tc - .5) * vec2(asp, 1);
57 float r = length(p), an = atan(p.y, p.x);
58 float pulse = .04 * b + .015 * sin(iTime * 1.7);
59 vec2 q = lens(p, iTime * .16 + b * .7);
60 q.x /= asp;
61 q += .5;
62 vec2 tangent = normalize(vec2(-p.y, p.x) + vec2(1e-4));
63 float ca = .006 + .03 * t;
64 vec3 c = vec3(texture(samp, fract(q + tangent * ca)).r, texture(samp, fract(q)).g,
65 texture(samp, fract(q - tangent * ca)).b);
66 float disk = exp(-abs(r - (.27 + pulse)) * (48. - m * 12.));
67 float crown =
68 pow(.5 + .5 * cos(an * 11. - log(r + .03) * 7. + iTime * 2.), 10.) * exp(-r * 2.2);
69 float photon = exp(-abs(r - .16 - b * .025) * 95.);
70 c *= .58 + .55 * pal(an / TAU + iTime * .04);
71 c += pal(an / TAU + r * 1.4 + iTime * .1) *
72 (disk * (1.2 + 3. * b) + crown * (.35 + 1.8 * a) + photon * 1.5);
73 c *= smoothstep(.055, .13, r);
74 c += pal(iTime * .08) * exp(-r * 24.) * .5;
75 c = mix(c, c.bgr, .2 * m);
76 c *= .9 + .28 * amp_smooth;
77 c = mix(c, 1. - c, smoothstep(.965, 1., amp_peak));
78 color = vec4(1. - exp(-max(c, 0.) * 1.15), 1);
79}
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
vec3 pal(float t)
Evaluates pal for this shader effect.
vec2 lens(vec2 p, float z)
Evaluates lens for this shader effect.
#define TAU
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.