mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'fake-contrast-2-electric-boogaloo' into 'master'
Fake contrast 2: Electric Boogaloo See merge request KartKrew/Kart!267
This commit is contained in:
commit
7132eeab48
7 changed files with 72 additions and 64 deletions
|
|
@ -223,30 +223,18 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if
|
||||||
return surfcolor.s.alpha;
|
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;
|
INT16 finallight = lightnum;
|
||||||
|
|
||||||
if (cv_grfakecontrast.value != 0)
|
|
||||||
{
|
|
||||||
const UINT8 contrast = 8;
|
|
||||||
fixed_t extralight = 0;
|
fixed_t extralight = 0;
|
||||||
|
|
||||||
if (cv_grfakecontrast.value == 2) // Smooth setting
|
if (cv_grfakecontrast.value == 1) // Smooth setting
|
||||||
{
|
extralight += line->hwLightOffset;
|
||||||
extralight = (-(contrast<<FRACBITS) +
|
|
||||||
FixedDiv(AngleFixed(R_PointToAngle2(0, 0,
|
|
||||||
abs(v1x - v2x),
|
|
||||||
abs(v1y - v2y))), 90<<FRACBITS)
|
|
||||||
* (contrast * 2)) >> FRACBITS;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
extralight += line->lightOffset * 8;
|
||||||
if (v1y == v2y)
|
|
||||||
extralight = -contrast;
|
|
||||||
else if (v1x == v2x)
|
|
||||||
extralight = contrast;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extralight != 0)
|
if (extralight != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -257,7 +245,6 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t
|
||||||
if (finallight > 255)
|
if (finallight > 255)
|
||||||
finallight = 255;
|
finallight = 255;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (FUINT)finallight;
|
return (FUINT)finallight;
|
||||||
}
|
}
|
||||||
|
|
@ -618,7 +605,7 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa
|
||||||
INT32 solid, i;
|
INT32 solid, i;
|
||||||
lightlist_t * list = sector->lightlist;
|
lightlist_t * list = sector->lightlist;
|
||||||
const UINT8 alpha = Surf->PolyColor.s.alpha;
|
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;
|
extracolormap_t *colormap = NULL;
|
||||||
|
|
||||||
realtop = top = wallVerts[3].y;
|
realtop = top = wallVerts[3].y;
|
||||||
|
|
@ -647,12 +634,12 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa
|
||||||
{
|
{
|
||||||
if (pfloor && (pfloor->flags & FF_FOG))
|
if (pfloor && (pfloor->flags & FF_FOG))
|
||||||
{
|
{
|
||||||
lightnum = HWR_CalcWallLight(pfloor->master->frontsector->lightlevel, v1x, v1y, v2x, v2y);
|
lightnum = HWR_CalcWallLight(gr_curline, pfloor->master->frontsector->lightlevel);
|
||||||
colormap = pfloor->master->frontsector->extra_colormap;
|
colormap = pfloor->master->frontsector->extra_colormap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lightnum = HWR_CalcWallLight(*list[i].lightlevel, v1x, v1y, v2x, v2y);
|
lightnum = HWR_CalcWallLight(gr_curline, *list[i].lightlevel);
|
||||||
colormap = list[i].extra_colormap;
|
colormap = list[i].extra_colormap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -933,7 +920,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT));
|
cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
|
lightnum = HWR_CalcWallLight(gr_curline, gr_frontsector->lightlevel);
|
||||||
colormap = gr_frontsector->extra_colormap;
|
colormap = gr_frontsector->extra_colormap;
|
||||||
|
|
||||||
if (gr_frontsector)
|
if (gr_frontsector)
|
||||||
|
|
@ -1759,7 +1746,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
|
|
||||||
blendmode = PF_Fog|PF_NoTexture;
|
blendmode = PF_Fog|PF_NoTexture;
|
||||||
|
|
||||||
lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
|
lightnum = HWR_CalcWallLight(gr_curline, rover->master->frontsector->lightlevel);
|
||||||
colormap = rover->master->frontsector->extra_colormap;
|
colormap = rover->master->frontsector->extra_colormap;
|
||||||
|
|
||||||
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
|
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
|
||||||
|
|
@ -1871,7 +1858,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
|
|
||||||
blendmode = PF_Fog|PF_NoTexture;
|
blendmode = PF_Fog|PF_NoTexture;
|
||||||
|
|
||||||
lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
|
lightnum = HWR_CalcWallLight(gr_curline, rover->master->frontsector->lightlevel);
|
||||||
colormap = rover->master->frontsector->extra_colormap;
|
colormap = rover->master->frontsector->extra_colormap;
|
||||||
|
|
||||||
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
|
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
|
||||||
|
|
|
||||||
|
|
@ -1407,7 +1407,10 @@ static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings)
|
||||||
{
|
{
|
||||||
// update seg angles (used only by renderer)
|
// update seg angles (used only by renderer)
|
||||||
for (i = 0; i < po->segCount; ++i)
|
for (i = 0; i < po->segCount; ++i)
|
||||||
|
{
|
||||||
po->segs[i]->angle += delta;
|
po->segs[i]->angle += delta;
|
||||||
|
P_UpdateSegLightOffset(po->segs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// update polyobject's angle
|
// update polyobject's angle
|
||||||
po->angle += delta;
|
po->angle += delta;
|
||||||
|
|
|
||||||
|
|
@ -446,6 +446,27 @@ static inline float P_SegLengthFloat(seg_t *seg)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Updates the light offset
|
||||||
|
*
|
||||||
|
* \param li Seg to update the light offsets of
|
||||||
|
*/
|
||||||
|
void P_UpdateSegLightOffset(seg_t *li)
|
||||||
|
{
|
||||||
|
const UINT8 contrast = 16;
|
||||||
|
fixed_t extralight = 0;
|
||||||
|
|
||||||
|
extralight = -((fixed_t)contrast*FRACUNIT) +
|
||||||
|
FixedDiv(AngleFixed(R_PointToAngle2(0, 0,
|
||||||
|
abs(li->v1->x - li->v2->x),
|
||||||
|
abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * ((fixed_t)contrast * 2);
|
||||||
|
|
||||||
|
// Between -2 and 2 for software, -16 and 16 for hardware
|
||||||
|
li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT;
|
||||||
|
#ifdef HWRENDER
|
||||||
|
li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/** Loads the SEGS resource from a level.
|
/** Loads the SEGS resource from a level.
|
||||||
*
|
*
|
||||||
* \param lump Lump number of the SEGS resource.
|
* \param lump Lump number of the SEGS resource.
|
||||||
|
|
@ -492,6 +513,8 @@ static void P_LoadRawSegs(UINT8 *data, size_t i)
|
||||||
|
|
||||||
li->numlights = 0;
|
li->numlights = 0;
|
||||||
li->rlights = NULL;
|
li->rlights = NULL;
|
||||||
|
|
||||||
|
P_UpdateSegLightOffset(li);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ boolean P_DelWadFile(void);
|
||||||
#endif
|
#endif
|
||||||
boolean P_RunSOC(const char *socfilename);
|
boolean P_RunSOC(const char *socfilename);
|
||||||
void P_WriteThings(lumpnum_t lump);
|
void P_WriteThings(lumpnum_t lump);
|
||||||
|
void P_UpdateSegLightOffset(seg_t *li);
|
||||||
size_t P_PrecacheLevelFlats(void);
|
size_t P_PrecacheLevelFlats(void);
|
||||||
void P_AllocMapHeader(INT16 i);
|
void P_AllocMapHeader(INT16 i);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -565,6 +565,12 @@ typedef struct seg_s
|
||||||
polyobj_t *polyseg;
|
polyobj_t *polyseg;
|
||||||
boolean dontrenderme;
|
boolean dontrenderme;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Fake contrast calculated on level load
|
||||||
|
SINT8 lightOffset;
|
||||||
|
#ifdef HWRENDER
|
||||||
|
INT16 hwLightOffset;
|
||||||
|
#endif
|
||||||
} seg_t;
|
} seg_t;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
||||||
38
src/r_segs.c
38
src/r_segs.c
|
|
@ -412,10 +412,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||||
|
|
||||||
if (rlight->extra_colormap && rlight->extra_colormap->fog)
|
if (rlight->extra_colormap && rlight->extra_colormap->fog)
|
||||||
;
|
;
|
||||||
else if (curline->v1->y == curline->v2->y)
|
else
|
||||||
lightnum--;
|
lightnum += curline->lightOffset;
|
||||||
else if (curline->v1->x == curline->v2->x)
|
|
||||||
lightnum++;
|
|
||||||
|
|
||||||
rlight->lightnum = lightnum;
|
rlight->lightnum = lightnum;
|
||||||
}
|
}
|
||||||
|
|
@ -435,10 +433,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||||
if (colfunc == R_DrawFogColumn_8
|
if (colfunc == R_DrawFogColumn_8
|
||||||
|| (frontsector->extra_colormap && frontsector->extra_colormap->fog))
|
|| (frontsector->extra_colormap && frontsector->extra_colormap->fog))
|
||||||
;
|
;
|
||||||
else if (curline->v1->y == curline->v2->y)
|
else
|
||||||
lightnum--;
|
lightnum += curline->lightOffset;
|
||||||
else if (curline->v1->x == curline->v2->x)
|
|
||||||
lightnum++;
|
|
||||||
|
|
||||||
if (lightnum < 0)
|
if (lightnum < 0)
|
||||||
walllights = scalelight[0];
|
walllights = scalelight[0];
|
||||||
|
|
@ -932,10 +928,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))
|
if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog))
|
||||||
;
|
;
|
||||||
else if (curline->v1->y == curline->v2->y)
|
else
|
||||||
rlight->lightnum--;
|
rlight->lightnum += curline->lightOffset;
|
||||||
else if (curline->v1->x == curline->v2->x)
|
|
||||||
rlight->lightnum++;
|
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
@ -955,11 +949,10 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||||
lightnum = R_FakeFlat(frontsector, &tempsec, &templight, &templight, false)
|
lightnum = R_FakeFlat(frontsector, &tempsec, &templight, &templight, false)
|
||||||
->lightlevel >> LIGHTSEGSHIFT;
|
->lightlevel >> LIGHTSEGSHIFT;
|
||||||
|
|
||||||
if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog));
|
if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog))
|
||||||
else if (curline->v1->y == curline->v2->y)
|
;
|
||||||
lightnum--;
|
else
|
||||||
else if (curline->v1->x == curline->v2->x)
|
lightnum += curline->lightOffset;
|
||||||
lightnum++;
|
|
||||||
|
|
||||||
if (lightnum < 0)
|
if (lightnum < 0)
|
||||||
walllights = scalelight[0];
|
walllights = scalelight[0];
|
||||||
|
|
@ -1492,10 +1485,8 @@ static void R_RenderSegLoop (void)
|
||||||
|
|
||||||
if (dc_lightlist[i].extra_colormap)
|
if (dc_lightlist[i].extra_colormap)
|
||||||
;
|
;
|
||||||
else if (curline->v1->y == curline->v2->y)
|
else
|
||||||
lightnum--;
|
lightnum += curline->lightOffset;
|
||||||
else if (curline->v1->x == curline->v2->x)
|
|
||||||
lightnum++;
|
|
||||||
|
|
||||||
if (lightnum < 0)
|
if (lightnum < 0)
|
||||||
xwalllights = scalelight[0];
|
xwalllights = scalelight[0];
|
||||||
|
|
@ -2639,10 +2630,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||||
// OPTIMIZE: get rid of LIGHTSEGSHIFT globally
|
// OPTIMIZE: get rid of LIGHTSEGSHIFT globally
|
||||||
lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);
|
lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);
|
||||||
|
|
||||||
if (curline->v1->y == curline->v2->y)
|
lightnum += curline->lightOffset;
|
||||||
lightnum--;
|
|
||||||
else if (curline->v1->x == curline->v2->x)
|
|
||||||
lightnum++;
|
|
||||||
|
|
||||||
if (lightnum < 0)
|
if (lightnum < 0)
|
||||||
walllights = scalelight[0];
|
walllights = scalelight[0];
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ static void CV_Gammaxxx_ONChange(void);
|
||||||
// - You can change them in software,
|
// - You can change them in software,
|
||||||
// but they won't do anything.
|
// but they won't do anything.
|
||||||
static CV_PossibleValue_t grgamma_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}};
|
static CV_PossibleValue_t grgamma_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}};
|
||||||
static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "Standard"}, {2, "Smooth"}, {0, NULL}};
|
static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Standard"}, {1, "Smooth"}, {0, NULL}};
|
||||||
|
|
||||||
consvar_t cv_grshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_grshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue