2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-12-02 23:20:15 +01:00

ref_soft: Merge kernel texture filter

This commit is contained in:
mittorn 2019-03-22 23:58:43 +07:00
parent e7785c9ccb
commit 842a15ee45
3 changed files with 60 additions and 14 deletions

View File

@ -1195,6 +1195,7 @@ extern cvar_t *sw_reportedgeout;
extern cvar_t *sw_stipplealpha;
extern cvar_t *sw_surfcacheoverride;
extern cvar_t *sw_waterwarp;
extern cvar_t *sw_texfilt;
extern vec3_t modelorg;
extern vec3_t r_origin;

View File

@ -83,6 +83,7 @@ cvar_t *sw_reportsurfout;
cvar_t *sw_stipplealpha;
cvar_t *sw_surfcacheoverride;
cvar_t *sw_waterwarp;
cvar_t *sw_texfilt;
cvar_t *r_drawworld;
cvar_t *r_drawentities;
@ -1654,7 +1655,7 @@ qboolean R_Init()
sw_surfcacheoverride = gEngfuncs.Cvar_Get ("sw_surfcacheoverride", "0", 0, "");
sw_waterwarp = gEngfuncs.Cvar_Get ("sw_waterwarp", "1", 0, "");
sw_mode = gEngfuncs.Cvar_Get( "sw_mode", "0", FCVAR_ARCHIVE, "");
sw_texfilt = gEngfuncs.Cvar_Get ("sw_texfilt", "0", 0, "texture dither");
//r_lefthand = ri.Cvar_Get( "hand", "0", FCVAR_USERINFO | FCVAR_ARCHIVE );
// r_speeds = ri.Cvar_Get ("r_speeds", "0", 0);

View File

@ -391,6 +391,20 @@ void NonTurbulent8 (espan_t *pspan)
#if !id386
int kernel[2][2][2] =
{
{
{16384,0},
{49152,32768}
}
,
{
{32768,49152},
{0,16384}
}
};
/*
=============
D_DrawSpans16
@ -481,10 +495,10 @@ void D_DrawSpans16 (espan_t *pspan)
}
else
{
// calculate s/z, t/z, zi->fixed s and t at last pixel in span (so
// can't step off polygon), clamp, calculate s and t steps across
// span by division, biasing steps low so we don't run off the
// texture
// calculate s/z, t/z, zi->fixed s and t at last pixel in span (so
// can't step off polygon), clamp, calculate s and t steps across
// span by division, biasing steps low so we don't run off the
// texture
spancountminus1 = (float)(spancount - 1);
sdivz += d_sdivzstepu * spancountminus1;
tdivz += d_tdivzstepu * spancountminus1;
@ -509,17 +523,47 @@ void D_DrawSpans16 (espan_t *pspan)
sstep = (snext - s) / (spancount - 1);
tstep = (tnext - t) / (spancount - 1);
}
}
}
do
{
*pdest++ = *(pbase + (s >> 16) + (t >> 16) * cachewidth);
s += sstep;
t += tstep;
} while (--spancount > 0);
// Drawing phrase
if (sw_texfilt->value == 0.0f)
{
do
{
*pdest++ = *(pbase + (s >> 16) + (t >> 16) * cachewidth);
s += sstep;
t += tstep;
} while (--spancount > 0);
}
else if (sw_texfilt->value == 1.0f)
{
do
{
int idiths = s;
int iditht = t;
s = snext;
t = tnext;
int X = (pspan->u + spancount) & 1;
int Y = (pspan->v)&1;
//Using the kernel
idiths += kernel[X][Y][0];
iditht += kernel[X][Y][1];
idiths = idiths >> 16;
idiths = idiths ? idiths -1 : idiths;
iditht = iditht >> 16;
iditht = iditht ? iditht -1 : iditht;
*pdest++ = *(pbase + idiths + iditht * cachewidth);
s += sstep;
t += tstep;
} while (--spancount > 0);
}
} while (count > 0);