diff options
author | Julian T <julian@jtle.dk> | 2021-02-06 17:27:42 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-02-06 17:27:42 +0100 |
commit | 0d5e6bd9363d5ed5c4f28174819fc0f5fd9aa586 (patch) | |
tree | f9ecafe7350ad616486e509ed55904295f505f83 /src/main.rs | |
parent | 1e83ea211055eb234b89c69b5d03602e3fcb98fb (diff) |
Reorganized scene module, and fixed bug in sphere intersect
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index c1383ad..c3d11e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use pathtrace::camera::{Camera, Film}; +use pathtrace::camera::{Camera, Film, CameraSettings}; use pathtrace::scene::Scene; use pathtrace::trace::Tracer; use pathtrace::scene::shapes::Sphere; @@ -9,17 +9,19 @@ use pathtrace::sample::UniformSampler; fn main() { let res = Vector2i::new_xy(500, 500); - let cam = Camera::new( - Vector3f::new_xyz(10.0, 0.0, 0.0), - Vector3f::new(0.0), - Vector3f::new_xyz(0.0, 0.1, 0.0), - 90.0, res, - ); + 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), + up: Vector3f::new_xyz(0.0, 1.0, 0.0), + fov: 90.0, + screensize: res, + }); let mut scn = Scene::new(); - scn.add_shape( - Box::new(Sphere::new(4.0, Vector3f::new(0.0))), - ); + scn.add_shapes(vec![ + Box::new(Sphere::new(0.5, Vector3f::new_xyz(0.0, 0.0, -1.0))), + Box::new(Sphere::new(100.0, Vector3f::new_xyz(0.0, -100.5, -1.0))), + ]); let tracer = Tracer::new(); @@ -30,7 +32,7 @@ fn main() { let mut film = Film::new(res); let tile = film.get_tile(&film.frame); - let mut task = RenderTask::new(Box::new(tile), 500); + let mut task = RenderTask::new(Box::new(tile), 10); task.render(&ctx, &mut sampler); film.commit_tile(&task.tile); |