aboutsummaryrefslogtreecommitdiff
path: root/src/material/sky_light.rs
blob: e499b6e5c3a3c4c2f27305896f066a7887301b3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use super::Material;
use crate::core::{Ray, Spectrum};

pub struct SkyLight {
}

impl SkyLight {
    pub fn new() -> Self {
        Self {}
    }
}

impl Material for SkyLight {
    fn emitted(&self, ray: &Ray) -> Option<Spectrum> {
        let t = (ray.direction.norm().y + 1.0) * 0.5;

        Some(Spectrum::new_rgb(1.0, 1.0, 1.0) * (1.0-t) + Spectrum::new_rgb(0.5, 0.7, 1.0) * t)
    }
}