From d1e3510b8c507c3d27ba2021b64c2cdc3854c119 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Tue, 30 Jan 2024 18:11:34 +0300 Subject: [PATCH] ogc: avoid rounding issues with texture drawing --- src/video/ogc/SDL_ogcgxcommon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/video/ogc/SDL_ogcgxcommon.c b/src/video/ogc/SDL_ogcgxcommon.c index 40735b05e3586..56c017f271763 100644 --- a/src/video/ogc/SDL_ogcgxcommon.c +++ b/src/video/ogc/SDL_ogcgxcommon.c @@ -59,7 +59,13 @@ void OGC_draw_init(int w, int h) SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "OGC_draw_init called with %d, %d", w, h); guMtxIdentity(mv); - guMtxTransApply(mv, mv, 0.5, 0.5, 0); + /* Ideally we would use 0.5 to center the coordinates on the pixels, but + * this causes some visual artifacts due to rounding: in the VVVVVV game, + * all 8x8 pixel textures lose their rightmost column and bottom row, + * except when they are drawn on the bottom-right quadrant of the screen. + * Values from 0.1 to 0.4 fix this issue, while preserving pixel accuracy + * on drawing operations. */ + guMtxTransApply(mv, mv, 0.4, 0.4, 0); GX_LoadPosMtxImm(mv, GX_PNMTX0); GX_ClearVtxDesc();