geomancy-0.4.0.0: src/Geomancy/Vulkan/DProjection.hs
module Geomancy.Vulkan.DProjection
( reverseDepthRH
, reverseDepthOrthoRH
, orthoRH
) where
import Geomancy.DMat4 (colMajor)
import Geomancy.DTransform (DTransform(..))
reverseDepthRH
:: Double
-> Double
-> Double -> Double
-> DTransform
reverseDepthRH fovRads zn width height =
colMajor
sx 0 0 0
0 sy 0 0
0 0 0 zn
0 0 1 0
where
sx = sy * recipAspect
where
recipAspect = height / width
sy = 1 / tan (fovRads / 2)
orthoRH :: Double -> Double -> Double -> Double -> DTransform
orthoRH near far width height =
colMajor
sx 0 0 0
0 sy 0 0
0 0 z w
0 0 0 1
where
sx = 2 / width
sy = 2 / height
z = 1 / (far - near)
w = near / (near - far)
reverseDepthOrthoRH :: Double -> Double -> Double -> Double -> DTransform
reverseDepthOrthoRH near far width height =
colMajor
sx 0 0 0
0 sy 0 0
0 0 z w
0 0 0 1
where
sx = 2 / width
sy = 2 / height
z = 1 / (near - far)
w = far / (far - near)