ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
twist-code-chromatic-vortex.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file twist-code-chromatic-vortex.frag
5 * @brief Vulkan fragment shader: twist-code-chromatic-vortex.
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) in vec2 tc;
21layout(location = 0) out vec4 color;
22layout(set = 0, binding = 0) uniform sampler2D samp;
23
24
25
26/**
27 * @brief Evaluates vortexUV for this shader effect.
28 * @param tc0 Input value for the calculation.
29 * @param turn Input value for the calculation.
30 * @param radialShift Input value for the calculation.
31 * @return Computed vec2 value.
32 */
33vec2 vortexUV(vec2 tc0, float turn, float radialShift) {
34 float aspect = max(iResolution.x, 1.0) / max(iResolution.y, 1.0);
35 vec2 ar = vec2(aspect, 1.0);
36 vec2 p = (tc0 - 0.5) * ar;
37 float r = length(p) + 0.001;
38 float a = atan(p.y, p.x);
39 float wave = sin(r * 46.0 - time_f * 10.0 + a * 5.0);
40 a += time_f * 1.1 + turn / r + wave * 0.28;
41 r += radialShift + wave * 0.04;
42 return fract(vec2(cos(a), sin(a)) * r / ar + 0.5);
43}
44
45/**
46 * @brief Executes the fragment shader entry point.
47 */
48void main(void) {
49 vec2 ur = vortexUV(tc, 1.22, 0.012);
50 vec2 ug = vortexUV(tc, 1.05, 0.0);
51 vec2 ub = vortexUV(tc, 0.88, -0.012);
52 vec3 rgb = vec3(texture(samp, ur).r,
53 texture(samp, ug).g,
54 texture(samp, ub).b);
55 float r = length(tc - 0.5);
56 rgb *= 0.85 + 0.35 * sin(r * 70.0 - time_f * 9.0);
57 color = vec4(rgb, texture(samp, ug).a);
58}
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.
vec2 vortexUV(vec2 tc0, float turn, float radialShift)
Evaluates vortexUV for this shader effect.