UE4 is using Z reversed projection matrix. Does anyone know how this kind of matrix us build ? And why is it used ?

I understand the classic perspective projection matrix link text, but I don’t know what is a Z reversed projection matrix ?

Ideally I would like to build a UE4 projection matrix from its frustum coordinate (left, right, top, bottom, near, far).

Thank you

Hello, overseb

Reversed matrix is used for optimization.

The basic point of this technique lies in swapping Far and Near values in projection matrix.

When depth is calculated for a standard matrix, an addition of numbers of different orders may occur (for example, 50000 and 0.5). This operation is quite heavy due to specifics floating-point numbers representation. On the other hand, when reversed projection matrix is used, this behavior occurs only in the area, that is close to the camera. Thus, it is more effective.

Hope this helped!

Cheers!

hi

Thank you for your answer, I have learned something.

To complete, I have found that these reversed projection matrix are corresponding to left handed matrix (like D3D).

So I found my solution here : D3DXMatrixPerspectiveOffCenterLH function (D3dx9math.h) - Win32 apps | Microsoft Learn

Thanks