ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
color_swirl_c.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file color_swirl_c.frag
5 * @brief Vulkan fragment shader: color swirl c.
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 alpha ext.u0.x
18#define iResolution ext.u0.zw
19#define time_f ext.u2.y
20
21layout(location = 0) out vec4 color;
22layout(location = 0) in vec2 tc;
23layout(set = 0, binding = 0) uniform sampler2D samp;
24
25
26
27
28/**
29 * @brief Evaluates pingPong for this shader effect.
30 * @param x Input value for the calculation.
31 * @param length Input value for the calculation.
32 * @return Computed float value.
33 */
34float pingPong(float x, float length) {
35 float modVal = mod(x, length * 2.0);
36 return modVal <= length ? modVal : length * 2.0 - modVal;
37}
38
39/**
40 * @brief Evaluates smoothNoise for this shader effect.
41 * @param uv Input value for the calculation.
42 * @return Computed float value.
43 */
44float smoothNoise(vec2 uv) {
45 return sin(uv.x * 12.0 + uv.y * 14.0 + time_f * 0.8) * 0.5 + 0.5;
46}
47
48/**
49 * @brief Executes the fragment shader entry point.
50 */
51void main(void) {
52 vec2 uv = (tc * iResolution - 0.5 * iResolution) / iResolution.y;
53 float radius = length(uv);
54 float angle = atan(uv.y, uv.x);
55 float swirl = sin(time_f * 0.4) * 2.0;
56 angle += swirl * radius * 1.5;
57
58 float modRadius = pingPong(radius + time_f * 0.3, 0.8);
59 float wave = sin(radius * 12.0 - time_f * 3.0) * 0.5 + 0.5;
60
61 float cloudNoise = smoothNoise(uv * 3.0 + vec2(modRadius, angle * 0.5));
62 cloudNoise += smoothNoise(uv * 6.0 - vec2(time_f * 0.2, time_f * 0.1));
63 cloudNoise = pow(cloudNoise, 1.5);
64 float r = sin(angle * 3.0 + modRadius * 8.0 + wave * 2.0) * cloudNoise;
65 float g = sin(angle * 5.0 - modRadius * 6.0 + wave * 4.0) * cloudNoise;
66 float b = sin(angle * 7.0 + modRadius * 10.0 - wave * 3.0) * cloudNoise;
67
68 vec3 col = vec3(r, g, b) * 0.5 + 0.5;
69 vec3 texColor = texture(samp, tc).rgb;
70 col = mix(col, texColor, 0.25);
71 color = vec4(sin(col * pingPong(time_f * 1.5, 6.0) + 1.5), alpha);
72}
73
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
vec3 wave(ivec2 p, ivec2 size)
Evaluates wave for this shader effect.
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
Definition af_scale.frag:32
vec2 swirl(vec2 uv, float centerRadius, float swirlAmount)
Evaluates swirl for this shader effect.
#define alpha
Definition color_g.frag:17
float smoothNoise(vec2 uv)
Evaluates smoothNoise for this shader effect.