Add gl_weapon_purelightlevel to make view weapon sprites/models match sector light levels purely

This commit is contained in:
nashmuhandes 2025-07-27 22:21:07 +08:00 committed by Rachael Alexanderson
commit 346f4c0e87
4 changed files with 11 additions and 8 deletions

View file

@ -211,7 +211,7 @@ private:
int SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &lightdata, const secplane_t *plane);
int CreateOtherPlaneVertices(subsector_t *sub, const secplane_t *plane);
void DrawPSprite(HUDSprite *huds, FRenderState &state);
WeaponLighting GetWeaponLighting(sector_t *viewsector, const DVector3 &pos, int cm, area_t in_area, const DVector3 &playerpos);
WeaponLighting GetWeaponLighting(sector_t *viewsector, const DVector3 &pos, int cm, area_t in_area, const DVector3 &playerpos, bool weaponPureLightLevel);
void PreparePlayerSprites2D(sector_t * viewsector, area_t in_area);
void PreparePlayerSprites3D(sector_t * viewsector, area_t in_area);
@ -352,7 +352,7 @@ inline bool isDarkLightMode(ELightMode lightmode)
return lightmode == ELightMode::Doom || lightmode == ELightMode::DoomDark;
}
int CalcLightLevel(ELightMode lightmode, int lightlevel, int rellight, bool weapon, int blendfactor);
int CalcLightLevel(ELightMode lightmode, int lightlevel, int rellight, bool weapon, int blendfactor, bool weaponPureLightLevel = false);
PalEntry CalcLightColor(ELightMode lightmode, int light, PalEntry pe, int blendfactor);
float GetFogDensity(FLevelLocals* Level, ELightMode lightmode, int lightlevel, PalEntry fogcolor, int sectorfogdensity, int blendfactor);
bool CheckFog(FLevelLocals* Level, sector_t* frontsector, sector_t* backsector, ELightMode lightmode);

View file

@ -76,7 +76,7 @@ CUSTOM_CVAR(Int, gl_distfog, 70, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
//
//==========================================================================
int CalcLightLevel(ELightMode lightmode, int lightlevel, int rellight, bool weapon, int blendfactor)
int CalcLightLevel(ELightMode lightmode, int lightlevel, int rellight, bool weapon, int blendfactor, bool weaponPureLightLevel)
{
int light;
@ -84,7 +84,7 @@ int CalcLightLevel(ELightMode lightmode, int lightlevel, int rellight, bool weap
bool darklightmode = (isDarkLightMode(lightmode)) || (isSoftwareLighting(lightmode) && blendfactor > 0);
if (darklightmode && lightlevel < 192 && !weapon)
if ((darklightmode && lightlevel < 192 && !weapon) || (weapon && weaponPureLightLevel))
{
if (lightlevel > 100)
{

View file

@ -55,6 +55,8 @@ EXTERN_CVAR(Bool, r_drawplayersprites)
EXTERN_CVAR(Bool, r_deathcamera)
CVARD(Bool, gl_weapon_purelightlevel, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE, "Makes the lighting on weapon sprites (or models) purely match the sector's light level you're standing in");
//==========================================================================
//
// R_DrawPSprite
@ -305,7 +307,7 @@ static FVector2 BobWeapon3D(WeaponPosition3D &weap, DPSprite *psp, FVector3 &tra
//
//==========================================================================
WeaponLighting HWDrawInfo::GetWeaponLighting(sector_t *viewsector, const DVector3 &pos, int cm, area_t in_area, const DVector3 &playerpos)
WeaponLighting HWDrawInfo::GetWeaponLighting(sector_t *viewsector, const DVector3 &pos, int cm, area_t in_area, const DVector3 &playerpos, bool weaponPureLightLevel = false)
{
WeaponLighting l;
@ -353,7 +355,7 @@ WeaponLighting HWDrawInfo::GetWeaponLighting(sector_t *viewsector, const DVector
if (Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) l.cm.ClearColor();
}
l.lightlevel = CalcLightLevel(lightmode, l.lightlevel, getExtraLight(), true, 0);
l.lightlevel = CalcLightLevel(lightmode, l.lightlevel, getExtraLight(), true, 0, weaponPureLightLevel);
if (isSoftwareLighting(lightmode) || l.lightlevel < 92)
{
@ -685,7 +687,7 @@ void HWDrawInfo::PreparePlayerSprites2D(sector_t * viewsector, area_t in_area)
AActor *camera = vp.camera;
WeaponPosition2D weap = GetWeaponPosition2D(camera->player, vp.TicFrac);
WeaponLighting light = GetWeaponLighting(viewsector, vp.Pos, isFullbrightScene(), in_area, camera->Pos());
WeaponLighting light = GetWeaponLighting(viewsector, vp.Pos, isFullbrightScene(), in_area, camera->Pos(), gl_weapon_purelightlevel);
VMFunction * ModifyBobLayer = nullptr;
DVector2 bobxy = DVector2(weap.bobx , weap.boby);
@ -765,7 +767,7 @@ void HWDrawInfo::PreparePlayerSprites3D(sector_t * viewsector, area_t in_area)
AActor *camera = vp.camera;
WeaponPosition3D weap = GetWeaponPosition3D(camera->player, vp.TicFrac);
WeaponLighting light = GetWeaponLighting(viewsector, vp.Pos, isFullbrightScene(), in_area, camera->Pos());
WeaponLighting light = GetWeaponLighting(viewsector, vp.Pos, isFullbrightScene(), in_area, camera->Pos(), gl_weapon_purelightlevel);
VMFunction * ModifyBobLayer3D = nullptr;
VMFunction * ModifyBobPivotLayer3D = nullptr;

View file

@ -2777,6 +2777,7 @@ OptionMenu "OpenGLOptions" protected
Option "$GLPREFMNU_FOGMODE", gl_fogmode, "FogMode"
Option "$GLPREFMNU_FOGFORCEFULLBRIGHT", gl_brightfog, "YesNo"
Slider "$GLPREFMNU_WPNLIGHTSTR", gl_weaponlight, 0,32, 2
Option "$GLPREFMNU_WPNPURELIGHT", gl_weapon_purelightlevel, "OnOff"
Option "$GLPREFMNU_ENVIRONMENTMAPMIRROR", gl_mirror_envmap, "OnOff"
Option "$GLPREFMNU_ENV", gl_enhanced_nightvision, "OnOff"
Option "$GLPREFMNU_ENVSTEALTH", gl_enhanced_nv_stealth, "EnhancedStealth"