More tries to fix Metal material

This commit is contained in:
Jonathan Flueren 2022-10-05 16:18:51 +02:00
parent fd9cbea2f6
commit a3644701b5
2 changed files with 6 additions and 6 deletions

View file

@ -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");

View 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;
}
}