diff --git a/rtiow/src/scenes/tutorial.rs b/rtiow/src/scenes/tutorial.rs index 7e1ab89..2c172e6 100644 --- a/rtiow/src/scenes/tutorial.rs +++ b/rtiow/src/scenes/tutorial.rs @@ -9,7 +9,9 @@ use crate::moving_sphere::MovingSphere; use crate::renderer::Opt; use crate::renderer::Scene; use crate::sphere::Sphere; +use crate::texture::CheckerTexture; use crate::texture::ConstantTexture; +use crate::texture::Texture; use crate::vec3::Vec3; pub fn new(opt: &Opt) -> Scene { @@ -30,23 +32,26 @@ pub fn new(opt: &Opt) -> Scene { time_min, time_max, ); - let ground_color = if opt.use_accel { - ConstantTexture::new(Vec3::new(1.0, 0.4, 0.4)) + let ground_color: Box = if opt.use_accel { + Box::new(CheckerTexture::new( + ConstantTexture::new([0., 0., 0.]), + ConstantTexture::new([1.0, 0.4, 0.4]), + )) } else { - ConstantTexture::new(Vec3::new(0.4, 1.0, 0.4)) + Box::new(ConstantTexture::new(Vec3::new(0.4, 1.0, 0.4))) }; let objects: Vec> = vec![ //let world: Box = Box::new(HitableList::new(vec![ - Box::new(Sphere::new([1., 0., 0.], 0.5, Dielectric::new(1.5))), + Box::new(Sphere::new([1., 0.5, 1.], 0.5, Dielectric::new(1.5))), Box::new(Sphere::new( Vec3::new(0., 0., -1.), 0.5, Lambertian::new(ConstantTexture::new(Vec3::new(0.1, 0.2, 0.5))), )), Box::new(Sphere::new( - Vec3::new(0., -100.5, -1.), - 100., + Vec3::new(0., -1000.5, -1.), + 1000., Lambertian::new(ground_color), )), Box::new(Sphere::new( diff --git a/rtiow/src/texture/mod.rs b/rtiow/src/texture/mod.rs index f732300..c33e534 100644 --- a/rtiow/src/texture/mod.rs +++ b/rtiow/src/texture/mod.rs @@ -25,6 +25,12 @@ impl Texture for Arc { } } +impl Texture for Box { + fn value(&self, u: f32, v: f32, p: Vec3) -> Vec3 { + (**self).value(u, v, p) + } +} + #[cfg(test)] mod test { use super::*;