diff --git a/tinyrender4/obj.go b/tinyrender4/obj.go index 2ba8970..18c5713 100644 --- a/tinyrender4/obj.go +++ b/tinyrender4/obj.go @@ -51,6 +51,8 @@ func (m *Mat44f) SetProjection(fov float32, near float32, far float32) { // 0 0 -f/(f-n) -1 // 0 0 -fn/(f-n) 0 // where S (scale) is 1 / tan(fov / 2) (assuming fov is radians) + // NOTE: -1 there is actually -1/c, where c is distance from viewer to + // projection plane. We fix it at 1 for now but... m.ZeroFill() scale := float32(1 / math.Tan(float64(fov)*0.5*math.Pi/180)) m.Set(0, 0, scale)