Fix lighting discrepancies between different FOVs
This commit is contained in:
parent
1d221a453a
commit
8868fc4d8a
|
@ -644,6 +644,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan))
|
||||||
|
|
||||||
/** \brief The R_DrawTiltedSpan_8 function
|
/** \brief The R_DrawTiltedSpan_8 function
|
||||||
Draw slopes! Holy sheit!
|
Draw slopes! Holy sheit!
|
||||||
|
@ -669,7 +670,7 @@ void R_DrawTiltedSpan_8(void)
|
||||||
|
|
||||||
// Lighting is simple. It's just linear interpolation from start to end
|
// Lighting is simple. It's just linear interpolation from start to end
|
||||||
{
|
{
|
||||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
float planelightfloat = PLANELIGHTFLOAT;
|
||||||
float lightstart, lightend;
|
float lightstart, lightend;
|
||||||
|
|
||||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||||
|
@ -805,7 +806,7 @@ void R_DrawTiltedTranslucentSpan_8(void)
|
||||||
|
|
||||||
// Lighting is simple. It's just linear interpolation from start to end
|
// Lighting is simple. It's just linear interpolation from start to end
|
||||||
{
|
{
|
||||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
float planelightfloat = PLANELIGHTFLOAT;
|
||||||
float lightstart, lightend;
|
float lightstart, lightend;
|
||||||
|
|
||||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||||
|
@ -942,7 +943,7 @@ void R_DrawTiltedTranslucentWaterSpan_8(void)
|
||||||
|
|
||||||
// Lighting is simple. It's just linear interpolation from start to end
|
// Lighting is simple. It's just linear interpolation from start to end
|
||||||
{
|
{
|
||||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
float planelightfloat = PLANELIGHTFLOAT;
|
||||||
float lightstart, lightend;
|
float lightstart, lightend;
|
||||||
|
|
||||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||||
|
@ -1078,7 +1079,7 @@ void R_DrawTiltedSplat_8(void)
|
||||||
|
|
||||||
// Lighting is simple. It's just linear interpolation from start to end
|
// Lighting is simple. It's just linear interpolation from start to end
|
||||||
{
|
{
|
||||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
float planelightfloat = PLANELIGHTFLOAT;
|
||||||
float lightstart, lightend;
|
float lightstart, lightend;
|
||||||
|
|
||||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||||
|
|
|
@ -62,6 +62,9 @@ void R_DrawSpan_NPO2_8 (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
|
|
||||||
|
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan))
|
||||||
|
|
||||||
/** \brief The R_DrawTiltedSpan_NPO2_8 function
|
/** \brief The R_DrawTiltedSpan_NPO2_8 function
|
||||||
Draw slopes! Holy sheit!
|
Draw slopes! Holy sheit!
|
||||||
*/
|
*/
|
||||||
|
@ -86,7 +89,7 @@ void R_DrawTiltedSpan_NPO2_8(void)
|
||||||
|
|
||||||
// Lighting is simple. It's just linear interpolation from start to end
|
// Lighting is simple. It's just linear interpolation from start to end
|
||||||
{
|
{
|
||||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
float planelightfloat = PLANELIGHTFLOAT;
|
||||||
float lightstart, lightend;
|
float lightstart, lightend;
|
||||||
|
|
||||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||||
|
@ -282,7 +285,7 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void)
|
||||||
|
|
||||||
// Lighting is simple. It's just linear interpolation from start to end
|
// Lighting is simple. It's just linear interpolation from start to end
|
||||||
{
|
{
|
||||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
float planelightfloat = PLANELIGHTFLOAT;
|
||||||
float lightstart, lightend;
|
float lightstart, lightend;
|
||||||
|
|
||||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||||
|
@ -476,7 +479,7 @@ void R_DrawTiltedSplat_NPO2_8(void)
|
||||||
|
|
||||||
// Lighting is simple. It's just linear interpolation from start to end
|
// Lighting is simple. It's just linear interpolation from start to end
|
||||||
{
|
{
|
||||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
float planelightfloat = PLANELIGHTFLOAT;
|
||||||
float lightstart, lightend;
|
float lightstart, lightend;
|
||||||
|
|
||||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||||
|
@ -869,7 +872,7 @@ void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void)
|
||||||
|
|
||||||
// Lighting is simple. It's just linear interpolation from start to end
|
// Lighting is simple. It's just linear interpolation from start to end
|
||||||
{
|
{
|
||||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
float planelightfloat = PLANELIGHTFLOAT;
|
||||||
float lightstart, lightend;
|
float lightstart, lightend;
|
||||||
|
|
||||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||||
|
|
|
@ -46,6 +46,8 @@ extern size_t validcount, linecount, loopcount, framecount;
|
||||||
#define MAXLIGHTZ 128
|
#define MAXLIGHTZ 128
|
||||||
#define LIGHTZSHIFT 20
|
#define LIGHTZSHIFT 20
|
||||||
|
|
||||||
|
#define LIGHTRESOLUTIONFIX (640*fovtan/vid.width)
|
||||||
|
|
||||||
extern lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
|
extern lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
|
||||||
extern lighttable_t *scalelightfixed[MAXLIGHTSCALE];
|
extern lighttable_t *scalelightfixed[MAXLIGHTSCALE];
|
||||||
extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
|
extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
|
||||||
|
|
14
src/r_segs.c
14
src/r_segs.c
|
@ -199,7 +199,7 @@ static void R_DrawWallSplats(void)
|
||||||
// draw the columns
|
// draw the columns
|
||||||
for (dc_x = x1; dc_x <= x2; dc_x++, spryscale += rw_scalestep)
|
for (dc_x = x1; dc_x <= x2; dc_x++, spryscale += rw_scalestep)
|
||||||
{
|
{
|
||||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||||
if (pindex >= MAXLIGHTSCALE)
|
if (pindex >= MAXLIGHTSCALE)
|
||||||
pindex = MAXLIGHTSCALE - 1;
|
pindex = MAXLIGHTSCALE - 1;
|
||||||
dc_colormap = walllights[pindex];
|
dc_colormap = walllights[pindex];
|
||||||
|
@ -599,7 +599,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||||
else
|
else
|
||||||
xwalllights = scalelight[rlight->lightnum];
|
xwalllights = scalelight[rlight->lightnum];
|
||||||
|
|
||||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||||
|
|
||||||
if (pindex >= MAXLIGHTSCALE)
|
if (pindex >= MAXLIGHTSCALE)
|
||||||
pindex = MAXLIGHTSCALE - 1;
|
pindex = MAXLIGHTSCALE - 1;
|
||||||
|
@ -644,7 +644,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate lighting
|
// calculate lighting
|
||||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||||
|
|
||||||
if (pindex >= MAXLIGHTSCALE)
|
if (pindex >= MAXLIGHTSCALE)
|
||||||
pindex = MAXLIGHTSCALE - 1;
|
pindex = MAXLIGHTSCALE - 1;
|
||||||
|
@ -1188,7 +1188,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||||
else
|
else
|
||||||
xwalllights = scalelight[lightnum];
|
xwalllights = scalelight[lightnum];
|
||||||
|
|
||||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||||
|
|
||||||
if (pindex >= MAXLIGHTSCALE)
|
if (pindex >= MAXLIGHTSCALE)
|
||||||
pindex = MAXLIGHTSCALE-1;
|
pindex = MAXLIGHTSCALE-1;
|
||||||
|
@ -1281,7 +1281,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate lighting
|
// calculate lighting
|
||||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||||
|
|
||||||
if (pindex >= MAXLIGHTSCALE)
|
if (pindex >= MAXLIGHTSCALE)
|
||||||
pindex = MAXLIGHTSCALE - 1;
|
pindex = MAXLIGHTSCALE - 1;
|
||||||
|
@ -1486,7 +1486,7 @@ static void R_RenderSegLoop (void)
|
||||||
if (segtextured)
|
if (segtextured)
|
||||||
{
|
{
|
||||||
// calculate lighting
|
// calculate lighting
|
||||||
pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||||
|
|
||||||
if (pindex >= MAXLIGHTSCALE)
|
if (pindex >= MAXLIGHTSCALE)
|
||||||
pindex = MAXLIGHTSCALE-1;
|
pindex = MAXLIGHTSCALE-1;
|
||||||
|
@ -1521,7 +1521,7 @@ static void R_RenderSegLoop (void)
|
||||||
else
|
else
|
||||||
xwalllights = scalelight[lightnum];
|
xwalllights = scalelight[lightnum];
|
||||||
|
|
||||||
pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||||
|
|
||||||
if (pindex >= MAXLIGHTSCALE)
|
if (pindex >= MAXLIGHTSCALE)
|
||||||
pindex = MAXLIGHTSCALE-1;
|
pindex = MAXLIGHTSCALE-1;
|
||||||
|
|
|
@ -1097,7 +1097,7 @@ static void R_SplitSprite(vissprite_t *sprite)
|
||||||
if (!((newsprite->cut & SC_FULLBRIGHT)
|
if (!((newsprite->cut & SC_FULLBRIGHT)
|
||||||
&& (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1))))
|
&& (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1))))
|
||||||
{
|
{
|
||||||
lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT);
|
lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT);
|
||||||
|
|
||||||
if (lindex >= MAXLIGHTSCALE)
|
if (lindex >= MAXLIGHTSCALE)
|
||||||
lindex = MAXLIGHTSCALE-1;
|
lindex = MAXLIGHTSCALE-1;
|
||||||
|
@ -1872,7 +1872,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// diminished light
|
// diminished light
|
||||||
lindex = FixedMul(xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT);
|
lindex = FixedMul(xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT);
|
||||||
|
|
||||||
if (lindex >= MAXLIGHTSCALE)
|
if (lindex >= MAXLIGHTSCALE)
|
||||||
lindex = MAXLIGHTSCALE-1;
|
lindex = MAXLIGHTSCALE-1;
|
||||||
|
|
Loading…
Reference in New Issue