uniform sampler2D tex;

//For shockwaves
uniform float time;
uniform vec2 center;	

//For grid fading																
uniform float sunPosX;
uniform float sunPosY;
uniform float texSizeX;
uniform float texSizeY;
uniform float gridFadeDist;
uniform float layerScale;

varying vec4 v_fragmentColor;						
varying vec2 v_texCoord;	




void main (void)
{

	vec4 color = texture2D(tex, v_texCoord);
	
	if(color.a > 0){

		 vec2 pixel_pos = v_texCoord.xy * vec2(texSizeX,texSizeY);
		 vec2 sun_pos = vec2(sunPosX, sunPosY);

		 float cut_of_dist = gridFadeDist * 0.66f;
		 float start_fading = gridFadeDist * 0.33f;
		 
		 float distance = distance(pixel_pos,sun_pos);
		 if(distance <= cut_of_dist*layerScale){
			color.a = 0;
		}else if(distance > cut_of_dist*layerScale && distance < gridFadeDist*layerScale){
			color.a = 0.1f * (0.66f - ((gridFadeDist*layerScale-distance)/(gridFadeDist*layerScale)));
		}else{
			color.a = 0.1f;
		}
		
		
		color.a = 1.0f;
	 }
	gl_FragColor = color;

}