From ff70bd0d83c4622404c0ea0a49c5ec8252ad5eab Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Jan 2022 03:42:27 -0800 Subject: [PATCH 1/5] Fix opengl semibright Adds back 3d models semibright. --- src/hardware/hw_main.c | 38 ++++++++++++++++++++++---------------- src/hardware/hw_main.h | 1 + src/hardware/hw_md2.c | 10 ++++++---- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 47ad59cb6..113b9588e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -181,6 +181,18 @@ boolean gl_shadersavailable = true; // 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) { RGBA_t poly_color, tint_color, fade_color; @@ -3795,7 +3807,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) patch_t *gpatch; FSurfaceInfo Surf; extracolormap_t *colormap = NULL; - FUINT lightlevel; + INT32 lightlevel; boolean lightset = true; FBITFIELD blend = 0; FBITFIELD occlusion; @@ -3931,12 +3943,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) i = 0; temp = FLOAT_TO_FIXED(realtop); - if (R_ThingIsFullBright(spr->mobj)) - lightlevel = 255; - else if (R_ThingIsFullDark(spr->mobj)) - lightlevel = 0; - else - lightset = false; + lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); for (i = 1; i < sector->numlights; i++) { @@ -3963,7 +3970,13 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { if (!lightset) + { lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; + + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); + } + if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) colormap = *list[i].extra_colormap; } @@ -4279,17 +4292,10 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // colormap test { sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 0; - boolean lightset = true; + INT32 lightlevel = 0; + boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); extracolormap_t *colormap = NULL; - if (R_ThingIsFullBright(spr->mobj)) - lightlevel = 255; - else if (R_ThingIsFullDark(spr->mobj)) - lightlevel = 0; - else - lightset = false; - if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) colormap = sector->extra_colormap; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 4ff46ba6a..33101edb2 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -67,6 +67,7 @@ void HWR_MakeScreenFinalTexture(void); void HWR_DrawScreenFinalTexture(int width, int height); // 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); UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index cf9d0b5c8..c2b593f06 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1324,7 +1324,8 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) if (spr->mobj->subsector) { sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; + INT32 lightlevel = 255; + boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); extracolormap_t *colormap = NULL; if (sector->numlights) @@ -1333,7 +1334,7 @@ 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 - if (!R_ThingIsFullBright(spr->mobj)) + if (!lightset) lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; if (*sector->lightlist[light].extra_colormap) @@ -1341,14 +1342,15 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) } else { - if (!R_ThingIsFullBright(spr->mobj)) + if (!lightset) lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; if (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); } From ecc3d031df33bfa7624d5b4308ae2c58437f15b5 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Jan 2022 03:45:40 -0800 Subject: [PATCH 2/5] Ignore colormap when overriding thing brightness --- src/hardware/hw_main.c | 36 ++++++++++++++++++++---------------- src/hardware/hw_md2.c | 14 +++++++++----- src/r_things.c | 2 +- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 113b9588e..b6a411e07 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3945,21 +3945,26 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); - for (i = 1; i < sector->numlights; i++) + if (!lightset) { - fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); - if (h <= temp) + for (i = 1; i < sector->numlights; i++) { - if (!lightset) + fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); + if (h <= temp) + { lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; - if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) - colormap = *list[i-1].extra_colormap; - break; + if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) + colormap = *list[i-1].extra_colormap; + break; + } } } if (R_ThingIsSemiBright(spr->mobj)) + { lightlevel = 128 + (lightlevel>>1); + colormap = NULL; + } for (i = 0; i < sector->numlights; i++) { @@ -3967,17 +3972,13 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) return; // even if we aren't changing colormap or lightlevel, we still need to continue drawing down the sprite - if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) + if (!lightset && !(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { - if (!lightset) - { - lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; + lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; - if (R_ThingIsSemiBright(spr->mobj)) - lightlevel = 128 + (lightlevel>>1); - } - - if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); + else if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) colormap = *list[i].extra_colormap; } @@ -4313,7 +4314,10 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; if (R_ThingIsSemiBright(spr->mobj)) + { lightlevel = 128 + (lightlevel>>1); + colormap = NULL; + } HWR_Lighting(&Surf, lightlevel, colormap); } diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index c2b593f06..7d54af5b9 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1335,22 +1335,26 @@ 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 if (!lightset) + { lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; - if (*sector->lightlist[light].extra_colormap) - colormap = *sector->lightlist[light].extra_colormap; + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; + } } - else + else if (!lightset) { - if (!lightset) - lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; + lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; if (sector->extra_colormap) colormap = sector->extra_colormap; } if (R_ThingIsSemiBright(spr->mobj)) + { lightlevel = 128 + (lightlevel>>1); + colormap = NULL; + } HWR_Lighting(&Surf, lightlevel, colormap); } diff --git a/src/r_things.c b/src/r_things.c index 4779e4df8..6ca07c3b3 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -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. R_SetColumnFunc(COLDRAWFUNC_TRANS, false); - if (vis->extra_colormap && !(vis->renderflags & RF_NOCOLORMAPS)) + if (!(vis->cut & (SC_FULLBRIGHT|SC_SEMIBRIGHT)) && vis->extra_colormap && !(vis->renderflags & RF_NOCOLORMAPS)) { if (!dc_colormap) dc_colormap = vis->extra_colormap->colormap; From 26d231c43acce0519c555865efdf73c524b0f8b8 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Jan 2022 05:09:39 -0800 Subject: [PATCH 3/5] Only ignore colormap for fullbright --- src/hardware/hw_main.c | 38 +++++++++++++++++--------------------- src/hardware/hw_md2.c | 9 ++------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b6a411e07..80fcbbfed 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3945,26 +3945,21 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); - if (!lightset) + for (i = 1; i < sector->numlights; i++) { - for (i = 1; i < sector->numlights; i++) + fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); + if (h <= temp) { - fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); - if (h <= temp) - { + if (!lightset) lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; - if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) - colormap = *list[i-1].extra_colormap; - break; - } + if (!R_ThingIsFullBright(spr->mobj) && !(spr->mobj->renderflags & RF_NOCOLORMAPS)) + colormap = *list[i-1].extra_colormap; + break; } } if (R_ThingIsSemiBright(spr->mobj)) - { lightlevel = 128 + (lightlevel>>1); - colormap = NULL; - } for (i = 0; i < sector->numlights; i++) { @@ -3972,13 +3967,17 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) return; // even if we aren't changing colormap or lightlevel, we still need to continue drawing down the sprite - if (!lightset && !(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) + if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { - lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; + if (!lightset) + { + lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; - if (R_ThingIsSemiBright(spr->mobj)) - lightlevel = 128 + (lightlevel>>1); - else 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; } @@ -4307,17 +4306,14 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!lightset) 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; } else if (!lightset) lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; if (R_ThingIsSemiBright(spr->mobj)) - { lightlevel = 128 + (lightlevel>>1); - colormap = NULL; - } HWR_Lighting(&Surf, lightlevel, colormap); } diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 7d54af5b9..38b151d91 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1335,12 +1335,10 @@ 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 if (!lightset) - { lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; - if (*sector->lightlist[light].extra_colormap) - colormap = *sector->lightlist[light].extra_colormap; - } + if (!R_ThingIsFullBright(spr->mobj) && *sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; } else if (!lightset) { @@ -1351,10 +1349,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) } if (R_ThingIsSemiBright(spr->mobj)) - { lightlevel = 128 + (lightlevel>>1); - colormap = NULL; - } HWR_Lighting(&Surf, lightlevel, colormap); } From df1e808b6ea0ceaa476c2e63d99e762969125a92 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 20 Jan 2022 19:14:44 +0000 Subject: [PATCH 4/5] Semibright has colormapping again --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 6ca07c3b3..95482bc38 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -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. R_SetColumnFunc(COLDRAWFUNC_TRANS, false); - if (!(vis->cut & (SC_FULLBRIGHT|SC_SEMIBRIGHT)) && vis->extra_colormap && !(vis->renderflags & RF_NOCOLORMAPS)) + if (vis->extra_colormap && !(vis->cut & SC_FULLBRIGHT) && !(vis->renderflags & RF_NOCOLORMAPS)) { if (!dc_colormap) dc_colormap = vis->extra_colormap->colormap; From f10aa9645bfcd506c8cb39f8f5185283c0c9bee9 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Jan 2022 23:39:58 -0800 Subject: [PATCH 5/5] Few more instances of fullbright colormap nullification --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 80fcbbfed..9aa525c79 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3937,7 +3937,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // Start with the lightlevel and colormap from the top of the sprite 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; i = 0; @@ -4296,7 +4296,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); extracolormap_t *colormap = NULL; - if (!(spr->mobj->renderflags & RF_NOCOLORMAPS)) + if (!R_ThingIsFullBright(spr->mobj) && !(spr->mobj->renderflags & RF_NOCOLORMAPS)) colormap = sector->extra_colormap; if (splat && sector->numlights)