summaryrefslogtreecommitdiff
path: root/src/fragment.glsl
blob: e2334663970a76204094d17cc260a9a6679d7848 (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
#version 330 core
out vec4 FragColor;

in vec2 texCoord;
in float randOffset;

uniform sampler2D texture0;
uniform sampler2D texture1;

/* thank you internet i guess 
 * note: this has terrible distribution, not sure if i care */
float
rand(vec2 co){
	return fract(sin(dot(co.xy ,vec2(12.9898,78.233))+randOffset) * 43758.5453);
}

void
main()
{
	vec4 col = mix(texture(texture0, texCoord),
	               texture(texture1, texCoord), 0.2);
	float gray = 0.2989 * col.r + 0.5870 * col.g + 0.1140 * col.b;
	if (gray + rand(texCoord) - 0.5 < 0.5)
		FragColor = vec4(vec3(0.0), 1.0);
	else
		FragColor = vec4(1.0);
}