Use CheckerTexture for ground in book scene.
This commit is contained in:
parent
96d49e685f
commit
4206ad7289
@ -11,7 +11,9 @@ use material::Metal;
|
|||||||
use renderer::Opt;
|
use renderer::Opt;
|
||||||
use renderer::Scene;
|
use renderer::Scene;
|
||||||
use sphere::Sphere;
|
use sphere::Sphere;
|
||||||
|
use texture::CheckerTexture;
|
||||||
use texture::ConstantTexture;
|
use texture::ConstantTexture;
|
||||||
|
use texture::Texture;
|
||||||
use vec3::Vec3;
|
use vec3::Vec3;
|
||||||
|
|
||||||
pub fn new(opt: &Opt) -> Scene {
|
pub fn new(opt: &Opt) -> Scene {
|
||||||
@ -51,14 +53,22 @@ pub fn new(opt: &Opt) -> Scene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn random_scene(background_color: Vec3) -> Vec<Box<Hit>> {
|
fn random_scene(ground_color: Vec3) -> Vec<Box<Hit>> {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
|
let checker = true;
|
||||||
|
let ground_texture: Box<Texture> = if checker {
|
||||||
|
Box::new(CheckerTexture::new(
|
||||||
|
Box::new(ConstantTexture::new(Vec3::new(0., 0., 0.))),
|
||||||
|
Box::new(ConstantTexture::new(ground_color)),
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
Box::new(ConstantTexture::new(ground_color))
|
||||||
|
};
|
||||||
|
|
||||||
let mut objects: Vec<Box<Hit>> = vec![Box::new(Sphere::new(
|
let mut objects: Vec<Box<Hit>> = vec![Box::new(Sphere::new(
|
||||||
Vec3::new(0., -1000., 0.),
|
Vec3::new(0., -1000., 0.),
|
||||||
1000.,
|
1000.,
|
||||||
Box::new(Lambertian::new(Box::new(ConstantTexture::new(
|
Box::new(Lambertian::new(ground_texture)),
|
||||||
background_color,
|
|
||||||
)))),
|
|
||||||
))];
|
))];
|
||||||
let mut random = || rng.gen_range::<f32>(0., 1.);
|
let mut random = || rng.gen_range::<f32>(0., 1.);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user