ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
twist_audio_ex_chromatic.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file twist_audio_ex_chromatic.frag
5 * @brief Vulkan fragment shader: twist audio ex chromatic.
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 time_f ext.u2.y
18
19layout(location = 0) in vec2 tc;
20layout(location = 0) out vec4 color;
21layout(set = 0, binding = 0) uniform sampler2D samp;
22
23layout(set = 0, binding = 3) uniform sampler1D spectrum;
24
25// Per-channel twist offsets create chromatic aberration tied to spectrum bands.
26/**
27 * @brief Evaluates twistAt for this shader effect.
28 * @param uv Input value for the calculation.
29 * @param strength Input value for the calculation.
30 * @return Computed vec2 value.
31 */
32vec2 twistAt(vec2 uv, float strength) {
33 vec2 center = vec2(0.5);
34 vec2 d = uv - center;
35 float r = length(d);
36 float a = strength * (r - 1.0) + time_f;
37 float c = cos(a), s = sin(a);
38 return mat2(c, -s, s, c) * d + center;
39}
40
41/**
42 * @brief Executes the fragment shader entry point.
43 */
44void main(void) {
45 float r = texture(spectrum, 0.05).r;
46 float g = texture(spectrum, 0.30).r;
47 float b = texture(spectrum, 0.65).r;
48
49 float ripple = sin(tc.x * 10.0 + time_f * 5.0) * 0.03;
50 ripple += sin(tc.y * 10.0 + time_f * 5.0) * 0.03;
51 vec2 rippleTC = tc + vec2(ripple);
52
53 vec2 tR = twistAt(tc, 1.0 + r * 5.0);
54 vec2 tG = twistAt(tc, 1.0 + g * 5.0);
55 vec2 tB = twistAt(tc, 1.0 + b * 5.0);
56
57 color.r = texture(samp, mix(rippleTC, tR, 0.5)).r;
58 color.g = texture(samp, mix(rippleTC, tG, 0.5)).g;
59 color.b = texture(samp, mix(rippleTC, tB, 0.5)).b;
60 color.a = 1.0;
61}
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 time_f
Definition 3high.frag:19
vec3 ripple(ivec2 p, ivec2 size)
Evaluates ripple for this shader effect.
vec3 spectrum(float t)
Evaluates spectrum for this shader effect.
#define strength
Definition ol.frag:16
vec2 twistAt(vec2 uv, float strength)
Evaluates twistAt for this shader effect.