ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
ant_gem_crystal_pulse.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_gem_crystal_pulse.frag
20 * @brief Vulkan fragment shader: ant gem crystal pulse.
21 */
22// ant_gem_crystal_pulse
23// Kaleidoscopic crystal facets (gem_bump) with bass-pumped zoom and spectrum color wash
24layout(location = 0) in vec2 tc;
25layout(location = 0) out vec4 color;
26layout(set = 0, binding = 0) uniform sampler2D samp;
27
28
29
30
31layout(set = 0, binding = 3) uniform sampler1D spectrum;
32
33const float PI = 3.14159265;
34
35/**
36 * @brief Evaluates rot for this shader effect.
37 * @param a Input value for the calculation.
38 * @return Computed mat2 value.
39 */
40mat2 rot(float a) {
41 float s = sin(a), c = cos(a);
42 return mat2(c, -s, s, c);
43}
44
45/**
46 * @brief Executes the fragment shader entry point.
47 */
48void main() {
49 float bass = texture(spectrum, 0.03).r;
50 float mid = texture(spectrum, 0.22).r;
51 float treble = texture(spectrum, 0.65).r;
52 float air = texture(spectrum, 0.85).r;
53
54 float aspect = iResolution.x / iResolution.y;
55 vec2 uv = tc;
56
57 // Center and aspect-correct
58 vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
59
60 // Bass-driven breathing zoom
61 p *= 1.0 - bass * 0.35;
62
63 // Mid-driven rotation
64 p = rot(iTime * 0.4 + mid * 2.5) * p;
65
66 // Crystal facets: kaleidoscope segments increase with treble
67 float segments = 6.0 + floor(treble * 14.0);
68 float angle = atan(p.y, p.x);
69 float radius = length(p);
70 float step_val = 2.0 * PI / segments;
71 angle = mod(angle, step_val);
72 angle = abs(angle - step_val * 0.5);
73
74 // Inner fractal fold for depth
75 vec2 crystal = vec2(cos(angle), sin(angle)) * radius;
76 for (int i = 0; i < 3; i++) {
77 crystal = abs(crystal) - 0.3 + bass * 0.15;
78 crystal = rot(iTime * 0.1 + float(i) * 0.7) * crystal;
79 }
80
81 // Map back to texture coords
82 crystal.x /= aspect;
83 vec2 sampUV = crystal + 0.5;
84
85 // Chromatic aberration driven by air frequencies
86 float chroma = (air + treble) * 0.04;
87 vec3 col;
88 col.r = texture(samp, sampUV + vec2(chroma, 0.0)).r;
89 col.g = texture(samp, sampUV).g;
90 col.b = texture(samp, sampUV - vec2(chroma, 0.0)).b;
91
92 // Spectrum color wash
93 vec3 specWash = 0.5 + 0.5 * cos(6.28318 * (radius - iTime * 0.3 + vec3(0.0, 0.33, 0.67)));
94 col = mix(col, col * specWash, 0.3 + mid * 0.3);
95
96 // Pulse brightness with bass
97 col *= 1.0 + bass * 0.6;
98
99 // Peak inversion
100 col = mix(col, vec3(1.0) - col, smoothstep(0.92, 1.0, amp_peak));
101
102 // Smooth brightness ride
103 col *= 0.85 + amp_smooth * 0.3;
104
105 color = vec4(col, 1.0);
106}
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
vec3 crystal(float t)
Evaluates crystal for this shader effect.
#define PI
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.