mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 08:41:59 +00:00
Renderer floatification: Use floats for lighting values
This commit is contained in:
parent
4416d88eb2
commit
ec8d038c99
9 changed files with 42 additions and 42 deletions
|
@ -294,11 +294,11 @@ R_DrawTiltedPlane_ASM:
|
|||
fmul dword [planelightfloat]
|
||||
fxch st1
|
||||
fmul dword [planelightfloat]
|
||||
sub esp,8
|
||||
fistp dword [esp]
|
||||
fistp dword [esp+4]
|
||||
sub esp,16
|
||||
fstp qword [esp]
|
||||
fstp qword [esp+8]
|
||||
call R_CalcTiltedLighting
|
||||
add esp, 12
|
||||
add esp, 20
|
||||
xor eax, eax
|
||||
|
||||
.litup add esp, 8
|
||||
|
|
|
@ -65,7 +65,7 @@ enum
|
|||
struct drawseg_t
|
||||
{
|
||||
seg_t* curline;
|
||||
fixed_t light, lightstep;
|
||||
float light, lightstep;
|
||||
fixed_t iscale, iscalestep;
|
||||
short x1, x2; // Same as sx1 and sx2, but clipped to the drawseg
|
||||
short sx1, sx2; // left, right of parent seg on screen
|
||||
|
|
|
@ -1757,8 +1757,8 @@ void mvlinec4 ()
|
|||
#endif
|
||||
|
||||
extern "C" short spanend[MAXHEIGHT];
|
||||
extern fixed_t rw_light;
|
||||
extern fixed_t rw_lightstep;
|
||||
extern float rw_light;
|
||||
extern float rw_lightstep;
|
||||
extern int wallshade;
|
||||
|
||||
static void R_DrawFogBoundarySection (int y, int y2, int x1)
|
||||
|
@ -1795,12 +1795,12 @@ void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip)
|
|||
// to create new horizontal spans whenever the light changes enough that
|
||||
// we need to use a new colormap.
|
||||
|
||||
fixed_t lightstep = rw_lightstep;
|
||||
fixed_t light = rw_light+lightstep*(x2-x1-1);
|
||||
double lightstep = rw_lightstep;
|
||||
double light = rw_light + rw_lightstep*(x2-x1-1);
|
||||
int x = x2-1;
|
||||
int t2 = uclip[x];
|
||||
int b2 = dclip[x];
|
||||
int rcolormap = GETPALOOKUP (light, wallshade);
|
||||
int rcolormap = GETPALOOKUP(light, wallshade);
|
||||
int lcolormap;
|
||||
BYTE *basecolormapdata = basecolormap->Maps;
|
||||
|
||||
|
@ -1819,7 +1819,7 @@ void R_DrawFogBoundary (int x1, int x2, short *uclip, short *dclip)
|
|||
int stop;
|
||||
|
||||
light -= rw_lightstep;
|
||||
lcolormap = GETPALOOKUP (light, wallshade);
|
||||
lcolormap = GETPALOOKUP(light, wallshade);
|
||||
if (lcolormap != rcolormap)
|
||||
{
|
||||
if (t2 < b2 && rcolormap != 0)
|
||||
|
|
|
@ -75,12 +75,12 @@ extern bool r_dontmaplines;
|
|||
#define LIGHT2SHADE(l) ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128)))
|
||||
|
||||
// MAXLIGHTSCALE from original DOOM, divided by 2.
|
||||
#define MAXLIGHTVIS (24*FRACUNIT)
|
||||
#define MAXLIGHTVIS (24.0)
|
||||
|
||||
// Convert a shade and visibility to a clamped colormap index.
|
||||
// Result is not fixed point.
|
||||
// Change R_CalcTiltedLighting() when this changes.
|
||||
#define GETPALOOKUP(vis,shade) (clamp<int> (((shade)-MIN(MAXLIGHTVIS,(vis)))>>FRACBITS, 0, NUMCOLORMAPS-1))
|
||||
#define GETPALOOKUP(vis,shade) (clamp<int> (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1))
|
||||
|
||||
extern double GlobVis;
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ void R_MapPlane (int y, int x1)
|
|||
{
|
||||
// Determine lighting based on the span's distance from the viewer.
|
||||
ds_colormap = basecolormap->Maps + (GETPALOOKUP (
|
||||
FLOAT2FIXED(GlobVis * fabs(CenterY - y)), planeshade) << COLORMAPSHIFT);
|
||||
GlobVis * fabs(CenterY - y), planeshade) << COLORMAPSHIFT);
|
||||
}
|
||||
|
||||
#ifdef X86_ASM
|
||||
|
@ -253,9 +253,9 @@ void R_MapPlane (int y, int x1)
|
|||
//==========================================================================
|
||||
|
||||
extern "C" {
|
||||
void R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
|
||||
void R_CalcTiltedLighting (double lval, double lend, int width)
|
||||
{
|
||||
fixed_t lstep;
|
||||
double lstep;
|
||||
BYTE *lightfiller;
|
||||
BYTE *basecolormapdata = basecolormap->Maps;
|
||||
int i = 0;
|
||||
|
@ -311,7 +311,7 @@ void R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
|
|||
}
|
||||
while (i <= width && lval >= 0)
|
||||
{
|
||||
tiltlighting[i++] = basecolormapdata + ((lval >> FRACBITS) << COLORMAPSHIFT);
|
||||
tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT);
|
||||
lval += lstep;
|
||||
}
|
||||
lightfiller = basecolormapdata;
|
||||
|
@ -334,7 +334,7 @@ void R_CalcTiltedLighting (fixed_t lval, fixed_t lend, int width)
|
|||
return;
|
||||
while (i <= width && lval < (NUMCOLORMAPS-1)*FRACUNIT)
|
||||
{
|
||||
tiltlighting[i++] = basecolormapdata + ((lval >> FRACBITS) << COLORMAPSHIFT);
|
||||
tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT);
|
||||
lval += lstep;
|
||||
}
|
||||
lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT);
|
||||
|
@ -371,7 +371,7 @@ void R_MapTiltedPlane (int y, int x1)
|
|||
{
|
||||
uz = (iz + plane_sz[0]*width) * planelightfloat;
|
||||
vz = iz * planelightfloat;
|
||||
R_CalcTiltedLighting (xs_RoundToInt(vz), xs_RoundToInt(uz), width);
|
||||
R_CalcTiltedLighting (vz, uz, width);
|
||||
}
|
||||
|
||||
uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx);
|
||||
|
@ -1709,7 +1709,7 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
|
|||
plane_sz[0] = -plane_sz[0];
|
||||
}
|
||||
|
||||
planelightfloat = (r_TiltVisibility * lxscale * lyscale) / fabs(pl->height.ZatPoint(ViewPos));
|
||||
planelightfloat = (r_TiltVisibility * lxscale * lyscale) / (fabs(pl->height.ZatPoint(ViewPos) - ViewPos.Z)) / 65536.f;
|
||||
|
||||
if (pl->height.fC() > 0)
|
||||
planelightfloat = -planelightfloat;
|
||||
|
|
|
@ -39,7 +39,7 @@ struct visplane_s
|
|||
int lightlevel;
|
||||
fixed_t xoffs, yoffs; // killough 2/28/98: Support scrolling flats
|
||||
int left, right;
|
||||
FDynamicColormap *colormap; // [RH] Support multiple colormaps
|
||||
FDynamicColormap *colormap; // [RH] Support multiple colormaps
|
||||
fixed_t xscale, yscale; // [RH] Support flat scaling
|
||||
angle_t angle; // [RH] Support flat rotation
|
||||
int sky;
|
||||
|
|
|
@ -110,9 +110,9 @@ bool rw_markportal;
|
|||
bool rw_havehigh;
|
||||
bool rw_havelow;
|
||||
|
||||
fixed_t rw_light; // [RH] Scale lights with viewsize adjustments
|
||||
fixed_t rw_lightstep;
|
||||
fixed_t rw_lightleft;
|
||||
float rw_light; // [RH] Scale lights with viewsize adjustments
|
||||
float rw_lightstep;
|
||||
float rw_lightleft;
|
||||
|
||||
static double rw_frontlowertop;
|
||||
|
||||
|
@ -1080,7 +1080,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t
|
|||
int x, shiftval;
|
||||
int y1ve[4], y2ve[4], u4, d4, z;
|
||||
char bad;
|
||||
fixed_t light = rw_light - rw_lightstep;
|
||||
float light = rw_light - rw_lightstep;
|
||||
SDWORD texturemid, xoffset;
|
||||
BYTE *basecolormapdata;
|
||||
|
||||
|
@ -1158,7 +1158,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t
|
|||
}
|
||||
if (bad == 15)
|
||||
{
|
||||
light += rw_lightstep << 2;
|
||||
light += rw_lightstep * 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1432,7 +1432,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe
|
|||
BYTE *p;
|
||||
int y1ve[4], y2ve[4], u4, d4, startx, dax, z;
|
||||
char bad;
|
||||
fixed_t light = rw_light - rw_lightstep;
|
||||
float light = rw_light - rw_lightstep;
|
||||
SDWORD texturemid, xoffset;
|
||||
BYTE *basecolormapdata;
|
||||
|
||||
|
@ -1507,7 +1507,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe
|
|||
}
|
||||
if (bad == 15)
|
||||
{
|
||||
light += rw_lightstep << 2;
|
||||
light += rw_lightstep * 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1605,7 +1605,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal,
|
|||
BYTE *p;
|
||||
int y1ve[4], y2ve[4], u4, d4, startx, dax, z;
|
||||
char bad;
|
||||
fixed_t light = rw_light - rw_lightstep;
|
||||
float light = rw_light - rw_lightstep;
|
||||
SDWORD texturemid, xoffset;
|
||||
BYTE *basecolormapdata;
|
||||
|
||||
|
@ -1681,7 +1681,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal,
|
|||
}
|
||||
if (bad == 15)
|
||||
{
|
||||
light += rw_lightstep << 2;
|
||||
light += rw_lightstep * 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2312,12 +2312,12 @@ void R_NewWall (bool needlights)
|
|||
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel)
|
||||
+ r_actualextralight);
|
||||
GlobVis = r_WallVisibility;
|
||||
rw_lightleft = FLOAT2FIXED(GlobVis / WallC.sz1);
|
||||
rw_lightstep = (FLOAT2FIXED(GlobVis / WallC.sz2) - rw_lightleft) / (WallC.sx2 - WallC.sx1);
|
||||
rw_lightleft = float (GlobVis / WallC.sz1);
|
||||
rw_lightstep = float((GlobVis / WallC.sz2 - rw_lightleft) / (WallC.sx2 - WallC.sx1));
|
||||
}
|
||||
else
|
||||
{
|
||||
rw_lightleft = FRACUNIT;
|
||||
rw_lightleft = 1;
|
||||
rw_lightstep = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ void R_RenderSegLoop ();
|
|||
|
||||
extern fixed_t swall[MAXWIDTH];
|
||||
extern fixed_t lwall[MAXWIDTH];
|
||||
extern fixed_t rw_light; // [RH] Scale lights with viewsize adjustments
|
||||
extern fixed_t rw_lightstep;
|
||||
extern fixed_t rw_lightleft;
|
||||
extern float rw_light; // [RH] Scale lights with viewsize adjustments
|
||||
extern float rw_lightstep;
|
||||
extern float rw_lightleft;
|
||||
extern fixed_t rw_offset;
|
||||
|
||||
/* portal structure, this is used in r_ code in order to store drawsegs with portals (and mirrors) */
|
||||
|
|
|
@ -533,8 +533,8 @@ void R_DrawWallSprite(vissprite_t *spr)
|
|||
|
||||
int shade = LIGHT2SHADE(spr->sector->lightlevel + r_actualextralight);
|
||||
GlobVis = r_WallVisibility;
|
||||
rw_lightleft = FLOAT2FIXED(GlobVis / spr->wallc.sz1);
|
||||
rw_lightstep = (FLOAT2FIXED(GlobVis / spr->wallc.sz2) - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1);
|
||||
rw_lightleft = float (GlobVis / spr->wallc.sz1);
|
||||
rw_lightstep = float((GlobVis / spr->wallc.sz2 - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
|
||||
rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep;
|
||||
if (fixedlightlev >= 0)
|
||||
dc_colormap = usecolormap->Maps + fixedlightlev;
|
||||
|
@ -1128,7 +1128,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
|||
else
|
||||
{ // diminished light
|
||||
vis->ColormapNum = GETPALOOKUP(
|
||||
FLOAT2FIXED(r_SpriteVisibility / MAX(tz, MINZ)), spriteshade);
|
||||
r_SpriteVisibility / MAX(tz, MINZ), spriteshade);
|
||||
vis->Style.colormap = mybasecolormap->Maps + (vis->ColormapNum << COLORMAPSHIFT);
|
||||
}
|
||||
}
|
||||
|
@ -1204,7 +1204,7 @@ static void R_ProjectWallSprite(AActor *thing, const DVector3 &pos, FTextureID p
|
|||
vis->bIsVoxel = false;
|
||||
vis->bWallSprite = true;
|
||||
vis->ColormapNum = GETPALOOKUP(
|
||||
FLOAT2FIXED(r_SpriteVisibility / MAX(tz, MINZ)), spriteshade);
|
||||
r_SpriteVisibility / MAX(tz, MINZ), spriteshade);
|
||||
vis->Style.colormap = basecolormap->Maps + (vis->ColormapNum << COLORMAPSHIFT);
|
||||
vis->wallc = wallc;
|
||||
}
|
||||
|
@ -2002,7 +2002,7 @@ void R_DrawSprite (vissprite_t *spr)
|
|||
{ // diminished light
|
||||
spriteshade = LIGHT2SHADE(sec->lightlevel + r_actualextralight);
|
||||
spr->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP (
|
||||
FLOAT2FIXED(r_SpriteVisibility / MAX(MINZ, (double)spr->depth)), spriteshade) << COLORMAPSHIFT);
|
||||
r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade) << COLORMAPSHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2559,7 +2559,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade,
|
|||
else
|
||||
{
|
||||
// Particles are slightly more visible than regular sprites.
|
||||
vis->ColormapNum = GETPALOOKUP(FLOAT2FIXED(tiz * r_SpriteVisibility * 0.5), shade);
|
||||
vis->ColormapNum = GETPALOOKUP(tiz * r_SpriteVisibility * 0.5, shade);
|
||||
vis->Style.colormap = map + (vis->ColormapNum << COLORMAPSHIFT);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue