#version 120

#ifdef GL_ES 
precision mediump float;
#endif


uniform sampler2D u_texture;
// The inverse of the viewport dimensions along X and Y
uniform vec2 u_viewportInverse;
uniform float FXAA_REDUCE_MIN;
uniform float FXAA_REDUCE_MUL;
uniform float FXAA_SPAN_MAX;

varying vec4 v_color;
varying vec2 v_texCoords;


void main(){

	float offset[3] = float[3]( 0.0, 1.3846153846, 3.2307692308 );
	float weight[3] = float[3]( 0.2270270270, 0.3162162162, 0.0702702703 );

    vec3 texColor = texture2D(u_texture, v_texCoords).rgb;

	float d = distance(v_texCoords, vec2(0.5,0.5))/4;


	vec3 tc = vec3(1.0, 0.0, 0.0);

	vec2 uv = v_texCoords.xy;
	tc = texColor * weight[0];

	for (int i=1; i<3; i++){
		tc += texture2D(u_texture, uv + vec2(offset[i]/1920), 0.0).rgb \
		* weight[i] ;
		 tc += texture2D(u_texture, uv - vec2(offset[i]/1080), 0.0).rgb \
		 * weight[i] ;

		//  tc += texture2D(u_texture, uv + vec2(offset[i]/1920), 0.0).rgb \
		// * weight[i] ;
		//  tc += texture2D(u_texture, uv - vec2(offset[i]/1080), 0.0).rgb \
		//  * weight[i] ;
	}
	d*=2;
	vec3 mixer = mix(tc * (1-d*2), texColor, 1-d);

	//BLOOM
	//vec4 mixer2 = mix(vec4(mixer, 1.0), vec4(tc, .5), .1);

	gl_FragColor = vec4(mixer, 1.0);
}