ft (wip): textures

This commit is contained in:
2026-05-12 18:20:06 +02:00
parent 383f739808
commit 6a1e50fb7a
13 changed files with 222 additions and 6 deletions

View File

@@ -12,16 +12,20 @@ pub struct Hit {
n: Vec3,
mat: Arc<dyn Material>,
front_face: bool,
u: f32,
v: f32,
}
impl Hit {
pub fn new(t: f32, p: Vec3, n: Vec3, mat: Arc<dyn Material>, front_face: bool) -> Self {
pub fn new(t: f32, p: Vec3, n: Vec3, mat: Arc<dyn Material>, front_face: bool, u: f32, v: f32) -> Self {
Self {
t,
p,
n: if front_face { n } else { -n },
mat,
front_face,
u,
v
}
}
@@ -45,6 +49,10 @@ impl Hit {
self.front_face
}
pub fn uv(&self) -> (f32, f32) {
(self.u, self.v)
}
// TODO: use front_face to discard back-hits for culling
pub fn hit_list(hittables: &Vec<Arc<dyn Hittable>>, r: &Ray) -> Option<Hit> {
let mut closest: Option<Hit> = None;