ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
code-update-celestial-circuit.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file code-update-celestial-circuit.frag
5 * @brief Vulkan fragment shader: code-update-celestial-circuit.
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// Radial circuit mandala with pulsing traces, data sparks, and mirrored silicon facets.
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 H for this shader effect.
32 * @param p Input value for the calculation.
33 * @return Computed float value.
34 */
35float H(vec2 p) {
36 return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5);
37}
38/**
39 * @brief Evaluates P for this shader effect.
40 * @param x Input value for the calculation.
41 * @return Computed vec3 value.
42 */
43vec3 P(float x) {
44 return .5 + .5 * cos(T * (x + vec3(.15, .48, .83)));
45}
46/**
47 * @brief Executes the fragment shader entry point.
48 */
49void main() {
50 float b = texture(spectrum, .03).r, m = texture(spectrum, .2).r, t = texture(spectrum, .58).r,
51 a = texture(spectrum, .86).r;
52 float A = iResolution.x / iResolution.y;
53 vec2 p = (tc - .5) * vec2(A, 1);
54 float r = length(p), an = atan(p.y, p.x);
55 float seg = 12. + floor(b * 8.), w = T / seg, k = abs(mod(an + w * .5, w) - w * .5);
56 vec2 q = vec2(k * seg, r * 14.);
57 vec2 cell = floor(q);
58 float trace = max(pow(.5 + .5 * cos(q.x * T), 32.), pow(.5 + .5 * cos(q.y * T), 32.));
59 float gate = step(.35, H(cell));
60 trace *= mix(.3, 1., gate);
61 vec2 uv = fract(vec2(k / w, r * 2. + sin(k * seg) * .08 * m));
62 float ca = .004 + .018 * t;
63 vec3 c = vec3(texture(samp, uv + ca).r, texture(samp, uv).g, texture(samp, uv - ca).b) *
64 (.48 + .48 * P(r));
65 float spark = step(.975, H(cell + 17.)) * (.5 + .5 * sin(iTime * 6. + H(cell) * 20.));
66 c += P(r * .7 + an / T - iTime * .06) * (trace * (.35 + 1.5 * a) + spark * (.55 + 2. * t));
67 c += P(iTime * .08) * exp(-abs(r - .24 - b * .04) * 70.) * (.5 + b);
68 c *= .9 + .3 * amp_smooth;
69 c = mix(c, 1. - c, smoothstep(.95, 1., amp_peak));
70 color = vec4(1. - exp(-max(c, 0.) * 1.3), 1);
71}
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 P(float x)
Evaluates P for this shader effect.
float H(vec2 p)
Evaluates H for this shader effect.
vec2 cell(vec2 p)
Evaluates cell for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.