Merge branch 'thing-bright-override-colormap' into 'master'

Fix OGL semibright and ignore colormap for fullbright/semibright/fulldark

See merge request KartKrew/Kart!538
This commit is contained in:
SteelT 2022-01-23 19:01:44 +00:00
commit 7dc6542a4f
4 changed files with 37 additions and 29 deletions

View file

@ -181,6 +181,18 @@ boolean gl_shadersavailable = true;
// Lighting // Lighting
// ========================================================================== // ==========================================================================
boolean HWR_OverrideObjectLightLevel(mobj_t *thing, INT32 *lightlevel)
{
if (R_ThingIsFullBright(thing))
*lightlevel = 255;
else if (R_ThingIsFullDark(thing))
*lightlevel = 0;
else
return false;
return true;
}
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap) void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap)
{ {
RGBA_t poly_color, tint_color, fade_color; RGBA_t poly_color, tint_color, fade_color;
@ -3795,7 +3807,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
patch_t *gpatch; patch_t *gpatch;
FSurfaceInfo Surf; FSurfaceInfo Surf;
extracolormap_t *colormap = NULL; extracolormap_t *colormap = NULL;
FUINT lightlevel; INT32 lightlevel;
boolean lightset = true; boolean lightset = true;
FBITFIELD blend = 0; FBITFIELD blend = 0;
FBITFIELD occlusion; FBITFIELD occlusion;
@ -3925,18 +3937,13 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
// Start with the lightlevel and colormap from the top of the sprite // Start with the lightlevel and colormap from the top of the sprite
lightlevel = *list[sector->numlights - 1].lightlevel; lightlevel = *list[sector->numlights - 1].lightlevel;
if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) if (!R_ThingIsFullBright(spr->mobj) && !(spr->mobj->renderflags & RF_NOCOLORMAPS))
colormap = *list[sector->numlights - 1].extra_colormap; colormap = *list[sector->numlights - 1].extra_colormap;
i = 0; i = 0;
temp = FLOAT_TO_FIXED(realtop); temp = FLOAT_TO_FIXED(realtop);
if (R_ThingIsFullBright(spr->mobj)) lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel);
lightlevel = 255;
else if (R_ThingIsFullDark(spr->mobj))
lightlevel = 0;
else
lightset = false;
for (i = 1; i < sector->numlights; i++) for (i = 1; i < sector->numlights; i++)
{ {
@ -3945,7 +3952,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
{ {
if (!lightset) if (!lightset)
lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel;
if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) if (!R_ThingIsFullBright(spr->mobj) && !(spr->mobj->renderflags & RF_NOCOLORMAPS))
colormap = *list[i-1].extra_colormap; colormap = *list[i-1].extra_colormap;
break; break;
} }
@ -3963,8 +3970,14 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES))
{ {
if (!lightset) if (!lightset)
{
lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel;
if (!(spr->mobj->renderflags & RF_NOCOLORMAPS))
if (R_ThingIsSemiBright(spr->mobj))
lightlevel = 128 + (lightlevel>>1);
}
if (!R_ThingIsFullBright(spr->mobj) && !(spr->mobj->renderflags & RF_NOCOLORMAPS))
colormap = *list[i].extra_colormap; colormap = *list[i].extra_colormap;
} }
@ -4279,18 +4292,11 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
// colormap test // colormap test
{ {
sector_t *sector = spr->mobj->subsector->sector; sector_t *sector = spr->mobj->subsector->sector;
UINT8 lightlevel = 0; INT32 lightlevel = 0;
boolean lightset = true; boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel);
extracolormap_t *colormap = NULL; extracolormap_t *colormap = NULL;
if (R_ThingIsFullBright(spr->mobj)) if (!R_ThingIsFullBright(spr->mobj) && !(spr->mobj->renderflags & RF_NOCOLORMAPS))
lightlevel = 255;
else if (R_ThingIsFullDark(spr->mobj))
lightlevel = 0;
else
lightset = false;
if (!(spr->mobj->renderflags & RF_NOCOLORMAPS))
colormap = sector->extra_colormap; colormap = sector->extra_colormap;
if (splat && sector->numlights) if (splat && sector->numlights)
@ -4300,7 +4306,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
if (!lightset) if (!lightset)
lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel;
if (*sector->lightlist[light].extra_colormap && !(spr->mobj->renderflags & RF_NOCOLORMAPS)) if (!R_ThingIsFullBright(spr->mobj) && *sector->lightlist[light].extra_colormap && !(spr->mobj->renderflags & RF_NOCOLORMAPS))
colormap = *sector->lightlist[light].extra_colormap; colormap = *sector->lightlist[light].extra_colormap;
} }
else if (!lightset) else if (!lightset)

View file

@ -67,6 +67,7 @@ void HWR_MakeScreenFinalTexture(void);
void HWR_DrawScreenFinalTexture(int width, int height); void HWR_DrawScreenFinalTexture(int width, int height);
// This stuff is put here so models can use them // This stuff is put here so models can use them
boolean HWR_OverrideObjectLightLevel(mobj_t *thing, INT32 *lightlevel);
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap); void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap);
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work

View file

@ -1324,7 +1324,8 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
if (spr->mobj->subsector) if (spr->mobj->subsector)
{ {
sector_t *sector = spr->mobj->subsector->sector; sector_t *sector = spr->mobj->subsector->sector;
UINT8 lightlevel = 255; INT32 lightlevel = 255;
boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel);
extracolormap_t *colormap = NULL; extracolormap_t *colormap = NULL;
if (sector->numlights) if (sector->numlights)
@ -1333,22 +1334,22 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before
if (!R_ThingIsFullBright(spr->mobj)) if (!lightset)
lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel;
if (*sector->lightlist[light].extra_colormap) if (!R_ThingIsFullBright(spr->mobj) && *sector->lightlist[light].extra_colormap)
colormap = *sector->lightlist[light].extra_colormap; colormap = *sector->lightlist[light].extra_colormap;
} }
else else if (!lightset)
{ {
if (!R_ThingIsFullBright(spr->mobj)) lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel;
lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel;
if (sector->extra_colormap) if (sector->extra_colormap)
colormap = sector->extra_colormap; colormap = sector->extra_colormap;
} }
//lightlevel = 128 + (lightlevel>>1); if (R_ThingIsSemiBright(spr->mobj))
lightlevel = 128 + (lightlevel>>1);
HWR_Lighting(&Surf, lightlevel, colormap); HWR_Lighting(&Surf, lightlevel, colormap);
} }

View file

@ -861,7 +861,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome. else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome.
R_SetColumnFunc(COLDRAWFUNC_TRANS, false); R_SetColumnFunc(COLDRAWFUNC_TRANS, false);
if (vis->extra_colormap && !(vis->renderflags & RF_NOCOLORMAPS)) if (vis->extra_colormap && !(vis->cut & SC_FULLBRIGHT) && !(vis->renderflags & RF_NOCOLORMAPS))
{ {
if (!dc_colormap) if (!dc_colormap)
dc_colormap = vis->extra_colormap->colormap; dc_colormap = vis->extra_colormap->colormap;