in vec2 texCoord;

uniform sampler2D colorMap;
uniform sampler2D effectMap;
uniform sampler2D starsMap;

uniform vec4 glColor;

uniform float testvalue;

uniform float scroll;

void main (void)
{
	///gl_FragColor = texture2D(colorMap, texCoord)*glColor;
	//vec4 col2 = texture2D(colorMap, texCoord);
	//if ((col2.r+col2.g+col2.b)/3.0<0.3) discard;

	//vec2 fxuv1=vec2(texCoord.x-scroll/4.0,texCoord.y-scroll/1.0);
	//vec2 fxuv2=vec2(texCoord.x-scroll/1.33/4.0,texCoord.y-scroll/1.33/1.0);
	//gl_FragColor = texture2D(colorMap, texCoord)*texture2D(effectMap, texCoord)*0.7;//+
	//texture2D(colorMap, texCoord)*texture2D(starsMap, fxuv1)+
	//texture2D(colorMap, texCoord)*texture2D(starsMap, fxuv2);
	//return;

	//gl_FragColor = texture2D(colorMap, texCoord);
	//return;
	const float xpixelsize = 1.0/1920.0;
	const float ypixelsize = 1.0/1080.0;
	vec4 col = vec4(0,0,0,0);
	float blursize = 5;//6.4/2.0*1.5f*testvalue;
	if (blursize<1) blursize = 1;
	for (float y=-blursize/2; y<blursize/2; y++){
		for (float x=-blursize/2; x<blursize/2; x++){
			vec2 uv=texCoord+vec2(x*xpixelsize,y*ypixelsize);
			uv.x=clamp(uv.x,2.0/1920.0,1.0-2.0/1920.0);
			uv.y=clamp(uv.y,2.0/1080.0,1.0-2.0/1080.0);
			col+=texture2D(colorMap, uv);
		}
	}
	col/=(blursize*blursize);
	col=clamp(col,0,1);
	if ((col.r+col.g+col.b)/3.0<testvalue) discard;
	//gl_FragColor = texture2D(colorMap, texCoord)*glColor;
	gl_FragColor = col*texture2D(effectMap, texCoord);;
}
