 {
     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(

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


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

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

        if(0.0 <= hit_dist && hit_dist < far_dist)
        {
            const float cloud_absorption = 0.3;
            const float light_absorption = 0.3;
            const int march_count = 20;
            const vec3 cloud_speed = vec3(0.03, 0.03, 0.0) * TIME;
            const int light_march_count = 5;
            const bool inverse_ray_march = false;

            float march_step = cloud_thickness / float(march_count) / max(0.5, abs(eye_direction.y));
            float distortion = texture(texture_noise, ray_start_pos.xzy * 0.005 + cloud_speed * 0.5).x;

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

                // fade top and bottom
                float fade = (length(ray_pos - earth_center_pos.xyz) - cloud_bottom_height) / cloud_thickness;
                fade = pow(clamp((1.0 - abs(fade * 2.0 - 1.0)) * 2.0, 0.0, 1.0), 0.3);
                float cloud_density = get_cloud_density(ray_pos.xzy, cloud_speed, fade, distortion);

                float light_intensity = 1.0;
                for(int j=1; j<light_march_count; ++j)
                {
                    vec3 light_pos = ray_pos + sun_direction.xzy * float(j) * march_step;
                    float d = length(light_pos.xyz - earth_center_pos.xyz) - cloud_bottom_height;
                    float light_density = get_cloud_density(light_pos.xzy, cloud_speed, 1.0, distortion);
                    light_intensity *= 1.0 - light_density * light_absorption;
                    if(cloud_thickness < d || d < 0.0 || light_intensity <= 0.01)
                    {
                        break;
                    }
                }

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