diff options
-rw-r--r-- | wimmel.frag | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/wimmel.frag b/wimmel.frag index b9271d7..d3cf745 100644 --- a/wimmel.frag +++ b/wimmel.frag @@ -12,19 +12,16 @@ main() float height = search_rect[3]; int diff = 0; - for (i = 0.0; i < width; i += pixelsize.x) { - for (j = 0.0; j < height; j += pixelsize.y) { + for (i = 0.0; i < width && diff < barrier; i += pixelsize.x) { + for (j = 0.0; j < height && diff < barrier; 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; } } - /* Only written if fragment is NOT discarded in loop */ - gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + gl_FragColor = vec4(float(diff < barrier), 0.0, 0.0, 1.0); } // vim:ft=c: |