diff --git a/src/playsim/actor.h b/src/playsim/actor.h index 026a3218ea..3b5bb3bfe6 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -427,6 +427,7 @@ enum ActorFlag8 MF8_SEEFRIENDLYMONSTERS = 0X08000000, // [inkoalawetrust] Hostile monster can see friendly monsters. MF8_CROSSLINECHECK = 0x10000000, // [MC]Enables CanCrossLine virtual MF8_MASTERNOSEE = 0x20000000, // Don't show object in first person if their master is the current camera. + MF8_ADDLIGHTLEVEL = 0x40000000, // [MC] Actor light level is additive with sector. }; // --- mobj.renderflags --- diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index a0190e6ed5..1affd4db0b 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -997,7 +997,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t // light calculation bool enhancedvision = false; - bool UseActorLight = (thing->LightLevel > -1); + const bool UseActorLight = (thing->LightLevel > -1); // allow disabling of the fullbright flag by a brightmap definition // (e.g. to do the gun flashes of Doom's zombies correctly. @@ -1006,12 +1006,22 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t if (fullbright) lightlevel = 255; else if (UseActorLight) - lightlevel = thing->LightLevel; + { + int newlevel = thing->LightLevel; + if (thing->flags8 & MF8_ADDLIGHTLEVEL) + { + newlevel += hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? + rendersector->GetCeilingLight() : rendersector->GetFloorLight()); + + newlevel = clamp(newlevel, 0, 255); + } + lightlevel = newlevel; + } else lightlevel = hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? rendersector->GetCeilingLight() : rendersector->GetFloorLight()); - foglevel = (uint8_t)clamp((UseActorLight) ? thing->LightLevel : rendersector->lightlevel, 0, 255); + foglevel = (uint8_t)clamp((UseActorLight) ? lightlevel : rendersector->lightlevel, 0, 255); lightlevel = rendersector->CheckSpriteGlow(lightlevel, thingpos); diff --git a/src/rendering/swrenderer/scene/r_opaque_pass.cpp b/src/rendering/swrenderer/scene/r_opaque_pass.cpp index 74c4727024..48cf6a3265 100644 --- a/src/rendering/swrenderer/scene/r_opaque_pass.cpp +++ b/src/rendering/swrenderer/scene/r_opaque_pass.cpp @@ -956,7 +956,15 @@ namespace swrenderer thingColormap = GetSpriteColorTable(thing->Sector->Colormap, thing->Sector->SpecialColors[sector_t::sprites], nc); } if (thing->LightLevel > -1) + { thinglightlevel = thing->LightLevel; + + if (thing->flags8 & MF8_ADDLIGHTLEVEL) + { + thinglightlevel += thing->Sector->GetTexture(sector_t::ceiling) == skyflatnum ? thing->Sector->GetCeilingLight() : thing->Sector->GetFloorLight(); + thinglightlevel = clamp(thinglightlevel, 0, 255); + } + } if ((sprite.renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) { RenderWallSprite::Project(Thread, thing, sprite.pos, sprite.tex, sprite.spriteScale, sprite.renderflags, thinglightlevel, foggy, thingColormap); diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 3f5a84e3b3..0f7abaac6a 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -342,6 +342,7 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(MF8, SEEFRIENDLYMONSTERS, AActor, flags8), DEFINE_FLAG(MF8, CROSSLINECHECK, AActor, flags8), DEFINE_FLAG(MF8, MASTERNOSEE, AActor, flags8), + DEFINE_FLAG(MF8, ADDLIGHTLEVEL, AActor, flags8), // Effect flags DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects),