43 position = clamp(position, ivec2(0), size - 1);
44 vec2 uv = (vec2(position) + 0.5) / vec2(size);
45 return textureLod(samp, uv, 0.0).rgb;
52 ivec2 position = ivec2(gl_GlobalInvocationID.xy);
53 ivec2 size = imageSize(outputImage);
54 if (any(greaterThanEqual(position, size)))
return;
57 ivec2 origin = ivec2((position.x / span) * span, position.y);
58 vec3 selected =
source_at(position, size);
59 float selected_luma =
luminance(selected);
60 bool choose_high = ((position.x / span + position.y / 8 +
iFrame / 9) & 1) == 0;
61 for (
int index = 0; index < span; ++index) {
62 vec3 candidate =
source_at(origin + ivec2(index, 0), size);
63 float candidate_luma =
luminance(candidate);
64 if ((choose_high && candidate_luma > selected_luma) || (!choose_high && candidate_luma < selected_luma)) {
66 selected_luma = candidate_luma;
70 imageStore(outputImage, position, vec4(mix(source, selected,
alpha * 0.85), 1.0));