- Emulate the size limit of Doom's lightscale table by capping the value of vis passed to

GETPALOOKUP. The end result is that there is a minimum distance around you where light
  amplification stops and it gets no brighter. Should this scale with visibility? I can't say.

  So, yeah, it turns out all these years ago, I made this out to be harder than it really is.

SVN r3224 (trunk)
This commit is contained in:
Randy Heit 2011-06-12 03:15:15 +00:00
parent ee8ca0de87
commit 3401e92834
2 changed files with 77 additions and 49 deletions

View file

@ -98,9 +98,13 @@ extern bool r_dontmaplines;
// is necessary in order to best reproduce Doom's original lighting. // is necessary in order to best reproduce Doom's original lighting.
#define LIGHT2SHADE(l) ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*FRACUNIT*NUMCOLORMAPS/128)) #define LIGHT2SHADE(l) ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*FRACUNIT*NUMCOLORMAPS/128))
// MAXLIGHTSCALE from original DOOM, divided by 2.
#define MAXLIGHTVIS (24*FRACUNIT)
// Convert a shade and visibility to a clamped colormap index. // Convert a shade and visibility to a clamped colormap index.
// Result is not fixed point. // Result is not fixed point.
#define GETPALOOKUP(vis,shade) (clamp<int> (((shade)-(vis))>>FRACBITS, 0, NUMCOLORMAPS-1)) // Change R_CalcTiltedLighting() when this changes.
#define GETPALOOKUP(vis,shade) (clamp<int> (((shade)-MIN(MAXLIGHTVIS,(vis)))>>FRACBITS, 0, NUMCOLORMAPS-1))
extern fixed_t GlobVis; extern fixed_t GlobVis;

View file

@ -251,14 +251,37 @@ void STACK_ARGS R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
BYTE *basecolormapdata = basecolormap->Maps; BYTE *basecolormapdata = basecolormap->Maps;
int i = 0; int i = 0;
lval = planeshade - lval;
lend = planeshade - lend;
if (width == 0 || lval == lend) if (width == 0 || lval == lend)
{ // Constant lighting { // Constant lighting
lightfiller = basecolormapdata + (GETPALOOKUP (-lval, 0) << COLORMAPSHIFT); lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT);
} }
else if ((lstep = (lend - lval) / width) < 0) else
{
lstep = (lend - lval) / width;
if (lval >= MAXLIGHTVIS)
{ // lval starts "too bright".
lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT);
for (; i <= width && lval >= MAXLIGHTVIS; ++i)
{
tiltlighting[i] = lightfiller;
lval += lstep;
}
}
if (lend >= MAXLIGHTVIS)
{ // lend ends "too bright".
lightfiller = basecolormapdata + (GETPALOOKUP(lend, planeshade) << COLORMAPSHIFT);
for (; width > i && lend >= MAXLIGHTVIS; --width)
{
tiltlighting[width] = lightfiller;
lend -= lstep;
}
}
if (width > 0)
{
lval = planeshade - lval;
lend = planeshade - lend;
lstep = (lend - lval) / width;
if (lstep < 0)
{ // Going from dark to light { // Going from dark to light
if (lval < FRACUNIT) if (lval < FRACUNIT)
{ // All bright { // All bright
@ -308,7 +331,8 @@ void STACK_ARGS R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT); lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT);
} }
} }
}
}
for (; i <= width; i++) for (; i <= width; i++)
{ {
tiltlighting[i] = lightfiller; tiltlighting[i] = lightfiller;