aboutsummaryrefslogtreecommitdiff
path: root/src/material/mod.rs
blob: cded09ba20dbce7d4dd06ccccf9391df86cab5a5 (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
28
29
30
31
32
mod lambertian;
pub use lambertian::Lambertian;
mod metal;
pub use metal::Metal;
mod dielectric;
pub use dielectric::Dielectric;
pub use dielectric::DielectricAttenuation;
mod diffuse_light;
pub use diffuse_light::DiffuseLight;
mod isotropic;
pub use isotropic::Isotropic;

use crate::ray::Ray;
use crate::vec3::Color;
use crate::{hittable::HitRecord, vec3::Point3};

pub trait Material: Send + Sync {
    fn emitted(&self, _: f64, _: f64, _: &Point3) -> Color {
        Color {
            x: 0.0,
            y: 0.0,
            z: 0.0,
        }
    }
    fn scatter(
        &self,
        ray_in: &Ray,
        hit_record: &HitRecord,
        attenuation: &mut Color,
        scattered: &mut Ray,
    ) -> bool;
}