ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
xor_code_rgb_smooth_aurora_blend.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file xor_code_rgb_smooth_aurora_blend.frag
5 * @brief Vulkan fragment shader: xor code rgb smooth aurora blend.
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 bytes for this shader effect.
28 * @param c Input value for the calculation.
29 * @return Computed uvec3 value.
30 */
31uvec3 bytes(vec3 c) {
32 return uvec3(clamp(floor(c * 255.0 + 0.5), 0.0, 255.0));
33}
34
35/**
36 * @brief Evaluates xorColor for this shader effect.
37 * @param a Input value for the calculation.
38 * @param b Input value for the calculation.
39 * @return Computed vec3 value.
40 */
41vec3 xorColor(vec3 a, vec3 b) {
42 return vec3((bytes(a) ^ bytes(b)) & uvec3(255u)) / 255.0;
43}
44
45/**
46 * @brief Evaluates palette for this shader effect.
47 * @param t Input value for the calculation.
48 * @return Computed vec3 value.
49 */
50vec3 palette(float t) {
51 return 0.52 + 0.48 * cos(6.2831853 * (t + vec3(0.08, 0.40, 0.74)));
52}
53
54/**
55 * @brief Evaluates softFilter for this shader effect.
56 * @param uv Input value for the calculation.
57 * @return Computed vec3 value.
58 */
59vec3 softFilter(vec2 uv) {
60 vec2 px = 1.4 / max(iResolution, vec2(1.0));
61 vec3 sum = texture(samp, uv).rgb * 4.0;
62 sum += texture(samp, uv + vec2(px.x, 0.0)).rgb * 2.0;
63 sum += texture(samp, uv - vec2(px.x, 0.0)).rgb * 2.0;
64 sum += texture(samp, uv + vec2(0.0, px.y)).rgb * 2.0;
65 sum += texture(samp, uv - vec2(0.0, px.y)).rgb * 2.0;
66 return sum / 12.0;
67}
68
69/**
70 * @brief Executes the fragment shader entry point.
71 */
72void main(void) {
73 float aspect = max(iResolution.x, 1.0) / max(iResolution.y, 1.0);
74 vec2 p = (tc - 0.5) * vec2(aspect, 1.0);
75 float curtain = sin(p.x * 5.0 + time_f * 0.55 + sin(p.y * 3.0 - time_f * 0.3) * 2.0);
76 curtain += 0.35 * sin(p.x * 11.0 - time_f + p.y * 4.0);
77 vec2 flow = vec2(curtain * 0.008, sin(p.x * 4.0 + time_f * 0.4) * 0.006);
78
79 vec3 base = softFilter(tc + flow);
80 vec3 neighbor = softFilter(tc - flow * 0.65).gbr;
81 float key = 1.4 + 0.6 * sin(time_f * 0.18) + curtain * 0.16;
82 vec3 bits = xorColor(base, neighbor * key);
83 vec3 aurora = palette(p.y * 0.18 + curtain * 0.12 + time_f * 0.02);
84
85 float veil = smoothstep(-0.8, 0.9, curtain);
86 vec3 result = mix(base, bits, 0.24 + veil * 0.24);
87 result = mix(result, sqrt(max(result, 0.0)) * aurora, 0.28 + veil * 0.16);
88 result += aurora * pow(max(curtain, 0.0), 7.0) * 0.12;
89 color = vec4(clamp(result, 0.0, 1.0), texture(samp, tc).a);
90}
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 palette(float phase)
Evaluates palette for this shader effect.
uvec3 bytes(vec3 c)
Evaluates bytes for this shader effect.
vec3 aurora(float t)
Evaluates aurora for this shader effect.
vec3 xorColor(vec3 a, vec3 b)
Evaluates xorColor for this shader effect.
vec3 softFilter(vec2 uv)
Evaluates softFilter for this shader effect.