use ray_tracing_core::prelude::*;

#[derive(Debug)]
pub struct DiffuseMaterial {
    albedo: Color,
}

impl DiffuseMaterial {
    pub fn new(color: Color) -> Self {
        Self {
            albedo: color * FloatConsts::FRAC_1_PI,
        }
    }
}

impl<R: Rng> Material<R> for DiffuseMaterial {
    fn eval(&self, _w_in: Dir3, w_out: Dir3, _rng: &mut R) -> Color {
        if w_out.y() >= 0.0 {
            self.albedo
        } else {
            Color::black()
        }
    }
}
