Perspective matrix, frustum and CameraPersp [Solved]

To calculate the lens shift, you’d need the left and right extremes of the frustum (for horizontal lens shift) and the top and bottom extremes for the vertical lens shift.

If LEFT == -RIGHT and TOP == -BOTTOM, there is no lens shift and the frustum is symmetrical.

If you look at the definition of an asymmetrical projection matrix, I think you may find the horizontal lens shift described as (l+r)/(r-l) and the vertical lens shift as (t+b)/(t-b). You could try to use those values from the matrix, just remember that you may have to swap column and row as the documentation is for DirectX which uses a different matrix notation.

Let me know if that worked.

-Paul

Edit: tried it and yes!

float lensShiftHorizontal = projectionMatrix[2][0];
float lensShiftVertical = projectionMatrix[2][1];