mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-19 20:12:01 +00:00
Better fake contrast.
Fake contrast for the segs are calculated at map load. OpenGL only has the options "Standard" and "Smooth" now. Standard is default and replicates software. Smooth changes the contrast more smoothly depending on angle.
This commit is contained in:
parent
843721cc8f
commit
d4080e94f7
5 changed files with 57 additions and 64 deletions
|
|
@ -223,40 +223,27 @@ 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)
|
||||
fixed_t extralight = 0;
|
||||
|
||||
if (cv_grfakecontrast.value == 1) // Smooth setting
|
||||
extralight += line->hwLightOffset;
|
||||
else
|
||||
extralight += line->lightOffset * 8;
|
||||
|
||||
if (extralight != 0)
|
||||
{
|
||||
const UINT8 contrast = 8;
|
||||
fixed_t extralight = 0;
|
||||
finallight += extralight;
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (v1y == v2y)
|
||||
extralight = -contrast;
|
||||
else if (v1x == v2x)
|
||||
extralight = contrast;
|
||||
}
|
||||
|
||||
if (extralight != 0)
|
||||
{
|
||||
finallight += extralight;
|
||||
|
||||
if (finallight < 0)
|
||||
finallight = 0;
|
||||
if (finallight > 255)
|
||||
finallight = 255;
|
||||
}
|
||||
if (finallight < 0)
|
||||
finallight = 0;
|
||||
if (finallight > 255)
|
||||
finallight = 255;
|
||||
}
|
||||
|
||||
return (FUINT)finallight;
|
||||
|
|
@ -618,7 +605,7 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa
|
|||
INT32 solid, i;
|
||||
lightlist_t * list = sector->lightlist;
|
||||
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;
|
||||
|
|
@ -647,12 +634,12 @@ void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfa
|
|||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
lightnum = HWR_CalcWallLight(*list[i].lightlevel, v1x, v1y, v2x, v2y);
|
||||
lightnum = HWR_CalcWallLight(gr_curline, *list[i].lightlevel);
|
||||
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));
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (gr_frontsector)
|
||||
|
|
@ -1759,7 +1746,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
|||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
|
||||
|
|
@ -3596,10 +3583,10 @@ static int CompareVisSprites(const void *p1, const void *p2)
|
|||
gr_vissprite_t* spr2 = *(gr_vissprite_t*const*)p2;
|
||||
int idiff;
|
||||
float fdiff;
|
||||
|
||||
|
||||
// make transparent sprites last
|
||||
// "boolean to int"
|
||||
|
||||
|
||||
int transparency1 = (spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK);
|
||||
int transparency2 = (spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK);
|
||||
idiff = transparency1 - transparency2;
|
||||
|
|
|
|||
|
|
@ -457,6 +457,7 @@ static void P_LoadRawSegs(UINT8 *data, size_t i)
|
|||
mapseg_t *ml;
|
||||
seg_t *li;
|
||||
line_t *ldef;
|
||||
fixed_t extralight = 0;
|
||||
|
||||
numsegs = i / sizeof (mapseg_t);
|
||||
if (numsegs <= 0)
|
||||
|
|
@ -492,6 +493,17 @@ static void P_LoadRawSegs(UINT8 *data, size_t i)
|
|||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1091,7 +1103,7 @@ static void P_LoadThings(void)
|
|||
|| mt->type == 1705 || mt->type == 1713 || mt->type == 1800)
|
||||
{
|
||||
sector_t *mtsector = R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector;
|
||||
|
||||
|
||||
mt->mobj = NULL;
|
||||
|
||||
// Z for objects
|
||||
|
|
|
|||
|
|
@ -565,6 +565,12 @@ typedef struct seg_s
|
|||
polyobj_t *polyseg;
|
||||
boolean dontrenderme;
|
||||
#endif
|
||||
|
||||
// Fake contrast calculated on level load
|
||||
SINT8 lightOffset;
|
||||
#ifdef HWRENDER
|
||||
INT16 hwLightOffset;
|
||||
#endif
|
||||
} 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)
|
||||
;
|
||||
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;
|
||||
}
|
||||
|
|
@ -435,10 +433,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];
|
||||
|
|
@ -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))
|
||||
;
|
||||
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++;
|
||||
}
|
||||
|
|
@ -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)
|
||||
->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];
|
||||
|
|
@ -1492,10 +1485,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];
|
||||
|
|
@ -2639,10 +2630,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];
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ static void CV_Gammaxxx_ONChange(void);
|
|||
// - You can change them in software,
|
||||
// but they won't do anything.
|
||||
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_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue