fn color(r: &Ray, world: &Box<dyn Hitable>, depth: i32) -> Vec3 {
    match world.intersect(&r, 0.001, std::f32::MAX) {
        Some(hit) => {
            let scatter_info = hit.material.scatter(&r, &hit);
            match scatter_info {
                Some((scattered, attenuation)) => {
                    if depth < 50 {
                        attenuation * color(&scattered, world, depth + 1)
                    } else {
                        Default::default()
                    }
                }
                None => Default::default(),
            }
        }
        None => {
            let unit_direction = unit_vector(&r.direction());
            let t = 0.5 * (unit_direction.y() + 1.);
            (1. - t) * Vec3(1., 1., 1.) + t * Vec3(0.5, 0.7, 1.0)
        }
    }
}
// For now the color is a simple gradient background.
For now the color is a simple gradient background.
For now the color is a simple gradient background .
fn color(r: &Ray, world: &Box<dyn Hitable>, depth: i32) -> Vec3 {
    match world.intersect(&r, 0.001, std::f32::MAX) {
        Some(hit) => {
            let scatter_info = hit.material.scatter(&r, &hit);
            match scatter_info {
                Some((scattered, attenuation)) => {
                    if depth < 50 {
                        attenuation * color(&scattered, world, depth + 1)
                    } else {
                        Default::default()
                    }
                }
                None => Default::default(),
            }
        }
        None => {
            let unit_direction = unit_vector(&r.direction());
            let t = 0.5 * (unit_direction.y() + 1.);
            (1. - t) * Vec3(1., 1., 1.) + t * Vec3(0.5, 0.7, 1.0)
        }
    }
}
fn color ( r : & Ray , world : & Box < dyn Hitable > , depth : i32 ) -> Vec3 { match world . intersect ( & r , 0.001 , std :: f32 :: MAX ) { Some ( hit ) => { let scatter_info = hit . material . scatter ( & r , & hit ) ; match scatter_info { Some ( ( scattered , attenuation ) ) => { if depth < 50 { attenuation * color ( & scattered , world , depth + 1 ) } else { Default :: default ( ) } } None => Default :: default ( ) , } } None => { let unit_direction = unit_vector ( & r . direction ( ) ) ; let t = 0.5 * ( unit_direction . y ( ) + 1. ) ; ( 1. - t ) * Vec3 ( 1. , 1. , 1. ) + t * Vec3 ( 0.5 , 0.7 , 1.0 ) } } }
For now the color is a simple gradient background.
For now the color is a simple gradient background .
r
&Ray
world
&Box<dyn Hitable>
depth
i32