ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
rainbow_ink.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file rainbow_ink.frag
5 * @brief Vulkan fragment shader: rainbow ink.
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 iResolution ext.u0.zw
18#define random_seed ext.custom_uniforms[6].z
19#define time_f ext.u2.y
20
21layout(location = 0) in vec2 tc;
22layout(location = 0) out vec4 color;
23layout(set = 0, binding = 0) uniform sampler2D samp;
24
25
26
27
28/**
29 * @brief Evaluates rainbow for this shader effect.
30 * @param t Input value for the calculation.
31 * @return Computed vec3 value.
32 */
33vec3 rainbow(float t) {
34 t = fract(t);
35 float r = abs(t * 6.0 - 3.0) - 1.0;
36 float g = 2.0 - abs(t * 6.0 - 2.0);
37 float b = 2.0 - abs(t * 6.0 - 4.0);
38 return clamp(vec3(r, g, b), 0.0, 1.0);
39}
40
41/**
42 * @brief Evaluates noise for this shader effect.
43 * @param p Input value for the calculation.
44 * @return Computed float value.
45 */
46float noise(vec2 p) {
47 return texture(samp, p).r;
48}
49
50/**
51 * @brief Evaluates swirl for this shader effect.
52 * @param p Input value for the calculation.
53 * @param t Input value for the calculation.
54 * @param seed Input value for the calculation.
55 * @return Computed vec2 value.
56 */
57vec2 swirl(vec2 p, float t, float seed) {
58 float radius = length(p);
59 float angle = atan(p.y, p.x) + sin(t + radius * 10.0 + noise(p * 10.0 + seed) * 10.0) * 0.5;
60 return vec2(cos(angle), sin(angle)) * radius;
61}
62
63/**
64 * @brief Executes the fragment shader entry point.
65 */
66void main(void) {
67 float mod_time = mod(time_f, 25.0);
68 vec2 uv = tc * 2.0 - 1.0;
69 uv.y *= iResolution.y / iResolution.x;
70
71 uv = swirl(uv, mod_time * 0.1, random_seed);
72 uv *= 0.5;
73
74 float n = noise(uv * 0.5 + mod_time * 0.05);
75 vec3 rainbow_color = rainbow(n + mod_time * 0.1);
76
77 vec4 original_color = texture(samp, tc);
78 vec3 blended_color = mix(original_color.rgb, rainbow_color, 0.5);
79
80 color = vec4(rainbow_color, 1.0);
81
82 //color = vec4(blended_color, original_color.a);
83}
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 seed
Definition air-bowl.frag:20
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.
#define random_seed