ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
twist_audio_ex_freq_layers.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file twist_audio_ex_freq_layers.frag
5 * @brief Vulkan fragment shader: twist audio ex freq layers.
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// Three layered twists from low/mid/high bands composed sequentially.
26/**
27 * @brief Evaluates twistOnce for this shader effect.
28 * @param uv Input value for the calculation.
29 * @param strength Input value for the calculation.
30 * @param t Input value for the calculation.
31 * @return Computed vec2 value.
32 */
33vec2 twistOnce(vec2 uv, float strength, float t) {
34 vec2 center = vec2(0.5);
35 vec2 d = uv - center;
36 float r = length(d);
37 float a = strength * (r - 1.0) + t;
38 float c = cos(a), s = sin(a);
39 return mat2(c, -s, s, c) * d + center;
40}
41
42/**
43 * @brief Executes the fragment shader entry point.
44 */
45void main(void) {
46 float lo = texture(spectrum, 0.05).r;
47 float md = texture(spectrum, 0.30).r;
48 float hi = texture(spectrum, 0.70).r;
49
50 vec2 uv = tc;
51 uv = twistOnce(uv, 1.0 + lo * 5.0, time_f * 0.5);
52 uv = twistOnce(uv, 1.0 + md * 4.0, -time_f * 0.7);
53 uv = twistOnce(uv, 1.0 + hi * 3.0, time_f * 1.1);
54
55 float ripple = sin(tc.x * 10.0 + time_f * 5.0) * 0.03;
56 ripple += sin(tc.y * 10.0 + time_f * 5.0) * 0.03;
57 vec2 rippleTC = tc + vec2(ripple);
58
59 color = texture(samp, mix(rippleTC, uv, 0.5));
60}
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 twistOnce(vec2 uv, float strength, float t)
Evaluates twistOnce for this shader effect.