precision mediump float;

uniform sampler2D texture;
uniform vec3 color;
uniform float alpha;

varying vec2 pass_TexCoords;

vec3 saturateColor(in vec3 color, in float a);

void main() {

    float a = texture2D(texture, pass_TexCoords).a * alpha;
    vec3 black = vec3(0.0, 0.0, 0.0);
    gl_FragColor.rgb = mix(color, black, 1.0 - a);
    gl_FragColor.a = a;

}

vec3 saturateColor(in vec3 color, in float a){

    float grayscale = (color.r * 0.299 + color.g * 0.587 + color. b * 0.114);
    float alpha = ((1.1 - a) * 0.5) * 40.0;

    return alpha * color + (1.0 - alpha) * vec3(grayscale, grayscale, grayscale);

}