ft (wip): textures
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user