示例#1
0
    def scatter(self, r_in, rec):
        condition = (rec.t > 0) & rec.front_face

        scatter_direction = Vec3.random_in_hemisphere(rec.normal)
        scattered = RayList(rec.p.mul_ndarray(condition),
                            scatter_direction.mul_ndarray(condition))
        attenuation = Vec3List.from_array(condition) * self.albedo
        return scattered, attenuation
示例#2
0
 def scatter(self, r_in: Ray, rec: HitRecord) \
         -> Optional[Tuple[Ray, Color]]:
     scatter_direction: Vec3 = Vec3.random_in_hemisphere(rec.normal)
     scattered = Ray(rec.p, scatter_direction)
     attenuation = self.albedo
     return scattered, attenuation