wip: normal material

This commit is contained in:
2026-05-02 13:48:27 +02:00
parent c3d37f4758
commit ae73e626b9
10 changed files with 36 additions and 12 deletions

View 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.))
}
}