43 position = clamp(position, ivec2(0), size - 1);
44 return textureLod(samp, (vec2(position) + 0.5) / vec2(size), 0.0).rgb;
51 ivec2 position = ivec2(gl_GlobalInvocationID.xy);
52 ivec2 size = imageSize(outputImage);
53 if (any(greaterThanEqual(position, size)))
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));
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,
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));