def scatter(self, r_in: Ray, rec: HitRecord) \ -> Optional[Tuple[Ray, Color]]: reflected: Vec3 = r_in.direction().unit_vector().reflect(rec.normal) \ + Vec3.random_in_unit_sphere() * self.fuzz scattered = Ray(rec.p, reflected) attenuation = self.albedo if scattered.direction() @ rec.normal > 0: return scattered, attenuation return None
def scatter(self, r_in: Ray, rec: HitRecord) \ -> Optional[Tuple[Ray, Color]]: scattered = Ray(rec.p, Vec3.random_in_unit_sphere(), r_in.time()) attenuation = self.albedo.value(rec.u, rec.v, rec.p) return scattered, attenuation