diff --git a/src/console/c_cmds.cpp b/src/console/c_cmds.cpp index 33f107d1a..7597b7158 100644 --- a/src/console/c_cmds.cpp +++ b/src/console/c_cmds.cpp @@ -941,8 +941,8 @@ CCMD(currentpos) AActor *mo = players[consoleplayer].mo; if(mo) { - Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n", - mo->X(), mo->Y(), mo->Z(), mo->Angles.Yaw.Normalized360().Degrees, mo->floorz, mo->Sector->sectornum, mo->Sector->lightlevel); + Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, sector lightlevel: %d, actor lightlevel\n", + mo->X(), mo->Y(), mo->Z(), mo->Angles.Yaw.Normalized360().Degrees, mo->floorz, mo->Sector->sectornum, mo->Sector->lightlevel, mo->LightLevel); } else { diff --git a/src/playsim/actor.h b/src/playsim/actor.h index 3a39a5d03..026a3218e 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -1112,6 +1112,7 @@ public: int16_t movecount; // when 0, select a new dir int16_t strafecount; // for MF3_AVOIDMELEE + int16_t LightLevel; // Allows for overriding sector light levels. uint16_t SpawnAngle; TObjPtr target; // thing being chased/attacked (or NULL) diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index afc8c7ed4..7b67017dc 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -371,6 +371,7 @@ void AActor::Serialize(FSerializer &arc) A("friction", Friction) A("SpriteOffset", SpriteOffset) ("viewpos", ViewPos) + A("lightlevel", LightLevel) A("userlights", UserLights) A("WorldOffset", WorldOffset); diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index 994922c27..9d0720b3e 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -101,6 +101,8 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent) int rel = fullbright ? 0 : getExtraLight(); auto &vp = di->Viewpoint; + const bool UseActorLight = (actor && actor->LightLevel > -1); + if (translucent) { // The translucent pass requires special setup for the various modes. @@ -240,7 +242,6 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent) // set up the light slice secplane_t *topplane = i == 0 ? &topp : &(*lightlist)[i].plane; secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottomp : &(*lightlist)[i + 1].plane; - int thislight = (*lightlist)[i].caster != nullptr ? hw_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; int thisll = actor == nullptr ? thislight : (uint8_t)actor->Sector->CheckSpriteGlow(thislight, actor->InterpolatedPosition(vp.TicFrac)); @@ -1002,9 +1003,13 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t fullbright = (thing->flags5 & MF5_BRIGHT) || ((thing->renderflags & RF_FULLBRIGHT) && (!texture || !texture->isFullbrightDisabled())); - lightlevel = fullbright ? 255 : - hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? + if (fullbright) lightlevel = 255; + else if (thing->LightLevel > -1) + lightlevel = thing->LightLevel; + else + lightlevel = hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? rendersector->GetCeilingLight() : rendersector->GetFloorLight()); + foglevel = (uint8_t)clamp(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 02598f72a..74c472702 100644 --- a/src/rendering/swrenderer/scene/r_opaque_pass.cpp +++ b/src/rendering/swrenderer/scene/r_opaque_pass.cpp @@ -955,7 +955,8 @@ namespace swrenderer auto nc = !!(thing->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING); thingColormap = GetSpriteColorTable(thing->Sector->Colormap, thing->Sector->SpecialColors[sector_t::sprites], nc); } - + if (thing->LightLevel > -1) + thinglightlevel = thing->LightLevel; 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/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 13a516184..34223ff49 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -2026,6 +2026,7 @@ DEFINE_FIELD(AActor, ViewPos) DEFINE_FIELD_NAMED(AActor, ViewAngles.Yaw, viewangle) DEFINE_FIELD_NAMED(AActor, ViewAngles.Pitch, viewpitch) DEFINE_FIELD_NAMED(AActor, ViewAngles.Roll, viewroll) +DEFINE_FIELD(AActor, LightLevel) DEFINE_FIELD_X(FCheckPosition, FCheckPosition, thing); DEFINE_FIELD_X(FCheckPosition, FCheckPosition, pos); diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 0d277ae4f..63f0a3f12 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -255,6 +255,7 @@ class Actor : Thinker native native int RenderHidden; native int RenderRequired; native int FriendlySeeBlocks; + native int16 lightlevel; native readonly int SpawnTime; private native int InventoryID; // internal counter. @@ -356,6 +357,7 @@ class Actor : Thinker native property RenderRequired: RenderRequired; property FriendlySeeBlocks: FriendlySeeBlocks; property ThruBits: ThruBits; + property LightLevel: LightLevel; // need some definition work first //FRenderStyle RenderStyle; @@ -380,6 +382,7 @@ class Actor : Thinker native Default { + LightLevel -1; Scale 1; Health DEFAULT_HEALTH; Reactiontime 8;