From 5e524bca6025d7f7e8b99df8e781fb3d097d9cf4 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 5 Feb 2025 20:16:16 +0300 Subject: [PATCH] engine: client: enable half-texel hack for nearest filtering too, if the scaling factor isn't an integer --- engine/client/cl_game.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 75e7d4dc..0def0520 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -306,21 +306,22 @@ void SPR_AdjustSize( float *x, float *y, float *w, float *h ) static void SPR_AdjustTexCoords( int texnum, float width, float height, float *s1, float *t1, float *s2, float *t2 ) { - if( REF_GET_PARM( PARM_TEX_FILTERING, texnum )) - { - if( refState.width != clgame.scrInfo.iWidth ) - { - // align to texel if scaling - *s1 += 0.5f; - *s2 -= 0.5f; - } + const qboolean filtering = REF_GET_PARM( PARM_TEX_FILTERING, texnum ); + const int xremainder = refState.width % clgame.scrInfo.iWidth; + const int yremainder = refState.height % clgame.scrInfo.iHeight; - if( refState.height != clgame.scrInfo.iHeight ) - { - // align to texel if scaling - *t1 += 0.5f; - *t2 -= 0.5f; - } + if(( filtering || xremainder ) && refState.width != clgame.scrInfo.iWidth ) + { + // align to texel if scaling + *s1 += 0.5f; + *s2 -= 0.5f; + } + + if(( filtering || yremainder ) && refState.height != clgame.scrInfo.iHeight ) + { + // align to texel if scaling + *t1 += 0.5f; + *t2 -= 0.5f; } *s1 /= width;