 {
     vec3 sun_direction = LIGHT_DIRECTION.xyz;
     vec3 relative_camera_pos = CAMERA_POSITION.xyz * atmosphere_ratio;
-    vec3 relative_point = relative_camera_pos + eye_direction * max(NEAR_FAR.x, dist) * atmosphere_ratio;
+    vec3 relative_point = relative_camera_pos + eye_direction.xyz * max(NEAR_FAR.x, dist) * atmosphere_ratio;
     vec3 N = normalize(relative_point - earth_center);
 
     sun_irradiance = GetSunAndSkyIrradiance(

        // apply altitude of camera
        ray_start_pos.y += CAMERA_POSITION.y;

        float dist_fade = clamp(1.0 - (hit_dist - min_dist) / (far_dist - min_dist), 0.0, 1.0);
        cloud.xyz = vec3(1.0, 1.0, 1.0) * LIGHT_COLOR.xyz * scene_radiance;

        if(0.0 <= hit_dist && hit_dist < far_dist)
        {
            const float opacity_absorption = 0.5;
            const float light_absorption = 0.2;
            const vec3 cloud_color = vec3(0.5, 0.5, 0.7);
            const int march_count = 30;
            const vec3 cloud_speed = vec3(0.03, 0.03, 0.0) * TIME;
            const vec3 light_color = vec3(1.0, 1.0, 1.0) * LIGHT_COLOR.xyz * scene_radiance;
            const int light_march_count = 5;
            const bool inverse_ray_march = false;

            float march_step = cloud_thickness / float(march_count);

            for(int i=0; i<march_count; ++i)
            {
                vec3 uvw;
                if(inverse_ray_march)
                {
                    uvw = ray_start_pos.xzy + eye_direction.xzy * float(march_count - i) * march_step;
                }
                else
                {
                    uvw = ray_start_pos.xzy + eye_direction.xzy * float(i) * march_step;
                }

                float weight = (length(uvw.xzy - earth_center_pos.xyz) - cloud_bottom_height) / cloud_thickness;
                weight = pow(clamp((1.0 - abs(weight * 2.0 - 1.0)) * 5.0, 0.0, 1.0), 0.1);
                float cloud_density = get_cloud_density(uvw, cloud_speed, weight);

                float light_intensity = 1.0;
                for(int j=1; j<light_march_count; ++j)
                {
                    vec3 uvw_light = uvw + sun_direction.xzy * float(j) * march_step;
                    float d = length(uvw_light.xzy - earth_center_pos.xyz) - cloud_bottom_height;
                    if(cloud_thickness < d || d < 0.0)
                    {
                        break;
                    }

                    float light_density = get_cloud_density(uvw_light, cloud_speed, 1.0);
                    light_intensity *= 1.0 - light_density * light_absorption;
                    if(light_intensity <= 0.01)
                    {
                        break;
                    }
                }

                if(inverse_ray_march)
                {
                    cloud.xyz = mix(cloud.xyz, light_color * light_intensity, cloud_density);
                    cloud.w = clamp(cloud.w + cloud_density, 0.0, 1.0);
                }
                else
                {
                    cloud.w = clamp(cloud.w + cloud_density, 0.0, 1.0);
                    cloud.xyz = mix(light_color * light_intensity, cloud.xyz, cloud.w);
                    if(1.0 <= cloud.w)
                    {
                        break;

    // Cloud
    vec4 cloud = vec4(0.0);
    const float cloud_height = 500.0;
    const float cloud_thickness = 250.0;
    const float min_dist = 1000.0;
    const float far_dist = NEAR_FAR.y * 2.0;

