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