1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Backgrounds: Fix cut off textures and texture fragments and seams

-Fix cut off textures in hamster64. Enable coord correction if
gDP.otherMode.textureFilter == G_TF_BILERP.
-Fix seams in hamster64 and texture fragments in starcraft64. Enable
texture clamp if lrs/lrt <= (imageW/imageH - 1).
This commit is contained in:
gizmo98 2018-10-10 19:58:54 +02:00 committed by Sergey Lipskiy
parent 1df96cebeb
commit 35099ec8cb
3 changed files with 11 additions and 7 deletions

View File

@ -1394,6 +1394,8 @@ void TextureCache::_updateBackground()
assert(currentTex.height == gSP.bgImage.height);
assert(currentTex.format == gSP.bgImage.format);
assert(currentTex.size == gSP.bgImage.size);
currentTex.clampS = gSP.bgImage.clampS;
currentTex.clampT = gSP.bgImage.clampT;
activateTexture(0, &currentTex);
m_hits++;
@ -1419,8 +1421,8 @@ void TextureCache::_updateBackground()
pCurrent->maskT = 0;
pCurrent->mirrorS = 0;
pCurrent->mirrorT = 0;
pCurrent->clampS = 0;
pCurrent->clampT = 0;
pCurrent->clampS = gSP.bgImage.clampS;
pCurrent->clampT = gSP.bgImage.clampT;
pCurrent->line = 0;
pCurrent->tMem = 0;
pCurrent->frameBufferTexture = CachedTexture::fbNone;

View File

@ -110,6 +110,7 @@ struct gSPInfo
{
u32 address, width, height, format, size, palette;
f32 imageX, imageY, scaleW, scaleH;
u8 clampS, clampT;
} bgImage;
u32 geometryMode;

View File

@ -407,14 +407,14 @@ struct ObjCoordinates
lrs = uls + std::min(imageW, frameW * scaleW) - 1;
lrt = ult + std::min(imageH, frameH * scaleH) - 1;
gSP.bgImage.clampS = lrs <= (imageW - 1) ? 1 : 0 ;
gSP.bgImage.clampT = lrt <= (imageH - 1) ? 1 : 0 ;
// G_CYC_COPY (gSPBgRectCopy()) does not allow texture filtering
if (gDP.otherMode.cycleType != G_CYC_COPY) {
// Correct texture coordinates -0.5f and +0.5 if G_OBJRM_BILERP
// bilinear interpolation is set
if ((gSP.objRendermode&G_OBJRM_BILERP) != 0 &&
((gDP.otherMode.textureFilter == G_TF_BILERP) || // Kirby Crystal Shards
(gDP.otherMode.textureFilter == G_TF_POINT && (gSP.objRendermode&G_OBJRM_NOTXCLAMP) != 0)) // Worms Armageddon
) {
if (gDP.otherMode.textureFilter == G_TF_BILERP) {
uls -= 0.5f;
ult -= 0.5f;
lrs += 0.5f;
@ -443,7 +443,8 @@ struct ObjCoordinates
uly = frameY;
lrx = ulx + (lrs - uls) / scaleW;
lry = uly + (lrt - ult) / scaleH;
if ((gSP.objRendermode&G_OBJRM_BILERP) == 0) {
if (((gSP.objRendermode&G_OBJRM_BILERP) == 0 && gDP.otherMode.textureFilter != G_TF_BILERP) ||
((gSP.objRendermode&G_OBJRM_BILERP) != 0 && gDP.otherMode.textureFilter == G_TF_POINT && (gSP.objRendermode&G_OBJRM_NOTXCLAMP) != 0)) {
lrx += 1.0f / scaleW;
lry += 1.0f / scaleH;
}