summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wimmel.frag9
1 files changed, 6 insertions, 3 deletions
diff --git a/wimmel.frag b/wimmel.frag
index d3cf745..b9271d7 100644
--- a/wimmel.frag
+++ b/wimmel.frag
@@ -12,16 +12,19 @@ main()
float height = search_rect[3];
int diff = 0;
- for (i = 0.0; i < width && diff < barrier; i += pixelsize.x) {
- for (j = 0.0; j < height && diff < barrier; j += pixelsize.y) {
+ for (i = 0.0; i < width; i += pixelsize.x) {
+ for (j = 0.0; j < height; j += pixelsize.y) {
vec4 match = texture2D(tex, search_rect.xy + vec2(i,j));
vec4 orig = texture2D(tex, v_texcoord + vec2(i,j));
diff += int(any(greaterThan(abs(orig - match), vec4(0.2))));
+ if (diff >= barrier)
+ discard;
}
}
- gl_FragColor = vec4(float(diff < barrier), 0.0, 0.0, 1.0);
+ /* Only written if fragment is NOT discarded in loop */
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
// vim:ft=c: