 
 varying vec3 pos;
 uniform vec3 skycolor;
-float phase(float cosangle, float c) {
-	float a = 9/(2.0f*(c*c+2.0f))-3.0f/2.0f;
-	float b = (1.0f*cosangle*cosangle)/(pow(1.0f+c*c-2.0f*c*cosangle,1.5));
-	return a*b;
+
+float phase(float alpha, float g){
+    float a = 3.0*(1.0-g*g);
+    float b = 2.0*(2.0+g*g);
+    float c = 1.0+alpha*alpha;
+    float d = pow(1.0+g*g-2.0*g*alpha, 1.5);
+    return (a/b)*(c/d);
 }
+
 vec3 absorb(float dist, vec3 color, float factor){
     return color-color*pow(skycolor, vec3(factor/dist));
 }
-const int step_count = 32;
+const int step_count = 16;
 void main()
 {
     if (pos.y < 0) {

		mie*mie_collected +
		rayleigh*rayleigh_collected
	);
    gl_FragColor = vec4(color,1);
}


		float sample_depth = atmospheric_depth(sample_pos,light_dir);

		vec3 influx = absorb(sample_depth, vec3(1.8), 6000)*extinction;

		rayleigh_collected += absorb(sqrt(sample_distance), skycolor*influx, 23900.0);
		mie_collected += absorb(sample_distance, influx, 36400.0);
	}

	float eye_extinction = 1/*horizon_extinction(eye_position, ray,surface_height - 0.3)*/;
	rayleigh_collected = (
		rayleigh_collected *
		eye_extinction *
		pow(eye_atmo_dist / 2500e3, 1)
	)/float(step_count);
	mie_collected = (
		mie_collected *
		eye_extinction *
		pow(eye_atmo_dist / 2500e3, 1)
	)/float(step_count);

	vec3 color = vec3(
