Skip to content
Snippets Groups Projects
Commit a3644701 authored by Jonathan Flueren's avatar Jonathan Flueren
Browse files

More tries to fix Metal material

parent fd9cbea2
Branches
No related tags found
No related merge requests found
......@@ -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");
......
......@@ -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;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment