After posting my last article relating glFrustum to the intrinsic camera matrix, I receieved some emails asking how the (now deprecated) gluPerspective function relates to the intrinsic matrix. We can show a similar result with gluPerspective
as we did with glFrustum
, namely that it is the product of a glOrtho
matrix and a (modified) intrinsic camera matrix, but in this case the intrinsic matrix has different constraints. I'll be re-using notation and concepts from the previous article, so if you aren't familiar with them, I recommend reading it first.
The matrix generated by gluPerspective
is
where
Like with glFrustum
, gluPerspective
permits no axis skew, but it also restricts the viewing volume to be centered around the camera's principal (viewing) axis. This means that the principal point offsets \(x_0\) and \(y_0\) must be zero, and the matrix generated by glOrtho
must be centered, i.e. bottom = -top
and left = -right
. The Persp matrix corresponding to the intrinsic matrix is:
where
and the NDC matrix is
where
It is easy to show that the product \((NDC \times Persp)\) is equivalent to the matrix generated by gluPerspective(fovy, aspect, near, far)
with
In my experience, the zero-skew assumption is usually reasonable, so glFrustum
can provide a decent approximation to the full intrinsic matrix. However there is quite often a non-negligible principal point offset (~ 2% of the image size), even in high-quality cameras. For this reason, gluPerspective
might be a good choice for quick-and-dirty demos, but for the most accurate simulation, you should use the full camera matrix like I described previously.