From 32c3b7761a186d2a74dcbcf415e20345d89b985a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Dec 2024 17:13:28 +0100 Subject: [PATCH] fix papersprite lightlevels again kek + remove shit that does nothing --- src/hardware/hw_main.c | 69 +++++++++++++++++++++--------------------- src/p_mobj.h | 3 -- src/r_things.c | 9 +----- src/r_things.h | 1 - 4 files changed, 35 insertions(+), 47 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 58d1436fc..289e331b3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -341,44 +341,43 @@ boolean HWR_PalRenderFlashpal(void) void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite) { - *lightlevel += R_ThingLightLevel(spr->mobj); + (void)papersprite; - if (maplighting.directional == true && P_SectorUsesDirectionalLighting(sector)) + if (maplighting.directional == false || !P_SectorUsesDirectionalLighting(sector) || model == true) + return; + + fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); + + // this seems to be wrong??? + /*fixed_t extralight = R_GetSpriteDirectionalLighting( + papersprite + ? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90) + : R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme + );*/ + + // Less change in contrast in dark sectors + extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); + + // NO NO BAD! WHY!? + /*if (papersprite) { - if (model == false) // this is implemented by shader - { - fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); - - // this seems to be wrong??? - /*fixed_t extralight = R_GetSpriteDirectionalLighting( - papersprite - ? R_PointToAngle(spr->mobj->x, spr->mobj->y) + (spr->flip ? -ANGLE_90 : ANGLE_90) - : R_PointToAngle(spr->mobj->x, spr->mobj->y) // fixme - );*/ - - // Less change in contrast in dark sectors - extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); - - if (papersprite) - { - // Papersprite contrast should match walls - *lightlevel += FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; - } - else - { - // simple OGL approximation - fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); - fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); - - // Less change in contrast at further distances, to counteract DOOM diminished light - fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); - extralight = FixedMul(extralight, min(n, FRACUNIT)); - - // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance - *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; - } - } + // Papersprite contrast should match walls + *lightlevel += FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; } + else*/ + { + // simple OGL approximation + fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); + fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); + + // Less change in contrast at further distances, to counteract DOOM diminished light + fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); + extralight = FixedMul(extralight, min(n, FRACUNIT)); + + // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance + *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; + } + } void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap, const boolean directional) diff --git a/src/p_mobj.h b/src/p_mobj.h index 23d19136c..8c1b23387 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -295,7 +295,6 @@ typedef struct mobj_s fixed_t old_spritexscale2, old_spriteyscale2; fixed_t old_spritexoffset, old_spriteyoffset; fixed_t old_spritexoffset2, old_spriteyoffset2; - INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch @@ -449,8 +448,6 @@ typedef struct precipmobj_s fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexscale2, old_spriteyscale2; fixed_t old_spritexoffset, old_spriteyoffset; - fixed_t old_spritexoffset2, old_spriteyoffset2; - INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch diff --git a/src/r_things.c b/src/r_things.c index 7af2f122b..53b58cdaf 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -109,13 +109,6 @@ static drawseg_xrange_item_t *drawsegs_xrange; static size_t drawsegs_xrange_size = 0; static INT32 drawsegs_xrange_count = 0; -INT32 R_ThingLightLevel(mobj_t* thing) -{ - INT32 lightlevel = thing->lightlevel; - - return lightlevel; -} - // ========================================================================== // // Sprite loading routines: support sprites in pwad, dehacked sprite renaming, @@ -1621,7 +1614,7 @@ static void R_ProjectSprite(mobj_t *thing) lightnum = thing->subsector->sector->lightlevel; } - lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT; + lightnum = (lightnum) >> LIGHTSEGSHIFT; if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector)) { diff --git a/src/r_things.h b/src/r_things.h index 1af5d99bd..78221d794 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -57,7 +57,6 @@ extern fixed_t windowtop; extern fixed_t windowbottom; extern INT32 lengthcol; -INT32 R_ThingLightLevel(mobj_t *thing); fixed_t R_GetSpriteDirectionalLighting(angle_t angle); fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope);