precision mediump float;

varying lowp vec4 vColor;
varying vec2 vTexCoord;

uniform sampler2D u_texture;

uniform float brightness;
uniform float contrast;

void main() {
	vec4 color = vColor * texture2D(u_texture, vTexCoord);
	color.rgb /= color.a; // ignore alpha
	color.rgb = ((color.rgb - 0.5) * max(contrast, 0.0)) + 0.5; // apply contrast
	color.rgb += brightness; // apply brightness
	color.rgb *= color.a; // return alpha
	gl_FragColor = color;
}