fix perspective matrix computation
This commit is contained in:
parent
3de90e7618
commit
a8d4f11193
1 changed files with 10 additions and 6 deletions
|
|
@ -54,14 +54,18 @@
|
|||
mat)))))
|
||||
|
||||
(defun calc-frustum-scale (fovy)
|
||||
(/ 1.0 (tan (/ (maths:deg-to-rad fovy) 2.0))))
|
||||
(tan (/ (maths:deg-to-rad fovy) 2.0)))
|
||||
|
||||
(defun make-persp-matrix (fovy aspect near far)
|
||||
(let ((frustum-scale (calc-frustum-scale fovy)))
|
||||
(f44:mat frustum-scale 0.0 0.0 0.0
|
||||
0.0 (/ frustum-scale aspect) 0.0 0.0
|
||||
(let ((range (calc-frustum-scale fovy)))
|
||||
(let ((left (* (- range) aspect))
|
||||
(right (* range aspect))
|
||||
(bottom (- range))
|
||||
(top range))
|
||||
(f44:mat (/ (* near 2) (- right left)) 0.0 0.0 0.0
|
||||
0.0 (/ (* near 2) (- top bottom)) 0.0 0.0
|
||||
0.0 0.0 (/ (+ far near) (- near far)) -1.0
|
||||
0.0 0.0 (/ (* 2.0 far near) (- near far)) 0.0)))
|
||||
0.0 0.0 (/ (* 2.0 far near) (- near far)) 0.0))))
|
||||
|
||||
(defun make-ortho-matrix (width height)
|
||||
(f44:mat (/ 2.0 width) 0.0 0.0 -1.0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue