def scatter(self, r_in, rec): condition = (rec.t > 0) & rec.front_face scatter_direction = rec.normal + Vec3.random_unit_vector(len(r_in)) scattered = RayList(rec.p.mul_ndarray(condition), scatter_direction.mul_ndarray(condition)) attenuation = Vec3List.from_array(condition) * self.albedo return scattered, attenuation
def scatter(self, r_in: Ray, rec: HitRecord) \ -> Optional[Tuple[Ray, Color]]: if not rec.front_face: return None scatter_direction: Vec3 = rec.normal + Vec3.random_unit_vector() scattered = Ray(rec.p, scatter_direction, r_in.time()) attenuation = self.albedo.value(rec.u, rec.v, rec.p) return scattered, attenuation
def scatter(self, r_in: Ray, rec: HitRecord) \ -> Optional[Tuple[Ray, Color]]: scatter_direction: Vec3 = rec.normal + Vec3.random_unit_vector() scattered = Ray(rec.p, scatter_direction) attenuation = self.albedo return scattered, attenuation