wip: normal material
This commit is contained in:
17
src/objects/materials/normal.rs
Normal file
17
src/objects/materials/normal.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
objects::{hit::Hit, materials::traits::Material},
|
||||
ray::Ray,
|
||||
vec3::Vec3,
|
||||
};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Normal {}
|
||||
|
||||
impl Material for Normal {
|
||||
fn scatter(&self, hit: &Hit, ray: &Ray) -> Option<(Ray, Vec3)> {
|
||||
let refl = ray.dir().reflect(hit.n()).get_unit();
|
||||
Some((Ray::new(*hit.p(), refl), (hit.n() + 1.) / 2.))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user