Fix mipmap filtering issues in tinydisplay renderer

This commit is contained in:
rdb 2016-09-28 00:00:22 +02:00
parent 2e9394eba7
commit 3f53994372
2 changed files with 11 additions and 10 deletions

View File

@ -39,6 +39,7 @@ This issue fixes several bugs that were still found in 1.9.2.
* Windows installer no longer clears %PATH% if longer than 1024 chars * Windows installer no longer clears %PATH% if longer than 1024 chars
* Fix inoperative -tbn/-tbnall/-tbnauto options in egg-optchar * Fix inoperative -tbn/-tbnall/-tbnauto options in egg-optchar
* Fix tinydisplay texture errors on shutdown * Fix tinydisplay texture errors on shutdown
* Fix mipmap filtering issues in tinydisplay renderer
------------------------ RELEASE 1.9.2 ------------------------ ------------------------ RELEASE 1.9.2 ------------------------

View File

@ -489,11 +489,11 @@ lookup_texture_mipmap_linear(ZTextureDef *texture_def, int s, int t, unsigned in
level = max((int)level - 1, 0); level = max((int)level - 1, 0);
p2 = ZB_LOOKUP_TEXTURE_MIPMAP_NEAREST(texture_def, s, t, level); p2 = ZB_LOOKUP_TEXTURE_MIPMAP_NEAREST(texture_def, s, t, level);
unsigned int bitsize = level + ZB_POINT_ST_FRAC_BITS; unsigned int f = level_dx >> (level - 1);
r = LINEAR_FILTER_BITSIZE(PIXEL_R(p2), PIXEL_R(p1), level_dx, bitsize); r = LINEAR_FILTER(PIXEL_R(p1), PIXEL_R(p2), f);
g = LINEAR_FILTER_BITSIZE(PIXEL_G(p2), PIXEL_G(p1), level_dx, bitsize); g = LINEAR_FILTER(PIXEL_G(p1), PIXEL_G(p2), f);
b = LINEAR_FILTER_BITSIZE(PIXEL_B(p2), PIXEL_B(p1), level_dx, bitsize); b = LINEAR_FILTER(PIXEL_B(p1), PIXEL_B(p2), f);
a = LINEAR_FILTER_BITSIZE(PIXEL_A(p2), PIXEL_A(p1), level_dx, bitsize); a = LINEAR_FILTER(PIXEL_A(p1), PIXEL_A(p2), f);
return RGBA_TO_PIXEL(r, g, b, a); return RGBA_TO_PIXEL(r, g, b, a);
} }
@ -570,11 +570,11 @@ lookup_texture_mipmap_trilinear(ZTextureDef *texture_def, int s, int t, unsigned
} }
int r, g, b, a; int r, g, b, a;
unsigned int bitsize = level + ZB_POINT_ST_FRAC_BITS; unsigned int f = level_dx >> (level - 1);
r = LINEAR_FILTER_BITSIZE(PIXEL_R(p2a), PIXEL_R(p1a), level_dx, bitsize); r = LINEAR_FILTER(PIXEL_R(p1a), PIXEL_R(p2a), f);
g = LINEAR_FILTER_BITSIZE(PIXEL_G(p2a), PIXEL_G(p1a), level_dx, bitsize); g = LINEAR_FILTER(PIXEL_G(p1a), PIXEL_G(p2a), f);
b = LINEAR_FILTER_BITSIZE(PIXEL_B(p2a), PIXEL_B(p1a), level_dx, bitsize); b = LINEAR_FILTER(PIXEL_B(p1a), PIXEL_B(p2a), f);
a = LINEAR_FILTER_BITSIZE(PIXEL_A(p2a), PIXEL_A(p1a), level_dx, bitsize); a = LINEAR_FILTER(PIXEL_A(p1a), PIXEL_A(p2a), f);
return RGBA_TO_PIXEL(r, g, b, a); return RGBA_TO_PIXEL(r, g, b, a);
} }