#version 330
uniform sampler2D tex;
uniform float transp; 
uniform float tresh;
uniform float pixMult;

in  vec2 vsoTexCoord;

out vec4 fragColor;

// Source - https://stackoverflow.com/a/4275343
// Posted by appas, modified by community. See post 'Timeline' for change history
// Retrieved 2026-06-03, License - CC BY-SA 4.0
float rand(vec2 co){
    return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
}


void main(void) {
	vec2 randC = floor(vsoTexCoord * pixMult) / pixMult;
	if(rand(randC) >= tresh)
		discard;
	vec4 c = texture(tex, vsoTexCoord);
	fragColor = length(c.rgb) > 1.0 ? vec4(vec3(0.7),transp) : vec4(0.0);
}
