From e09b0a9e1d37004d45c52ed317e3b5fc22cec384 Mon Sep 17 00:00:00 2001 From: Jonathan Flueren <11487762+JonOfUs@users.noreply.github.com> Date: Sun, 17 Jul 2022 02:22:09 +0200 Subject: [PATCH] First mesh render --- src/main.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7556afa..8bea18f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,7 +171,6 @@ fn random_world() -> HittableList { } fn from_obj(path: &str) -> HittableList { - let mut world = HittableList::new(); let material_ground = Arc::new(Lambertian::new(&Color::new(0.05, 0.05, 0.05))); @@ -216,30 +215,31 @@ fn from_obj(path: &str) -> HittableList { Point3::new( mesh.positions[3 * index_a] as f64, mesh.positions[3 * index_a + 1] as f64, - mesh.positions[3 * index_a + 2] as f64 + mesh.positions[3 * index_a + 2] as f64, ), Point3::new( mesh.positions[3 * index_b] as f64, mesh.positions[3 * index_b + 1] as f64, - mesh.positions[3 * index_b + 2] as f64 + mesh.positions[3 * index_b + 2] as f64, ), Point3::new( mesh.positions[3 * index_c] as f64, mesh.positions[3 * index_c + 1] as f64, - mesh.positions[3 * index_c + 2] as f64 + mesh.positions[3 * index_c + 2] as f64, ), - material.clone() + material.clone(), ))); } } return world; - } // The output is wrapped in a Result to allow matching on errors // Returns an Iterator to the Reader of the lines of the file. fn read_lines

(filename: P) -> io::Result>> -where P: AsRef, { +where + P: AsRef, +{ let file = File::open(filename)?; Ok(io::BufReader::new(file).lines()) } @@ -264,10 +264,10 @@ fn main() { // Image let aspect_ratio = 16.0 / 9.0; - let image_width = 200; + let image_width = 600; let image_height = (image_width as f64 / aspect_ratio) as u32; - let samples_per_pixel = 100_u32; - let max_depth = 5; + let samples_per_pixel = 50_u32; + let max_depth = 50; let vfov = 50.0; let lookfrom = Point3::new(30.0, 20.0, 30.0); @@ -276,6 +276,12 @@ fn main() { let dist_to_focus = 40.0; let aperture = 0.1; + // limit rayon multithreading thread count + let thread_count = 4; // if 0, for each logical cpu core a thread wil be created + if thread_count > 0 { + env::set_var("RAYON_NUM_THREADS", "4"); + } + let world = from_obj("obj/Lowpoly_tree_sample copy.obj"); // World