From a3644701b5f1b8a2d8dca26c404f939aaf93564b Mon Sep 17 00:00:00 2001 From: Jonathan Flueren Date: Wed, 5 Oct 2022 16:18:51 +0200 Subject: [PATCH] More tries to fix Metal material --- src/main.rs | 8 ++++---- src/material.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9720837..b0de8a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,7 @@ fn ray_color(r: &Ray, world: &HittableList, depth: u32) -> Color { { return attenuation * ray_color(&scattered, world, depth - 1); } - return Color::null(); + return Color::new(255.0, 0.0, 0.0);//Color::null(); } let unit_direction = r.direction(); @@ -67,7 +67,7 @@ fn main() { // Image let aspect_ratio = 10.0 / 7.5; //16.0 / 9.0; - let image_width = 300; + let image_width = 1200; let image_height = (image_width as f64 / aspect_ratio) as u32; let samples_per_pixel = 1_u32; let max_depth = 50; @@ -287,10 +287,10 @@ fn from_obj(path: &str) -> HittableList { // 118.0 / 255.0, //))); //let material = Arc::new(Dielectric::new(2.0)); - let material = Arc::new(Metal::new(&Color::new(0.7, 0.6, 0.5), 0.0)); + let material = Arc::new(Metal::new(&Color::new(0.5, 0.55, 0.7), 0.0)); //let material = Arc::new(Rainbow::new()); - let rotate_obj = 0; // rotate clockwise, 0: 0, 1: 90, 2: 180, 3: 270 + let rotate_obj = 1; // rotate clockwise, 0: 0, 1: 90, 2: 180, 3: 270 let cornell_box = tobj::load_obj(path, &tobj::OFFLINE_RENDERING_LOAD_OPTIONS); let (models, materials) = cornell_box.expect("Failed to load OBJ file"); diff --git a/src/material.rs b/src/material.rs index 5004352..a366283 100644 --- a/src/material.rs +++ b/src/material.rs @@ -77,13 +77,13 @@ impl Material for Metal { *scattered = Ray::new(rec.p, reflected + self.fuzz * Vec3::random_in_unit_sphere()); *attenuation = self.albedo.clone(); - let reflect = Vec3::dot(scattered.direction(), rec.normal); + let reflect = Vec3::dot(r_in.direction(), rec.normal); //dbg!(reflect); /*if reflect > 0.0 { *attenuation = Color::new(100.0, 0.0, 0.0); }*/ - return reflect > 0.0; + return true;//reflect > 0.0; } }