summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-03-14 23:20:47 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-03-14 23:23:19 +0100
commit5bcbaab8ea90655c2496c8df029a9cb991dba0ce (patch)
treebbd9414527c32d54a666d51f5294962f7f2ebbd8
parent893eb770f9c3dbe8c265fcabf197d3ed43d7784a (diff)
downloadcv-5bcbaab8ea90655c2496c8df029a9cb991dba0ce.tar.gz
cv-5bcbaab8ea90655c2496c8df029a9cb991dba0ce.tar.bz2
cv-5bcbaab8ea90655c2496c8df029a9cb991dba0ce.zip
wimmel.frag: Discard fragment early if difference is to significant
-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: