From d07f5320bd2c8c209d022bbcf12786e236bd5b35 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 21 Oct 2020 01:43:28 -0400 Subject: [PATCH] CGraphics: Fix depth in perspective matrices (part 2) --- Runtime/Graphics/CGraphics.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Runtime/Graphics/CGraphics.cpp b/Runtime/Graphics/CGraphics.cpp index 8da4fb5b0..452b2d511 100644 --- a/Runtime/Graphics/CGraphics.cpp +++ b/Runtime/Graphics/CGraphics.cpp @@ -215,8 +215,9 @@ zeus::CMatrix4f CGraphics::CalculatePerspectiveMatrix(float fovy, float aspect, float fpn = st.x18_far + st.x14_near; float fmn = st.x18_far - st.x14_near; - return zeus::CMatrix4f{2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f, - 0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f}; + zeus::CMatrix4f mat2{2.f * st.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * st.x14_near / tmb, tpb / tmb, 0.f, + 0.f, 0.f, -fpn / fmn, -2.f * st.x18_far * st.x14_near / fmn, 0.f, 0.f, -1.f, 0.f}; + return forRenderer ? DepthCorrect * mat2 : mat2; } zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) {