From 337e96d3b0a7f8fa2c293bbf872e1af34b86ad7d Mon Sep 17 00:00:00 2001 From: s2s <12202580+standard-two-simplex@users.noreply.github.com> Date: Tue, 31 Aug 2021 12:13:57 +0200 Subject: [PATCH] Use texture coordinate bounds for s2dex one-piece backgrounds --- ...l_CombinerProgramUniformFactoryAccurate.cpp | 3 ++- src/uCodes/S2DEX.cpp | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactoryAccurate.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactoryAccurate.cpp index ef65b9f1..15a9a47f 100644 --- a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactoryAccurate.cpp +++ b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactoryAccurate.cpp @@ -26,7 +26,8 @@ public: void update(bool _force) override { const bool isNativeRes = config.frameBufferEmulation.nativeResFactor == 1 && config.video.multisampling == 0; const bool isTexRect = dwnd().getDrawer().getDrawingState() == DrawingState::TexRect; - const bool useTexCoordBounds = isTexRect && !isNativeRes && config.graphics2D.enableTexCoordBounds; + const bool isBackground = gSP.textureTile[0] != nullptr && gSP.textureTile[0]->textureMode == TEXTUREMODE_BGIMAGE; + const bool useTexCoordBounds = (isTexRect || isBackground) && !isNativeRes && config.graphics2D.enableTexCoordBounds; /* At rasterization stage, the N64 places samples on the top left of the fragment while OpenGL */ /* places them in the fragment center. As a result, a normal approach results in shifted texture */ /* coordinates. In native resolution, this difference can be negated by shifting vertices by 0.5. */ diff --git a/src/uCodes/S2DEX.cpp b/src/uCodes/S2DEX.cpp index 37356c9f..7b1cc07c 100644 --- a/src/uCodes/S2DEX.cpp +++ b/src/uCodes/S2DEX.cpp @@ -481,7 +481,7 @@ struct ObjCoordinates f32 imageW = (f32)gSP.bgImage.width; f32 imageH = (f32)gSP.bgImage.height; - if (u32(imageW) == 512 && (config.generalEmulation.hacks & hack_RE2) != 0) { + if (u32(imageW) == 512 && (config.generalEmulation.hacks & hack_RE2) != 0u) { const f32 width = f32(*REG.VI_WIDTH); const f32 scale = imageW / width; imageW = width; @@ -502,7 +502,7 @@ struct ObjCoordinates lrs = uls + (lrx - ulx) * scaleW; lrt = ult + (lry - uly) * scaleH; - if (config.frameBufferEmulation.nativeResFactor != 1 || config.video.multisampling != 0) { + if (config.frameBufferEmulation.nativeResFactor != 1u || config.video.multisampling != 0u) { uls -= 0.5f * scaleW; ult -= 0.5f * scaleH; lrs -= 0.5f * scaleW; @@ -513,7 +513,7 @@ struct ObjCoordinates if (gDP.otherMode.cycleType != G_CYC_COPY) { // Correct texture coordinates if G_OBJRM_BILERP // bilinear interpolation is set - if ((gSP.objRendermode & G_OBJRM_BILERP) != 0) { + if ((gSP.objRendermode & G_OBJRM_BILERP) != 0u) { // No correction gives the best picture, but is this correct? //uls -= 0.5f; //ult -= 0.5f; @@ -522,7 +522,7 @@ struct ObjCoordinates } // SHRINKSIZE_1 adds a 0.5f perimeter around the image // upper left texture coords += 0.5f; lower left texture coords -= 0.5f - if ((gSP.objRendermode&G_OBJRM_SHRINKSIZE_1) != 0) { + if ((gSP.objRendermode&G_OBJRM_SHRINKSIZE_1) != 0u) { uls += 0.5f; ult += 0.5f; lrs -= 0.5f; @@ -530,7 +530,7 @@ struct ObjCoordinates } // SHRINKSIZE_2 adds a 1.0f perimeter // upper left texture coords += 1.0f; lower left texture coords -= 1.0f - else if ((gSP.objRendermode&G_OBJRM_SHRINKSIZE_2) != 0) { + else if ((gSP.objRendermode&G_OBJRM_SHRINKSIZE_2) != 0u) { uls += 1.0f; ult += 1.0f; lrs -= 1.0f; @@ -538,9 +538,15 @@ struct ObjCoordinates } } + gDP.m_texCoordBounds.valid = true; + gDP.m_texCoordBounds.uls = uls; + gDP.m_texCoordBounds.lrs = lrs - 1.0f; + gDP.m_texCoordBounds.ult = ult; + gDP.m_texCoordBounds.lrt = lrt - 1.0f; + // BgRect1CycOnePiece() and BgRectCopyOnePiece() do only support // imageFlip in horizontal direction - if ((_pObjScaleBg->imageFlip & G_BG_FLAG_FLIPS) != 0) { + if ((_pObjScaleBg->imageFlip & G_BG_FLAG_FLIPS) != 0u) { std::swap(ulx, lrx); }