
#version 150

out vec3 c;
in vec4 pos;
in vec4 gpos;

uniform float distort;

void main(void)
{
	vec2 pc = (gl_PointCoord.xy-vec2(0.5,0.5))*2.f;
	vec3 py = max(vec3(0.f), 105.f-abs(pos.yyy));
	vec3 m = pos.yyy*2;
	c = 1.f-min(vec3(1.0f),
			pow(sqrt(vec3(dot(pc,pc))),
				vec3(2.f))
			);
	c *= max(vec3(0.f),vec3(0.4+distort*0.1f,0.7,0.1)*m)
	+	 max(vec3(0.f),vec3(max(-0.7,-0.1-distort*0.2f),-0.1,-0.7/(distort*0.05+1))*m)
	+	vec3(8,5,1)*py;
	c *= clamp(16000-gpos.z,0,16000)*0.001/16.f;
}
