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); }