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
pub mod glass;
pub mod matte;
pub mod metal;


use std::sync::Arc;

use crate::{
    HitData,
    Ray,
    Vec3
};



/// Basic trait that every material must implement.
pub trait Material: Sync + Send + 'static {
    /// Wraps the object implementing this trait with Atomic Rc pointer.
    ///
    /// Used for multithreading.
    fn into_arc(self) -> Arc<dyn Material>
        where
            Self: Material + Sized + 'static {
        Arc::new(self)
    }

    fn scatter(&self, ray_in: &Ray, hit_data: &HitData) -> (Vec3, Ray);
}