From db497cc55f0420f1888bd072ee3afcbf34700848 Mon Sep 17 00:00:00 2001 From: Yuriy O'Donnell Date: Thu, 23 Oct 2014 00:20:47 +0200 Subject: [PATCH 1/2] Added projection matrix epsilon that fixes depth clipping issues in some games --- Source/Core/VideoCommon/VertexShaderManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 022bf7683d..c87c9297ba 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -475,7 +475,7 @@ void VertexShaderManager::SetConstants() g_fProjectionMatrix[13] = 0.0f; g_fProjectionMatrix[14] = 0.0f; - g_fProjectionMatrix[15] = 1.0f; + g_fProjectionMatrix[15] = 1.0f + FLT_EPSILON; // hack to fix depth clipping precision issues (such as Sonic Unleashed UI) SETSTAT_FT(stats.g2proj_0, g_fProjectionMatrix[0]); SETSTAT_FT(stats.g2proj_1, g_fProjectionMatrix[1]); From dc08de028cb51256fcfe277feab27da9e0826445 Mon Sep 17 00:00:00 2001 From: Yuriy O'Donnell Date: Sun, 9 Nov 2014 15:25:49 +0100 Subject: [PATCH 2/2] Moved projection epsilon to a more reasonable place --- Source/Core/VideoCommon/VertexShaderManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index c87c9297ba..b0e3afdaaa 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -87,7 +87,7 @@ static float PHackValue(std::string sValue) void UpdateProjectionHack(int iPhackvalue[], std::string sPhackvalue[]) { - float fhackvalue1 = 0, fhackvalue2 = 0; + float fhackvalue1 = 0, fhackvalue2 = FLT_EPSILON; // hack to fix depth clipping precision issues (such as Sonic Unleashed UI) float fhacksign1 = 1.0, fhacksign2 = 1.0; const char *sTemp[2]; @@ -475,7 +475,7 @@ void VertexShaderManager::SetConstants() g_fProjectionMatrix[13] = 0.0f; g_fProjectionMatrix[14] = 0.0f; - g_fProjectionMatrix[15] = 1.0f + FLT_EPSILON; // hack to fix depth clipping precision issues (such as Sonic Unleashed UI) + g_fProjectionMatrix[15] = 1.0f; SETSTAT_FT(stats.g2proj_0, g_fProjectionMatrix[0]); SETSTAT_FT(stats.g2proj_1, g_fProjectionMatrix[1]);