dasom/material/
lambertian.rs

1use crate::{ Color, HitRecord, Material, Ray, random_unit_vector };
2
3pub struct Lambertian {
4    albedo: Color
5}
6
7impl Lambertian {
8    pub fn new(albedo: Color) -> Self {
9        Self { albedo }
10    }
11}
12
13impl Material for Lambertian {
14    fn scatter(&self, _ray: Ray, hr: &HitRecord) -> Option< (Ray, Color) > {
15        Some((Ray::new(hr.p, hr.normal + random_unit_vector(-hr.normal)), self.albedo))
16    }
17}