precalc fakecontrast on mapload
This commit is contained in:
1 parent
bce621d647
commit
6df8f5b35c
4 files changed
+42
-46
No files matched your search
+11
-21
@@ -583,30 +583,20 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if
|
||||
return surfcolor.s.alpha;
|
||||
}
|
||||
|
||||
static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y)
|
||||
// Lightnum = current light
|
||||
// line = the seg to get the light offset from
|
||||
static FUINT HWR_CalcWallLight(seg_t *line, FUINT lightnum)
|
||||
{
|
||||
INT16 finallight = lightnum;
|
||||
|
||||
if (cv_grfakecontrast.value != 0)
|
||||
{
|
||||
const UINT8 contrast = 8;
|
||||
fixed_t extralight = 0;
|
||||
|
||||
if (cv_grfakecontrast.value == 2) // Smooth setting
|
||||
{
|
||||
extralight = (-(contrast<<FRACBITS) +
|
||||
FixedDiv(AngleFixed(R_PointToAngle2(0, 0,
|
||||
abs(v1x - v2x),
|
||||
abs(v1y - v2y))), 90<<FRACBITS)
|
||||
* (contrast * 2)) >> FRACBITS;
|
||||
}
|
||||
extralight += line->hwLightOffset;
|
||||
else
|
||||
{
|
||||
if (v1y == v2y)
|
||||
extralight = -contrast;
|
||||
else if (v1x == v2x)
|
||||
extralight = contrast;
|
||||
}
|
||||
extralight += line->lightOffset * 8;
|
||||
|
||||
if (extralight != 0)
|
||||
{
|
||||
@@ -1095,7 +1085,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
|
||||
fixed_t v2y = FloatToFixed(wallVerts[1].z);
|
||||
|
||||
const UINT8 alpha = Surf->PolyColor.s.alpha;
|
||||
FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y);
|
||||
FUINT lightnum = HWR_CalcWallLight(gr_curline, sector->lightlevel);
|
||||
extracolormap_t *colormap = NULL;
|
||||
|
||||
realtop = top = wallVerts[3].y;
|
||||
@@ -1134,13 +1124,13 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
|
||||
{
|
||||
lightnum = pfloor->master->frontsector->lightlevel;
|
||||
colormap = pfloor->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightnum = *list[i].lightlevel;
|
||||
colormap = list[i].extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1498,7 +1488,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
|
||||
lightnum = gr_frontsector->lightlevel;
|
||||
colormap = gr_frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum);
|
||||
|
||||
if (gr_linedef->flags & ML_TFERLINE)
|
||||
noencore = true;
|
||||
@@ -2121,7 +2111,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
|
||||
lightnum = rover->master->frontsector->lightlevel;
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum);
|
||||
|
||||
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
|
||||
|
||||
@@ -2235,7 +2225,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
|
||||
lightnum = rover->master->frontsector->lightlevel;
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum);
|
||||
|
||||
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
|
||||
|
||||
|
||||
@@ -530,6 +530,7 @@ static void P_LoadRawSegs(UINT8 *data)
|
||||
mapseg_t *ml = (mapseg_t*)data;
|
||||
seg_t *li = segs;
|
||||
line_t *ldef;
|
||||
fixed_t extralight = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < numsegs; i++, li++, ml++)
|
||||
@@ -559,6 +560,17 @@ static void P_LoadRawSegs(UINT8 *data)
|
||||
|
||||
li->numlights = 0;
|
||||
li->rlights = NULL;
|
||||
|
||||
extralight = -(8*FRACUNIT) +
|
||||
FixedDiv(AngleFixed(R_PointToAngle2(0, 0,
|
||||
abs(li->v1->x - li->v2->x),
|
||||
abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * 16;
|
||||
|
||||
// Between -1 and 1 for software, -8 and 8 for hardware
|
||||
li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT;
|
||||
#ifdef HWRENDER
|
||||
li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -532,6 +532,12 @@ typedef struct seg_s
|
||||
r_lightlist_t *rlights;
|
||||
polyobj_t *polyseg;
|
||||
boolean dontrenderme;
|
||||
|
||||
// Fake contrast calculated on level load
|
||||
SINT8 lightOffset;
|
||||
#ifdef HWRENDER
|
||||
INT16 hwLightOffset;
|
||||
#endif
|
||||
} seg_t;
|
||||
|
||||
//
|
||||
|
||||
+13
-25
@@ -406,10 +406,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||
|
||||
if (rlight->extra_colormap && rlight->extra_colormap->fog)
|
||||
;
|
||||
else if (curline->v1->y == curline->v2->y)
|
||||
lightnum--;
|
||||
else if (curline->v1->x == curline->v2->x)
|
||||
lightnum++;
|
||||
else
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
rlight->lightnum = lightnum;
|
||||
}
|
||||
@@ -429,10 +427,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||
if (colfunc == R_DrawFogColumn_8
|
||||
|| (frontsector->extra_colormap && frontsector->extra_colormap->fog))
|
||||
;
|
||||
else if (curline->v1->y == curline->v2->y)
|
||||
lightnum--;
|
||||
else if (curline->v1->x == curline->v2->x)
|
||||
lightnum++;
|
||||
else
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
if (lightnum < 0)
|
||||
walllights = scalelight[0];
|
||||
@@ -836,10 +832,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||
|
||||
if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog))
|
||||
;
|
||||
else if (curline->v1->y == curline->v2->y)
|
||||
rlight->lightnum--;
|
||||
else if (curline->v1->x == curline->v2->x)
|
||||
rlight->lightnum++;
|
||||
else
|
||||
rlight->lightnum += curline->lightOffset;
|
||||
|
||||
p++;
|
||||
}
|
||||
@@ -859,11 +853,10 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||
lightnum = R_FakeFlat(frontsector, &tempsec, &templight, &templight, false)
|
||||
->lightlevel >> LIGHTSEGSHIFT;
|
||||
|
||||
if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog));
|
||||
else if (curline->v1->y == curline->v2->y)
|
||||
lightnum--;
|
||||
else if (curline->v1->x == curline->v2->x)
|
||||
lightnum++;
|
||||
if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog))
|
||||
;
|
||||
else
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
if (lightnum < 0)
|
||||
walllights = scalelight[0];
|
||||
@@ -1416,10 +1409,8 @@ static void R_RenderSegLoop (void)
|
||||
|
||||
if (dc_lightlist[i].extra_colormap)
|
||||
;
|
||||
else if (curline->v1->y == curline->v2->y)
|
||||
lightnum--;
|
||||
else if (curline->v1->x == curline->v2->x)
|
||||
lightnum++;
|
||||
else
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
if (lightnum < 0)
|
||||
xwalllights = scalelight[0];
|
||||
@@ -2436,10 +2427,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
// OPTIMIZE: get rid of LIGHTSEGSHIFT globally
|
||||
lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);
|
||||
|
||||
if (curline->v1->y == curline->v2->y)
|
||||
lightnum--;
|
||||
else if (curline->v1->x == curline->v2->x)
|
||||
lightnum++;
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
if (lightnum < 0)
|
||||
walllights = scalelight[0];
|
||||
|
||||
Reference in new issue
Block a user