ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
codex_aurora_vortex.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file codex_aurora_vortex.frag
5 * @brief Vulkan fragment shader: codex aurora 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 iMouse ext.mouse
18#define iResolution ext.u0.zw
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 mirrorWrap for this shader effect.
30 * @param p Input value for the calculation.
31 * @return Computed vec2 value.
32 */
33vec2 mirrorWrap(vec2 p) {
34 return abs(fract(p) * 2.0 - 1.0);
35}
36
37/**
38 * @brief Evaluates rot for this shader effect.
39 * @param a Input value for the calculation.
40 * @return Computed mat2 value.
41 */
42mat2 rot(float a) {
43 float s = sin(a), c = cos(a);
44 return mat2(c, -s, s, c);
45}
46
47/**
48 * @brief Executes the fragment shader entry point.
49 */
50void main(void) {
51 float t = time_f * 0.5;
52 vec2 p = tc - 0.5;
53 p.x *= iResolution.x / max(iResolution.y, 1.0);
54 vec2 mouseUV = (iMouse.z > 0.0) ? (iMouse.xy / max(iResolution, vec2(1.0))) : vec2(0.5);
55 vec2 mouseP = mouseUV * 2.0 - 1.0;
56 mouseP.x *= iResolution.x / max(iResolution.y, 1.0);
57 p -= mouseP * 0.12;
58 float r = length(p);
59 float swirl = 2.5 * exp(-r * 1.8) * sin(t + r * 8.0);
60 vec2 q = rot(swirl) * p;
61 q += vec2(sin(q.y * 12.0 + t * 2.0), cos(q.x * 11.0 - t * 1.7)) * 0.025;
62 q += (mouseP - p) * 0.04 * smoothstep(0.95, 0.0, length(p - mouseP));
63 vec2 uv = mirrorWrap(q + 0.5);
64 vec3 c = texture(samp, uv).rgb;
65 float curtain = sin((q.x + q.y) * 18.0 + sin(q.x * 7.0 + t) * 3.0 - t * 2.0);
66 curtain = smoothstep(0.1, 1.0, curtain * 0.5 + 0.5);
67 vec3 aurora = 0.5 + 0.5 * cos(vec3(1.4, 3.2, 5.1) + q.y * 8.0 + t);
68 c = mix(c, c * aurora + aurora * 0.25, curtain * 0.65);
69 c *= 1.0 - smoothstep(0.55, 0.9, r) * 0.45;
70 color = vec4(c, 1.0);
71}
layout(set=0, binding=1, std140) uniform SpriteExtended
Definition 3high.frag:7
#define iMouse
Definition 3high.frag:17
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
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
Definition air-bowl.frag:52
vec3 aurora(float t)
Evaluates aurora for this shader effect.
vec2 swirl(vec2 uv, float centerRadius, float swirlAmount)
Evaluates swirl for this shader effect.
vec2 mirrorWrap(vec2 uv)
Evaluates mirrorWrap for this shader effect.