From 40481305c49dce633b6100dfc38e1f4d7e8f7a5d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 24 Mar 2020 00:20:12 +1000 Subject: [PATCH] GPU/HW: Fudge texture coordinates by half a screen-space pixel Fixes holes in triangles in some games, e.g. Disney's The Emperor's New Groove. --- src/core/gpu_hw_shadergen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index cee3ed58b..55e70ee2e 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -376,7 +376,10 @@ std::string GPU_HW_ShaderGen::GenerateBatchVertexShader(bool textured) v_col0 = a_col0; #if TEXTURED - v_tex0 = float2(float(a_texcoord & 0xFFFF), float(a_texcoord >> 16)); + // Fudge the texture coordinates by half a pixel in screen-space. + // This fixes the rounding/interpolation error on NVIDIA GPUs with shared edges between triangles. + v_tex0 = float2(float(a_texcoord & 0xFFFF) + (RCP_VRAM_SIZE.x * 0.5), + float(a_texcoord >> 16) + (RCP_VRAM_SIZE.y * 0.5)); // base_x,base_y,palette_x,palette_y v_texpage.x = (a_texpage & 15) * 64 * RESOLUTION_SCALE;