summaryrefslogtreecommitdiff
path: root/wimmel.frag
blob: b148852115630b6e75e9c3d5038ba4a05cb964c4 (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
varying vec2 v_texcoord;
uniform sampler2D tex;
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 match = texture2D(tex, srect.xy + vec2(i,j));
			vec4 orig = texture2D(tex, v_texcoord + vec2(i,j));

			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: