diff options
author | Julian T <julian@jtle.dk> | 2021-02-07 17:52:30 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-02-07 17:52:46 +0100 |
commit | c24d1e52b3f173ba5f4cc04f5a6a449a011a60c7 (patch) | |
tree | ff39abb0473a78aa15fbd2ab4c7f5c82660fe3ab /src/main.rs | |
parent | 33e747fa1c0957546c10e4d7b490ac7fbb0fd2d2 (diff) |
Add reflecting material
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 759cbf9..ac197a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ use pathtrace::scene::shapes::Sphere; use pathtrace::core::{Vector2i, Vector3f, Spectrum}; use pathtrace::render::{RenderContext, RenderTask}; use pathtrace::sample::UniformSampler; -use pathtrace::material::Lambertian; +use pathtrace::material::{Reflectant, Lambertian}; use std::rc::Rc; @@ -13,8 +13,8 @@ fn main() { let res = Vector2i::new_xy(500, 500); let cam = Camera::new(&CameraSettings { - target: Vector3f::new_xyz(0.0, 0.0, -1.0), - origin: Vector3f::new_xyz(0.0, 0.0, 0.0), + target: Vector3f::new_xyz(0.5, 0.0, -1.0), + origin: Vector3f::new_xyz(0.0, 0.0, 0.5), up: Vector3f::new_xyz(0.0, 1.0, 0.0), fov: 90.0, screensize: res, @@ -22,10 +22,12 @@ fn main() { let brown = Rc::new(Lambertian::new(Spectrum::new_rgb(0.5, 0.3, 0.0))); let blue = Rc::new(Lambertian::new(Spectrum::new_rgb(0.0, 0.3, 0.7))); + let metal = Rc::new(Reflectant::new(Spectrum::new_rgb(0.75, 0.75, 0.75), Some(0.1))); let mut scn = Scene::new(); scn.add_objects(vec![ - Object::new(blue.clone(), Box::new(Sphere::new(0.5, Vector3f::new_xyz(0.0, 0.0, -1.0)))), + Object::new(metal.clone(), Box::new(Sphere::new(0.5, Vector3f::new_xyz(0.0, 0.0, -1.0)))), + Object::new(blue.clone(), Box::new(Sphere::new(0.5, Vector3f::new_xyz(1.0, 0.0, -1.0)))), Object::new(brown.clone(), Box::new(Sphere::new(100.0, Vector3f::new_xyz(0.0, -100.5, -1.0)))), ]); @@ -38,7 +40,7 @@ fn main() { let mut film = Film::new(res); let tile = film.get_tile(&film.frame); - let mut task = RenderTask::new(Box::new(tile), 10); + let mut task = RenderTask::new(Box::new(tile), 100); task.render(&ctx, &mut sampler); film.commit_tile(&task.tile); |