ACMX Vulkan Shader Library
GLSL 4.50 shader effects for ACMX's Vulkan renderer
Loading...
Searching...
No Matches
acidcam_012_kaleido_slice_glitch.comp
Go to the documentation of this file.
1#version 450
2
3/**
4 * @file acidcam_012_kaleido_slice_glitch.comp
5 * @brief Vulkan compute shader: acidcam 012 kaleido slice glitch.
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
27const float TAU = 6.28318530718;
28
29/**
30 * @brief Evaluates hash11 for this shader effect.
31 * @param value Input value for the calculation.
32 * @return Computed float value.
33 */
34float hash11(float value) {
35 return fract(sin(value * 127.31) * 43758.5453);
36}
37
38/**
39 * @brief Evaluates source at for this shader effect.
40 * @param position Input value for the calculation.
41 * @param size Input value for the calculation.
42 * @return Computed vec3 value.
43 */
44vec3 source_at(vec2 position, ivec2 size) {
45 vec2 bounded_position = clamp(position, vec2(0.0), vec2(size - 1));
46 return textureLod(samp, (bounded_position + 0.5) / vec2(size), 0.0).rgb;
47}
48
49/**
50 * @brief Executes the compute shader entry point.
51 */
52void main() {
53 ivec2 position = ivec2(gl_GlobalInvocationID.xy);
54 ivec2 size = imageSize(outputImage);
55 if (any(greaterThanEqual(position, size)))
56 return;
57
58 float strength = clamp(alpha, 0.0, 1.0);
59 vec2 center = vec2(size) * 0.5;
60 vec2 delta = vec2(position) - center;
61 float radius = length(delta);
62 float angle = atan(delta.y, delta.x);
63 float slice_width = TAU / 10.0;
64 float slice = floor((angle + 0.5 * TAU) / slice_width);
65 float local_angle = mod(angle + 0.5 * TAU, slice_width);
66 local_angle = abs(local_angle - 0.5 * slice_width);
67
68 float frame_step = floor(float(iFrame) / 5.0);
69 float random_value = hash11(slice * 19.0 + frame_step);
70 float angle_error = (random_value - 0.5) * 0.75 * strength;
71 float radial_error = (hash11(slice * 43.0 + frame_step) - 0.5) *
72 min(vec2(size).x, vec2(size).y) * 0.18 * strength;
73 vec2 sample_position = center +
74 vec2(cos(local_angle + angle_error),
75 sin(local_angle + angle_error)) *
76 (radius + radial_error);
77
78 float channel_shift = (random_value - 0.5) * 30.0 * strength;
79 vec2 tangent = vec2(-sin(local_angle), cos(local_angle));
80 vec3 color;
81 color.r = source_at(sample_position + tangent * channel_shift, size).r;
82 color.g = source_at(sample_position, size).g;
83 color.b = source_at(sample_position - tangent * channel_shift, size).b;
84 imageStore(outputImage, position, vec4(clamp(color, 0.0, 1.0), 1.0));
85}
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 TAU
#define strength
Definition ol.frag:16