ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
gem-rainbow-metal3-slider.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file gem-rainbow-metal3-slider.frag
5 * @brief Vulkan fragment shader: gem-rainbow-metal3-slider.
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_high ext.audio_bands.z
18#define amp_low ext.audio_bands.x
19#define amp_mid ext.audio_bands.y
20#define amp_peak ext.u2.w
21#define amp_rms ext.u3.z
22#define amp_smooth ext.u3.w
23#define iResolution ext.u0.zw
24#define iamp ext.u1.z
25#define slider1 ext.custom_uniforms[5].x
26#define slider2 ext.custom_uniforms[5].y
27#define slider3 ext.custom_uniforms[5].z
28#define slider4 ext.custom_uniforms[5].w
29#define time_f ext.u2.y
30
31layout(location = 0) in vec2 tc;
32layout(location = 0) out vec4 color;
33
34layout(set = 0, binding = 0) uniform sampler2D samp;
35
36
37// Audio variables
38
39
40
41
42
43
44
45
46// New MIDI/Audio Uniforms
47layout(set = 0, binding = 3) uniform sampler1D spectrum; // 1D FFT audio data
48
49
50
51
52
53// Renamed from 'spectrum' to avoid sampler1D collision
54/**
55 * @brief Evaluates colorPalette for this shader effect.
56 * @param t Input value for the calculation.
57 * @return Computed vec3 value.
58 */
59vec3 colorPalette(float t) {
60 return vec3(0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.33, 0.67))));
61}
62
63/**
64 * @brief Executes the fragment shader entry point.
65 */
66void main(void) {
67 vec2 uv = tc * 2.0 - 1.0;
68 uv.x *= iResolution.x / iResolution.y;
69
70 float r = length(uv);
71 float angle = atan(uv.y, uv.x);
72
73// Fetch FFT data using the normalized radius.
74 float fft = texture(spectrum, clamp(r * 0.5, 0.0, 1.0)).r;
75
76 // FIX: Force lobes to be a whole number so the circle completes seamlessly
77 float lobes = floor(mix(2.0, 40.0, slider1));
78
79 float ripple = sin(angle * lobes + time_f) * (0.03 + amp_low * 0.05);
80
81 // FIX: Also ensure the secondary ripple uses a whole number!
82 // (lobes * 2.5) could result in a fraction like 27.5, which would cause a seam.
83 float secondaryLobes = floor(lobes * 2.5);
84 ripple += sin(angle * secondaryLobes - time_f * 2.0) * (0.01 + amp_high * 0.03);
85
86 // SLIDER 2: Radial wave density (maps 0.0-1.0 to 5.0-50.0)
87 // (Density doesn't rely on 'angle', so it can safely remain fractional)
88 float waveDensity = mix(5.0, 50.0, slider2);
89
90 // Inject FFT data into the wave calculation, scaled by SLIDER 4
91 float wave = sin(r * (waveDensity + amp_mid * 15.0) - time_f * (4.0 + amp_peak * 3.0) + ripple * 10.0 + (fft * 10.0 * slider4));
92
93 // SLIDER 3: Chromatic shift multiplier (maps 0.0-1.0 to 0.1-5.0)
94 float shiftMult = mix(0.1, 5.0, slider3);
95 float shift = (ripple * 0.5 + wave * 0.01 + amp_peak * 0.015) * shiftMult;
96
97 // Chromatic split sampling
98 float r_chan = texture(samp, tc + vec2(shift, 0.0)).r;
99 float g_chan = texture(samp, tc).g;
100 float b_chan = texture(samp, tc - vec2(shift, 0.0)).b;
101 vec3 baseTex = vec3(r_chan, g_chan, b_chan);
102
103 // Rainbow hue shifts with smoothed amplitude and FFT data
104 vec3 rainbow = colorPalette(r - time_f * 0.5 + ripple + amp_smooth * 0.3 + (fft * slider4));
105 float glowMask = smoothstep(0.5, 1.0, wave);
106
107 // Central light expands with amp_rms / amp_smooth
108 float lightRadius = 6.0 - amp_smooth * 4.0 - amp_rms * 3.0;
109 lightRadius = max(lightRadius, 0.5);
110 float center = exp(-r * lightRadius);
111 float brightness = 1.5 + amp_peak * 2.0;
112 vec3 coreGlow = vec3(1.0, 0.98, 0.9) * center * brightness;
113
114 // Mix base texture with rainbow, using SLIDER 4 to boost FFT glow
115 vec3 finalColor = mix(baseTex, rainbow, glowMask * (0.35 + amp_rms * 0.3 + (fft * 0.5 * slider4)));
116 finalColor += coreGlow;
117
118 // Add the glitchy wave feedback
119 finalColor += (wave * ripple * (2.0 + amp_low * 3.0));
120
121 color = vec4(finalColor, 1.0);
122}
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 time_f
Definition 3high.frag:19
#define amp_smooth
#define amp_mid
#define amp_low
#define amp_high
#define amp_peak
vec3 wave(ivec2 p, ivec2 size)
Evaluates wave for this shader effect.
vec3 ripple(ivec2 p, ivec2 size)
Evaluates ripple for this shader effect.
vec3 rainbow(float t)
Evaluates rainbow for this shader effect.
#define amp_rms
Definition breathe.frag:21
vec3 colorPalette(float t)
Evaluates colorPalette for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.