From e7b523384ef2cf47c5a52cecb191670d19b74a26 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 21 Aug 2020 01:55:55 +0200 Subject: [PATCH] Fix perspective projection transform Please review this commit carefully, as I only partially know what I'm doing. I believe that setting `m44` to one for the perspective projection matrix is wrong. First, the sources I can find that explain this all set it to zero. Granted, I can't find many sources online that explain this clearly, but the few that I can find support my point (see Wikipedia[1] and this university lecture[2], for example). Second, I did some transformation on paper, to better understand this, and while the approaches in the cited sources starting making sense to me, I can't make head or tails of that one in the m44 position. It just seems to get in the way. So while I can't rule out that the way things currently are make total sense for reasons I don't understand yet, as of right now, it seems more like an oversight. [1] https://en.wikipedia.org/wiki/Transformation_matrix#Perspective_projection [2] https://courses.cs.washington.edu/courses/cse455/09wi/Lects/lect5.pdf, page 23 --- src/transform3d.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transform3d.rs b/src/transform3d.rs index 92b814a8..1489cac6 100644 --- a/src/transform3d.rs +++ b/src/transform3d.rs @@ -431,7 +431,7 @@ where /// 1 0 0 0 /// 0 1 0 0 /// 0 0 1 -1/d - /// 0 0 0 1 + /// 0 0 0 0 /// ``` pub fn perspective(d: T) -> Self where @@ -444,7 +444,7 @@ where _1(), _0(), _0(), _0(), _0(), _1(), _0(), _0(), _0(), _0(), _1(), -_1() / d, - _0(), _0(), _0(), _1(), + _0(), _0(), _0(), _0(), ) } }