ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
cosine_swirl.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file cosine_swirl.frag
5 * @brief Vulkan fragment shader: cosine swirl.
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 time_f ext.u2.y
19
20layout(location = 0) out vec4 color;
21layout(location = 0) in vec2 tc;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25
26/**
27 * @brief Evaluates rainbow for this shader effect.
28 * @param t Input value for the calculation.
29 * @return Computed vec3 value.
30 */
31vec3 rainbow(float t) {
32 float hue = mod(t, 1.0) * 6.0;
33 float c = 1.0;
34 float x = 1.0 - abs(mod(hue, 2.0) - 1.0);
35 vec3 rgb = (hue < 1.0) ? vec3(c, x, 0.0) :
36 (hue < 2.0) ? vec3(x, c, 0.0) :
37 (hue < 3.0) ? vec3(0.0, c, x) :
38 (hue < 4.0) ? vec3(0.0, x, c) :
39 (hue < 5.0) ? vec3(x, 0.0, c) :
40 vec3(c, 0.0, x);
41 return rgb;
42}
43
44/**
45 * @brief Executes the fragment shader entry point.
46 */
47void main(void) {
48 vec2 center = vec2(0.5, 0.5);
49 vec2 dir = tc - center;
50 float dist = length(dir);
51 float angle = atan(dir.y, dir.x);
52 float frequency = 1.0;
53 float amplitude = 3.0;
54 float spiralTime = sin(time_f * frequency) * amplitude;
55 float scale = 1.0;
56 float gradient_pos = mod(dist * scale + (angle + spiralTime) / (2.0 * 3.14159), 1.0);
57 vec3 color_gradient = rainbow(gradient_pos);
58 vec4 ctx = texture(samp, tc);
59 float time_t = mod(time_f, 10.0) + 2.0;
60 color = mix(cos(ctx * time_t), vec4(color_gradient, 1.0), 0.5);
61 color.a = 1.0;
62}
63
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 rainbow(float t)
Evaluates rainbow for this shader effect.
vec3 hue(float t)
Evaluates hue for this shader effect.
Definition auraXi1.frag:65
#define frequency
Definition ol.frag:13