// Set the default precision to medium. We don't need as high of a
// precision in the fragment shader.
precision mediump float; 

// This is the color from the vertex shader
varying vec4 v_Color;

uniform lowp vec4  texBrightness;
uniform lowp vec4  texContrast;
uniform lowp vec4  texAvLuminance;
uniform lowp vec4  texFading;

varying vec2 TexCoordOut;
uniform sampler2D Texture;

// The entry point for our fragment shader.    
void main()
{
    vec4 texColour = texFading + texture2D(Texture, TexCoordOut);
    vec4 adjustedTexColour = mix(texColour * texBrightness, mix(texAvLuminance, texColour, texContrast), 0.5);  

    // Pass the color directly through the pipeline.
    gl_FragColor = v_Color * adjustedTexColour;    
}