ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
acidcam_018_chroma_phase_tear.comp
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file acidcam_018_chroma_phase_tear.comp
5 * @brief Vulkan compute shader: acidcam 018 chroma phase tear.
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 iFrame int(ext.u2.x)
19
20
21layout(local_size_x = 16, local_size_y = 16) in;
22layout(set = 0, binding = 5, rgba8) writeonly uniform image2D outputImage;
23layout(set = 0, binding = 0) uniform sampler2D samp;
24
25
26
27/**
28 * @brief Evaluates hash11 for this shader effect.
29 * @param value Input value for the calculation.
30 * @return Computed float value.
31 */
32float hash11(float value) {
33 return fract(sin(value * 73.156) * 43758.5453);
34}
35
36/**
37 * @brief Evaluates source at for this shader effect.
38 * @param position Input value for the calculation.
39 * @param size Input value for the calculation.
40 * @return Computed vec3 value.
41 */
42vec3 source_at(ivec2 position, ivec2 size) {
43 position = clamp(position, ivec2(0), size - 1);
44 return textureLod(samp, (vec2(position) + 0.5) / vec2(size), 0.0).rgb;
45}
46
47/**
48 * @brief Executes the compute shader entry point.
49 */
50void main() {
51 ivec2 position = ivec2(gl_GlobalInvocationID.xy);
52 ivec2 size = imageSize(outputImage);
53 if (any(greaterThanEqual(position, size)))
54 return;
55
56 float strength = clamp(alpha, 0.0, 1.0);
57 int band_height = max(3, int(mix(28.0, 5.0, strength)));
58 int band = position.y / band_height;
59 float frame_step = floor(float(iFrame) / 4.0);
60 float random_value = hash11(float(band) * 31.0 + frame_step);
61 int tear = int((random_value - 0.5) * float(size.x) * 0.22 * strength);
62 int phase = max(1, int(3.0 + 18.0 * strength));
63
64 ivec2 red_position = position + ivec2(tear + phase, 0);
65 ivec2 green_position = position + ivec2(tear / 3, 0);
66 ivec2 blue_position = position + ivec2(tear - phase, 0);
67 vec3 color = vec3(source_at(red_position, size).r,
68 source_at(green_position, size).g,
69 source_at(blue_position, size).b);
70
71 float tear_edge = step(float(band_height - 2), float(position.y % band_height));
72 vec3 inverted = vec3(1.0) - color.brg;
73 color = mix(color, inverted, tear_edge * step(0.76, random_value) * strength);
74 imageStore(outputImage, position, vec4(clamp(color, 0.0, 1.0), 1.0));
75}
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
float hash11(float value)
Evaluates hash11 for this shader effect.
vec3 source_at(vec2 position, ivec2 size)
Evaluates source at for this shader effect.
#define iFrame
Definition auraXi1.frag:18
#define alpha
Definition color_g.frag:17
#define strength
Definition ol.frag:16