fn ray_color(world: Arc<dyn Hittable + Sync + Send>, r: Ray, depth: i32) -> Color {
        // If we've exceeded the ray bounce limit, no more light is gathered.
        if depth <= 0 {
            return Color::new(0.0, 0.0, 0.0);
        }

        if let Some(hit_record) = world.hit(&r, 0.001, f64::INFINITY) {
            return match hit_record.material.scatter(&r, &hit_record) {
                None => Color::new(0.0, 0.0, 0.0),
                Some((scattered, attenuation)) => {
                    attenuation * Image::ray_color(world, scattered, depth - 1)
                }
            };
        }

        let unit_direction = r.direction().normalized();
        let t = 0.5 * (unit_direction.y() + 1.0);
        (1.0 - t) * Color::new(1.0, 1.0, 1.0) + t * Color::new(0.5, 0.7, 1.0)
    }
/// Computes the color rendered for a given ray `r` with a maximum
/// recursion depth of `depth`
Computes the color rendered for a given ray `r` with a maximum
recursion depth of `depth`
Computes the color rendered for a given ray ` r ` with a maximum recursion depth of ` depth `
fn ray_color(world: Arc<dyn Hittable + Sync + Send>, r: Ray, depth: i32) -> Color {
        // If we've exceeded the ray bounce limit, no more light is gathered.
        if depth <= 0 {
            return Color::new(0.0, 0.0, 0.0);
        }
        if let Some(hit_record) = world.hit(&r, 0.001, f64::INFINITY) {
            return match hit_record.material.scatter(&r, &hit_record) {
                None => Color::new(0.0, 0.0, 0.0),
                Some((scattered, attenuation)) => {
                    attenuation * Image::ray_color(world, scattered, depth - 1)
                }
            };
        }
        let unit_direction = r.direction().normalized();
        let t = 0.5 * (unit_direction.y() + 1.0);
        (1.0 - t) * Color::new(1.0, 1.0, 1.0) + t * Color::new(0.5, 0.7, 1.0)
    }
fn ray_color ( world : Arc < dyn Hittable + Sync + Send > , r : Ray , depth : i32 ) -> Color { // If we've exceeded the ray bounce limit, no more light is gathered. if depth <= 0 { return Color :: new ( 0.0 , 0.0 , 0.0 ) ; } if let Some ( hit_record ) = world . hit ( & r , 0.001 , f64 :: INFINITY ) { return match hit_record . material . scatter ( & r , & hit_record ) { None => Color :: new ( 0.0 , 0.0 , 0.0 ) , Some ( ( scattered , attenuation ) ) => { attenuation * Image :: ray_color ( world , scattered , depth - 1 ) } } ; } let unit_direction = r . direction ( ) . normalized ( ) ; let t = 0.5 * ( unit_direction . y ( ) + 1.0 ) ; ( 1.0 - t ) * Color :: new ( 1.0 , 1.0 , 1.0 ) + t * Color :: new ( 0.5 , 0.7 , 1.0 ) }
Computes the color rendered for a given ray `r` with a maximum
recursion depth of `depth`
Computes the color rendered for a given ray ` r ` with a maximum recursion depth of ` depth `
world
Arc<dyn Hittable + Sync + Send>
r
Ray
depth
i32