From 3deef4d969dd50ddf540b80fe43ef16af5c17169 Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Mon, 24 Jun 2024 22:51:51 +0100 Subject: Chapter 11 --- hittable.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'hittable.go') diff --git a/hittable.go b/hittable.go index 42599ab..ac5e996 100644 --- a/hittable.go +++ b/hittable.go @@ -11,12 +11,14 @@ type HitRecord struct { P Vec3 N Vec3 T float64 + F bool Mat Material } func (rec *HitRecord) SetFaceNormal(r Ray, out_n Vec3) { - if r.Direction.Dot(out_n) < 0 { - rec.N = out_n + rec.F = r.Direction.Dot(out_n) < 0; + if rec.F { + rec.N = out_n; } else { rec.N = out_n.Neg(); } -- cgit v1.2.1