Skip to content

Commit

Permalink
Added Unreal kernel filtering.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiensanglard authored and 0lvin committed May 20, 2018
1 parent 96a81f6 commit 184ff91
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/client/refresh/soft/sw_main.c
Expand Up @@ -124,6 +124,7 @@ cvar_t *sw_surfcacheoverride;
cvar_t *sw_waterwarp;
static cvar_t *sw_overbrightbits;
cvar_t *sw_custom_particles;
cvar_t *sw_texture_filtering;

cvar_t *r_drawworld;
static cvar_t *r_drawentities;
Expand Down Expand Up @@ -272,6 +273,7 @@ R_Register (void)
sw_waterwarp = ri.Cvar_Get ("sw_waterwarp", "1", 0);
sw_overbrightbits = ri.Cvar_Get("sw_overbrightbits", "1.0", CVAR_ARCHIVE);
sw_custom_particles = ri.Cvar_Get("sw_custom_particles", "0", CVAR_ARCHIVE);
sw_texture_filtering = ri.Cvar_Get("sw_texture_filtering", "0", CVAR_ARCHIVE);
r_mode = ri.Cvar_Get( "r_mode", "0", CVAR_ARCHIVE );

r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
Expand Down
58 changes: 51 additions & 7 deletions src/client/refresh/soft/sw_scan.c
Expand Up @@ -382,6 +382,19 @@ void NonTurbulent8 (espan_t *pspan)
//PGM
//====================

// Enable custom filtering
extern cvar_t *sw_texture_filtering;
static int filtering_kernel[2][2][2] = {
{
{16384, 0},
{49152, 32768}
},
{
{32768, 49152},
{0, 16384}
}
};

/*
=============
D_DrawSpans16
Expand Down Expand Up @@ -505,15 +518,46 @@ void D_DrawSpans16 (espan_t *pspan)
}
}

do
// Drawing phrase
if (sw_texture_filtering->value == 0.0f)
{
do
{
*pdest++ = *(pbase + (s >> 16) + (t >> 16) * cachewidth);
s += sstep;
t += tstep;
} while (--spancount > 0);

s = snext;
t = tnext;
}
else if (sw_texture_filtering->value == 1.0f)
{
*pdest++ = *(pbase + (s >> 16) + (t >> 16) * cachewidth);
s += sstep;
t += tstep;
} while (--spancount > 0);
do
{
int idiths = s;
int iditht = t;

int X = (pspan->u + spancount) & 1;
int Y = (pspan->v)&1;

//Using the kernel
idiths += filtering_kernel[X][Y][0];
iditht += filtering_kernel[X][Y][1];

idiths = idiths >> 16;
idiths = idiths ? idiths -1 : idiths;

s = snext;
t = tnext;

iditht = iditht >> 16;
iditht = iditht ? iditht -1 : iditht;


*pdest++ = *(pbase + idiths + iditht * cachewidth);
s += sstep;
t += tstep;
} while (--spancount > 0);
}

} while (count > 0);

Expand Down

0 comments on commit 184ff91

Please sign in to comment.