aboutsummaryrefslogtreecommitdiff
path: root/src/material/diffuse_light.rs
blob: fe462a873757d9db70b2f8d1dcca7aebe3a35f24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use super::Material;
use crate::core::{Ray, Spectrum};
use crate::Float;

pub struct DiffuseLight {
    color: Spectrum,
}

impl DiffuseLight {
    pub fn new(c: Spectrum) -> Self {
        Self {
            color: c,
        }
    }

    pub fn new_white(s: Float) -> Self {
        Self {
            color: Spectrum::new_rgb(s, s, s),
        }
    }
}

impl Material for DiffuseLight {
    fn emitted(&self, _: &Ray) -> Option<Spectrum> {
        Some(self.color)
    }
}