#version 400

uniform vec4 color;
in vec2 fragTexCoord;
out vec4 result;
in int gl_SampleID;

//This takes the random number seed for this pixel
float rand(vec2 co){
    return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}

// This is the actual code that is executed.
void main( void )
{
	float val = rand(vec2(fragTexCoord.x, fragTexCoord.y+gl_SampleID));
	int thisMask = (1 << gl_SampleID);
	if( (color.a) > val)
	{
		result = color;	
		gl_SampleMask[0] += thisMask;
	}else{
		discard;
	}
}