mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
Fix accidentally reintroducing clipping problems with high FOV (Thanks Cheesse)
This commit is contained in:
parent
15dcbaf353
commit
72b354b16a
@ -922,11 +922,12 @@ void Gfx_CalcOrthoMatrix(float width, float height, struct Matrix* matrix) {
|
|||||||
matrix->Row2.Z = 1.0f / (ORTHO_NEAR - ORTHO_FAR);
|
matrix->Row2.Z = 1.0f / (ORTHO_NEAR - ORTHO_FAR);
|
||||||
matrix->Row3.Z = ORTHO_NEAR / (ORTHO_NEAR - ORTHO_FAR);
|
matrix->Row3.Z = ORTHO_NEAR / (ORTHO_NEAR - ORTHO_FAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_CalcPerspectiveMatrix(float fov, float aspect, float zFar, struct Matrix* matrix) {
|
void Gfx_CalcPerspectiveMatrix(float fov, float aspect, float zFar, struct Matrix* matrix) {
|
||||||
/* With reversed z depth, near Z plane can be much closer (with sufficient depth buffer precision) */
|
/* With reversed z depth, near Z plane can be much closer (with sufficient depth buffer precision) */
|
||||||
/* This reduces clipping with high FOV without sacrificing depth precision for faraway objects */
|
/* This reduces clipping with high FOV without sacrificing depth precision for faraway objects */
|
||||||
/* However for low FOV, don't reduce near Z in order to gain a bit more depth precision */
|
/* However for low FOV, don't reduce near Z in order to gain a bit more depth precision */
|
||||||
float zNear = (depthBits < 24 || fov <= 70) ? 0.05f : 0.001953125f;
|
float zNear = (depthBits < 24 || fov <= 70 * MATH_DEG2RAD) ? 0.05f : 0.001953125f;
|
||||||
Matrix_PerspectiveFieldOfView(matrix, fov, aspect, zNear, zFar);
|
Matrix_PerspectiveFieldOfView(matrix, fov, aspect, zNear, zFar);
|
||||||
|
|
||||||
/* Adjust the projection matrix to produce reversed Z values */
|
/* Adjust the projection matrix to produce reversed Z values */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user