dasom 0.1.1

A toy ray tracing engine based on Ray Tracing In One Weekend in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{ Color, HitRecord, Material, Ray, random_unit_vector };

pub struct Lambertian {
    albedo: Color
}

impl Lambertian {
    pub fn new(albedo: Color) -> Self {
        Self { albedo }
    }
}

impl Material for Lambertian {
    fn scatter(&self, _ray: Ray, hr: &HitRecord) -> Option< (Ray, Color) > {
        Some((Ray::new(hr.p, hr.normal + random_unit_vector(-hr.normal)), self.albedo))
    }
}