 void calculateRayScatteringFromGround(in vec3 positionWC, in vec3 ray, in float atmosphereScale, in float innerRadius, out vec3 start, out float startOffset)
 {
     // Calculate the ray's starting position, then calculate its scattering offset
-    float cameraHeight = czm_eyeHeight + innerRadius;
-    start = normalize(positionWC) * cameraHeight;
+    float cameraHeight = length(positionWC);
+    start = positionWC;
     float height = length(start);
     float depth = exp((atmosphereScale / rayleighScaleDepth ) * (innerRadius - cameraHeight));
     float startAngle = dot(ray, start) / height;

void calculateRayScatteringFromSpace(in vec3 positionWC, in vec3 ray, in float innerRadius, in float outerRadius, inout float far, out vec3 start, out float startOffset)
{
    // Calculate the closest intersection of the ray with the outer atmosphere (which is the near point of the ray passing through the atmosphere)
    float cameraHeight = czm_eyeHeight + innerRadius;
    vec3 adjustedPositionWC = normalize(positionWC) * cameraHeight;

    float B = 2.0 * dot(adjustedPositionWC, ray);
    float C = cameraHeight * cameraHeight - outerRadius * outerRadius;
    float det = max(0.0, B * B - 4.0 * C);
    float near = 0.5 * (-B - sqrt(det));

    // Calculate the ray's starting position, then calculate its scattering offset
    start = adjustedPositionWC + ray * near;
    far -= near;
    float startAngle = dot(ray, start) / outerRadius;
    float startDepth = exp(-1.0 / rayleighScaleDepth);

    return czm_raySegment(t1, t2);
}

vec3 getAdjustedPosition(vec3 positionWC, float innerRadius)
{
  // Adjust the camera position so that atmosphere color looks the same wherever the eye height is the same
  float cameraHeight = czm_eyeHeight + innerRadius;
  return normalize(positionWC) * cameraHeight;
}

vec3 getTranslucentPosition(vec3 positionWC, vec3 outerPositionWC, float innerRadius, out bool intersectsEllipsoid)
{
    vec3 directionWC = normalize(outerPositionWC - positionWC);
    vec3 directionEC = czm_viewRotation * directionWC;
    czm_ray viewRay = czm_ray(vec3(0.0), directionEC);
    czm_raySegment raySegment = rayEllipsoidIntersection(viewRay, czm_ellipsoidInverseRadii);
    intersectsEllipsoid = raySegment.start >= 0.0;

    if (intersectsEllipsoid)
    {
        return positionWC + raySegment.stop * directionWC;
    }

    return getAdjustedPosition(positionWC, innerRadius);
}

void calculateMieColorAndRayleighColor(vec3 outerPositionWC, out vec3 mieColor, out vec3 rayleighColor)
{
    // Unpack attributes
