From 7301f5af4fc7cb7bc13a9d559183f2f095de47d0 Mon Sep 17 00:00:00 2001 From: Rosyid Haryadi Date: Sun, 2 Mar 2025 21:50:40 +0700 Subject: upd metal fuzz --- src/object.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/object.rs') diff --git a/src/object.rs b/src/object.rs index d9e2cc4..2192703 100644 --- a/src/object.rs +++ b/src/object.rs @@ -11,6 +11,7 @@ pub struct HitRecord { pub front_face: bool, pub material: MaterialType, pub color: Color, + pub fuzz: f32, } impl Default for HitRecord { @@ -22,6 +23,7 @@ impl Default for HitRecord { front_face: false, material: MaterialType::Diffuse, color:Color::new(0.0, 0.0, 0.0), + fuzz: 1.0, } } } @@ -41,13 +43,14 @@ pub struct Sphere { center: Point3, radius: f32, material: MaterialType, - color: Color + color: Color, + fuzz: f32, } impl Sphere { - pub fn new(center: Vec3, radius: f32, material: MaterialType, color: Color) -> Self { + pub fn new(center: Vec3, radius: f32, material: MaterialType, color: Color, fuzz: f32) -> Self { let radius = f32::max(0.0, radius); - Self { center, radius, material, color } + Self { center, radius, material, color, fuzz } } } @@ -80,6 +83,7 @@ impl Hittable for Sphere { rec.set_face_normal(r, outward_normal); rec.material = self.material.clone(); rec.color = self.color.clone(); + rec.fuzz = self.fuzz; true } -- cgit v1.2.3-70-g09d2