ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
xor_code_prismatic_bloom.frag
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file xor_code_prismatic_bloom.frag
5 * @brief Vulkan fragment shader: xor code prismatic bloom.
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.00, 0.31, 0.67)));
52}
53
54/**
55 * @brief Evaluates softBloom for this shader effect.
56 * @param uv Input value for the calculation.
57 * @return Computed vec3 value.
58 */
59vec3 softBloom(vec2 uv) {
60 vec2 px = 1.5 / 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 sum += texture(samp, uv + px).rgb;
67 sum += texture(samp, uv - px).rgb;
68 sum += texture(samp, uv + vec2(px.x, -px.y)).rgb;
69 sum += texture(samp, uv + vec2(-px.x, px.y)).rgb;
70 return sum / 16.0;
71}
72
73/**
74 * @brief Executes the fragment shader entry point.
75 */
76void main(void) {
77 vec2 p = tc - 0.5;
78 float radius = length(p);
79 float angle = atan(p.y, p.x);
80 float wave = sin(radius * 42.0 - time_f * 4.0 + angle * 6.0);
81 vec2 split = normalize(p + vec2(0.0001)) * (0.002 + 0.006 * wave);
82
83 vec3 prism =
84 vec3(texture(samp, tc + split).r, texture(samp, tc).g, texture(samp, tc - split).b);
85 vec3 bloom = softBloom(tc);
86 vec3 key = palette(radius * 1.8 + angle / 6.2831853 + time_f * 0.04);
87 vec3 bits = xorColor(prism, bloom * (1.8 + 0.7 * wave) + key * 0.35);
88
89 float halo = pow(0.5 + 0.5 * wave, 6.0);
90 vec3 result = mix(prism, bits, 0.42 + 0.28 * halo);
91 result = 1.0 - (1.0 - result) * (1.0 - key * halo * 0.55);
92 color = vec4(clamp(result, 0.0, 1.0), texture(samp, tc).a);
93}
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.
vec3 wave(ivec2 p, ivec2 size)
Evaluates wave for this shader effect.
uvec3 bytes(vec3 c)
Evaluates bytes for this shader effect.
vec3 prism(float t)
Evaluates prism for this shader effect.
vec3 bloom(float t)
Evaluates bloom for this shader effect.
vec3 xorColor(vec3 a, vec3 b)
Evaluates xorColor for this shader effect.
vec3 softBloom(vec2 uv)
Evaluates softBloom for this shader effect.