 	float two_p = 2.0 * sqrt( r.x *  r.x +  r.y *  r.y +  (r.z + 1) *  (r.z + 1));
 	vOut = (mTexture * vec4(0.5 + r.x / two_p,0.5 - r.y / two_p,0,0)).xy;
 }
+//-----------------------------------------------------------------------------
+void FFP_GenerateTexCoord_EnvMap_Sphere(in 	mat4 mWorld,
+										in 	mat4 mView,
+										in 	mat4 mWorldIT,
+										in 	vec4 vPos,
+										in 	vec3 vNormal,
+										out vec2 vOut)
+{
+	mat4 worldview = mView * mWorld;
+	vec3 normal = normalize( (mWorldIT * vec4(vNormal,0.0)).xyz); 
+	vec3 eyedir =  normalize(worldview * vPos).xyz;
+	vec3 r = reflect(eyedir, normal);
+	float two_p = 2.0 * sqrt( r.x *  r.x +  r.y *  r.y +  (r.z + 1) *  (r.z + 1));
+	vOut = vec2(0.5 + r.x / two_p,0.5 - r.y / two_p);
+}
 
 //-----------------------------------------------------------------------------
 void FFP_GenerateTexCoord_EnvMap_Reflect(in mat4 mWorld, 

				   in vec3 f,
				   out vec4 t)
{
	t = texture(s, f);
}

//-----------------------------------------------------------------------------

						   in vec3 vNormal,
						   out vec3 vOut)
{
	vec3 vWorldNormal = (mat3(mWorldIT) * vNormal);
	vec3 vViewNormal  = (mat3(mView) * vWorldNormal);

	vOut = vViewNormal;
}
