mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
Improve flat mipmap selection
This commit is contained in:
parent
aad2cde332
commit
3a7532fd9b
4 changed files with 18 additions and 11 deletions
|
@ -1046,6 +1046,7 @@ dsfixed_t ds_xstep;
|
|||
dsfixed_t ds_ystep;
|
||||
int ds_xbits;
|
||||
int ds_ybits;
|
||||
double ds_lod;
|
||||
|
||||
// start of a floor/ceiling tile image
|
||||
const BYTE* ds_source;
|
||||
|
|
|
@ -316,6 +316,7 @@ extern "C" dsfixed_t ds_ystep;
|
|||
extern "C" int ds_xbits;
|
||||
extern "C" int ds_ybits;
|
||||
extern "C" fixed_t ds_alpha;
|
||||
extern "C" double ds_lod;
|
||||
|
||||
// start of a 64*64 tile image
|
||||
extern "C" const BYTE* ds_source;
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
args.flags = 0;
|
||||
if (ds_shade_constants.simple_shade)
|
||||
args.flags |= DrawSpanArgs::simple_shade;
|
||||
if (!sampler_setup(args.source, args.xbits, args.ybits, args.xstep, args.ystep, ds_source_mipmapped))
|
||||
if (!sampler_setup(args.source, args.xbits, args.ybits, ds_source_mipmapped))
|
||||
args.flags |= DrawSpanArgs::nearest_filter;
|
||||
}
|
||||
|
||||
|
@ -117,18 +117,13 @@ protected:
|
|||
DrawSpanArgs args;
|
||||
|
||||
private:
|
||||
inline static bool sampler_setup(const uint32_t * &source, int &xbits, int &ybits, fixed_t xstep, fixed_t ystep, bool mipmapped)
|
||||
inline static bool sampler_setup(const uint32_t * &source, int &xbits, int &ybits, bool mipmapped)
|
||||
{
|
||||
// Is this a magfilter or minfilter?
|
||||
fixed_t xmagnitude = abs(xstep) >> (32 - xbits - FRACBITS);
|
||||
fixed_t ymagnitude = abs(ystep) >> (32 - ybits - FRACBITS);
|
||||
fixed_t magnitude = (xmagnitude + ymagnitude) * 2 + (1 << (FRACBITS - 1));
|
||||
bool magnifying = (magnitude >> FRACBITS == 0);
|
||||
|
||||
bool magnifying = ds_lod < 0.0f;
|
||||
if (r_mipmap && mipmapped)
|
||||
{
|
||||
int level = magnitude >> (FRACBITS + 1);
|
||||
while (level != 0)
|
||||
int level = (int)ds_lod;
|
||||
while (level > 0)
|
||||
{
|
||||
if (xbits <= 2 || ybits <= 2)
|
||||
break;
|
||||
|
@ -136,7 +131,7 @@ private:
|
|||
source += (1 << (xbits)) * (1 << (ybits));
|
||||
xbits -= 1;
|
||||
ybits -= 1;
|
||||
level >>= 1;
|
||||
level--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -245,6 +245,16 @@ void R_MapPlane (int y, int x1)
|
|||
ds_yfrac = 0;
|
||||
}
|
||||
|
||||
if (r_swtruecolor)
|
||||
{
|
||||
double distance2 = planeheight * yslope[(y + 1 < viewheight) ? y + 1 : y - 1];
|
||||
double xmagnitude = fabs(ystepscale * (distance2 - distance) * FocalLengthX);
|
||||
double ymagnitude = fabs(xstepscale * (distance2 - distance) * FocalLengthX);
|
||||
double magnitude = MAX(ymagnitude, xmagnitude);
|
||||
double min_lod = -1000.0;
|
||||
ds_lod = MAX(log2(magnitude) + r_lod_bias, min_lod);
|
||||
}
|
||||
|
||||
if (plane_shade)
|
||||
{
|
||||
// Determine lighting based on the span's distance from the viewer.
|
||||
|
|
Loading…
Reference in a new issue