varying vec2 v_texcoord; uniform sampler2D tex; uniform sampler2D tex2; uniform vec2 pixelsize; /* The rect to match against */ uniform vec4 srect; uniform int barrier; void main() { int diff = 0; float i, j; for (i = 0.0; i < srect[2] && diff < barrier; i += pixelsize.x) { for (j = 0.0; j < srect[3] && diff < barrier; j += pixelsize.y) { vec4 orig = texture2D(tex, v_texcoord + vec2(i,j)); vec4 match = texture2D(tex2, vec2(i, j) / srect.zw); diff += int(any(greaterThan(abs(orig - match), vec4(0.2)))); } } gl_FragColor = vec4(float(diff < barrier), 0.0, 0.0, 1.0); } // vim:ft=c: