summaryrefslogtreecommitdiff
path: root/wimmel.frag
blob: 58d633e37857a8b761960232ee5c36e3ac80f578 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);

			if (abs(orig.r - match.r) > 0.08)
				++diff;
		}
	}

	gl_FragColor = vec4(0.0, 0.0, float(diff < barrier), 1.0);
}

// vim:ft=c: