ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
rainbow_x_ink_wave.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file rainbow_x_ink_wave.frag
5 * @brief Vulkan fragment shader: rainbow x ink wave.
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 time_f ext.u2.y
26
27layout(location = 0) in vec2 tc;
28layout(location = 0) out vec4 color;
29layout(set = 0, binding = 0) uniform sampler2D samp;
30
31
32
33
34
35
36
37
38
39
40/**
41 * @brief Evaluates rainbow for this shader effect.
42 * @param t Input value for the calculation.
43 * @return Computed vec3 value.
44 */
45vec3 rainbow(float t) {
46 t = fract(t);
47 float r = abs(t * 6.0 - 3.0) - 1.0;
48 float g = 2.0 - abs(t * 6.0 - 2.0);
49 float b = 2.0 - abs(t * 6.0 - 4.0);
50 return clamp(vec3(r, g, b), 0.0, 1.0);
51}
52
53/**
54 * @brief Evaluates noise for this shader effect.
55 * @param p Input value for the calculation.
56 * @param s Input value for the calculation.
57 * @return Computed float value.
58 */
59float noise(vec2 p, sampler2D s) {
60 return texture(s, p * 0.1).r;
61}
62
63/**
64 * @brief Evaluates swirl for this shader effect.
65 * @param p Input value for the calculation.
66 * @param t Input value for the calculation.
67 * @param audioStr Input value for the calculation.
68 * @return Computed vec2 value.
69 */
70vec2 swirl(vec2 p, float t, float audioStr) {
71 float radius = length(p);
72 float swirlAmt = 0.5 + audioStr * 1.5;
73 float angle = atan(p.y, p.x) + sin(t + radius * 10.0 + noise(p * 10.0, samp) * 10.0) * swirlAmt;
74 return vec2(cos(angle), sin(angle)) * radius;
75}
76
77/**
78 * @brief Executes the fragment shader entry point.
79 */
80void main(void) {
81 float aLow = clamp(amp_low, 0.0, 1.0);
82 float aMid = clamp(amp_mid, 0.0, 1.0);
83 float aHigh = clamp(amp_high, 0.0, 1.0);
84 float aPk = clamp(amp_peak, 0.0, 1.0);
85 float aSmth = clamp(amp_smooth, 0.0, 1.0);
86
87 float mod_time = mod(time_f, 25.0);
88 vec2 uv = tc * 2.0 - 1.0;
89 uv.y *= iResolution.y / iResolution.x;
90
91 uv = swirl(uv, mod_time * 0.1, aLow);
92 uv *= 0.5 + aPk * 0.3;
93
94 float n = noise(uv * (0.5 + aHigh * 2.0) + mod_time * 0.05, samp);
95 float hueSpeed = mix(0.05, 0.3, aSmth);
96 vec3 rainbow_color = rainbow(n + mod_time * hueSpeed + aMid * 0.5);
97
98 vec4 tex = texture(samp, tc);
99 float inkSpread = 0.4 + aLow * 0.4;
100 vec3 blended = mix(tex.rgb, rainbow_color, inkSpread);
101
102 blended *= 1.0 + aPk * 0.6;
103 blended = mix(blended,
104 blended * vec3(1.0 + aLow * 0.2, 1.0 + aMid * 0.15, 1.0 + aHigh * 0.25),
105 aSmth);
106
107 color = vec4(blended, 1.0);
108}
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
float noise(vec2 p)
Evaluates noise for this shader effect.
vec3 rainbow(float t)
Evaluates rainbow for this shader effect.
vec2 swirl(vec2 uv, float centerRadius, float swirlAmount)
Evaluates swirl for this shader effect.
float n(vec2 p)
Evaluates n for this shader effect.