 
 	if (wsCamPos.y < cloudMinAltitude)
 	{
-		float L = distance(PLANET_CENTER, wsCamPos);
-		float alpha = dot( normalize(PLANET_CENTER - wsCamPos), viewRay);
+		float L = wsCamPos.y + PLANET_RADIUS;
+		float alpha = dot(vec3(0.0f, -1.0f, 0.0f), viewRay);
 		float l1 = L * abs(alpha);
 		float d = sqrt(L * L - l1 * l1);
 		float r = PLANET_RADIUS + cloudMinAltitude;

	else
	{
		sampleDisSum = 0.0f;
		sampleDisMax = 1000.0f;
		startPos = wsCamPos;
		endPos = wsCamPos + viewRay * sampleDisMax;
	}
	startToCamDis = sampleDisSum;

	{
		float L = wsCamPos.y + PLANET_RADIUS;
		float alpha = dot(vec3(0.0f, -1.0f, 0.0f), viewRay);
		if (acos(alpha) > asin((cloudMaxAltitude + PLANET_RADIUS) / L)) return vec4(0.0);
		float l1 = L * alpha;
		float d = sqrt(L * L - l1 * l1);
		float r = PLANET_RADIUS + cloudMaxAltitude;
