         // shadow_result = max(0.0, min(shadow_out, distance_to_intersection) - shadow_in);
     }
 
-    // Scene
-    vec3 scene_radiance = vec3(0.0);
-    {
-        vec3 normal = normalize(texture(texture_normal, uv).xyz * 2.0 - 1.0);
-        vec3 point = camera + scene_point;
-
-        vec3 sky_irradiance;
-        vec3 sun_irradiance = GetSunAndSkyIrradiance( point.xyz - earth_center, normal, sun_direction, sky_irradiance);
-        scene_radiance = kSphereAlbedo * (1.0 / PI) * (sun_irradiance + sky_irradiance);
-
-        float shadow_length = (1.0 - get_shadow_factor(uv, point, texture_shadow)) * 100000.0;
-        vec3 transmittance;
-        vec3 in_scatter = GetSkyRadianceToPoint(camera - earth_center, point.xyz - earth_center, shadow_length, sun_direction, transmittance);
-        scene_radiance = scene_radiance * transmittance + in_scatter;
-    }
+
 
     // Sky
-    float shadow_length = max(0.0, shadow_out - shadow_in) * lightshaft_fadein_hack;
+    float shadow_length = max(scene_shadow_length, max(0.0, shadow_out - shadow_in)) * lightshaft_fadein_hack;
     vec3 transmittance;
     vec3 radiance = GetSkyRadiance(camera - earth_center, view_direction, shadow_length, sun_direction, transmittance);
 

            sun_irradiance * GetSunVisibility(point, sun_direction) +
            sky_irradiance * GetSkyVisibility(point));

        float shadow_length = max(0.0, min(shadow_out, distance_to_intersection) - shadow_in) * lightshaft_fadein_hack;
        vec3 transmittance;
        vec3 in_scatter = GetSkyRadianceToPoint(camera - earth_center, point - earth_center, shadow_length, sun_direction, transmittance);
        ground_radiance = ground_radiance * transmittance + in_scatter;

        vec3 sun_irradiance = GetSunAndSkyIrradiance( point - earth_center, normal, sun_direction, sky_irradiance);
        sphere_radiance = kSphereAlbedo * (1.0 / PI) * (sun_irradiance + sky_irradiance);

        float shadow_length = max(scene_shadow_length, max(0.0, min(shadow_out, distance_to_intersection) - shadow_in)) * lightshaft_fadein_hack;
        vec3 transmittance;
        vec3 in_scatter = GetSkyRadianceToPoint(camera - earth_center, point - earth_center, shadow_length, sun_direction, transmittance);
        sphere_radiance = sphere_radiance * transmittance + in_scatter;
