I want to decompose projection matrices into near, far, top, bottom, left and right values to create a bounding box for view frustum. I used the formula described in this site Decompose the OpenGL projection matrix. This formula works for perspective which is created with frustum function (glFrustum). But it does not work for perspective which is created via perspective func (gluPerspective)
Frustum and perspective may create same perspective effect but generated matrices seems different. So it seems I can't use single formula to extract perspective parameters.
- Is there any proof of that decomposition formula, or does it always work?
- How do I decompose the matrix generated by perspective function into near, far, top, bottom, left and right values? Is there any formula which is already used in industry?
My implementations of ortho, frustum and perspetive is here: https://github.com/recp/cglm/blob/master/include/cglm/cam.h