Fix mipmap sampling bug

This commit is contained in:
Magnus Norddahl 2016-11-03 12:51:07 +01:00
parent 356830a8c8
commit 90c8b3370a
2 changed files with 3 additions and 3 deletions

View File

@ -1073,7 +1073,7 @@ extern "C" BYTE *ds_curcolormap, *ds_cursource, *ds_curtiltedsource;
void R_SetSpanSource(FTexture *tex)
{
ds_source = r_swtruecolor ? (const BYTE*)tex->GetPixelsBgra() : tex->GetPixels();
ds_source_mipmapped = tex->Mipmapped();
ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1;
#ifdef X86_ASM
if (!r_swtruecolor && ds_cursource != ds_source)
{

View File

@ -1159,12 +1159,12 @@ WallscanSampler::WallscanSampler(int y1, float swal, double yrepeat, fixed_t xof
int mipmap_offset = 0;
int mip_width = texture->GetWidth();
int mip_height = texture->GetHeight();
if (r_mipmap && texture->Mipmapped())
if (r_mipmap && texture->Mipmapped() && mip_width > 1 && mip_height > 1)
{
uint32_t xpos = (uint32_t)((((uint64_t)xoffset) << FRACBITS) / mip_width);
double texture_bias = 1.7f;
double level = MAX(magnitude - 3.0, 0.0);
while (level > texture_bias)
while (level > texture_bias && mip_width > 1 && mip_height > 1)
{
mipmap_offset += mip_width * mip_height;
level *= 0.5f;