From e676cd89eaa86e7c4daedca1b283a6a6bf28f467 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 17 Apr 2019 18:46:35 +0100 Subject: [PATCH 1/4] * Add FF_SEMIBRIGHT. * Ranges between full brightness to half-brightness (50% of fullbright effect). * Has both software and GL support (I think - GL needs to be doublechecked, but I think it's just GL being murky in general). * Used by Rings. * Backport FF_GLOBALANIM and FF_RANDOMANIM extensions to FF_ANIMATE from 2.2. * Rings use the former instead of their own hacky solution to the problem. * Also backport FF_VERTICALFLIP, because why not. * Inverts sprite relative to gravity. I remember wanting this for the flipped death sprite for Jawz, but then Oni drew his own frame for that, so it doesn't matter. * Refactor vissprite struct a tad, given I did so in internal where I pulled most of these improvements from. * Should be no in-game affect; let me know if you notice any regressions. --- src/dehacked.c | 6 ++++- src/g_game.c | 2 +- src/hardware/hw_main.c | 21 +++++++++++++---- src/info.c | 2 +- src/p_enemy.c | 12 ---------- src/p_mobj.c | 50 ++++++++++++++++++++++++++++++++-------- src/p_pspr.h | 28 ++++++++++++++++------- src/r_things.c | 52 +++++++++++++++++++++++------------------- src/r_things.h | 16 +++++++++---- 9 files changed, 124 insertions(+), 65 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 3c09fbbd3..85aad1f86 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8548,9 +8548,13 @@ struct { // Frame settings {"FF_FRAMEMASK",FF_FRAMEMASK}, - {"FF_PAPERSPRITE",FF_PAPERSPRITE}, {"FF_ANIMATE",FF_ANIMATE}, + {"FF_RANDOMANIM",FF_RANDOMANIM}, + {"FF_GLOBALANIM",FF_GLOBALANIM}, {"FF_FULLBRIGHT",FF_FULLBRIGHT}, + {"FF_SEMIBRIGHT",FF_SEMIBRIGHT}, + {"FF_PAPERSPRITE",FF_PAPERSPRITE}, + {"FF_VERTICALFLIP",FF_VERTICALFLIP}, {"FF_TRANSMASK",FF_TRANSMASK}, {"FF_TRANSSHIFT",FF_TRANSSHIFT}, // new preshifted translucency (used in source) diff --git a/src/g_game.c b/src/g_game.c index ef0896837..a49db0f62 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4832,7 +4832,7 @@ void G_WriteGhostTic(mobj_t *ghost) } // Store the sprite frame. - frame = ghost->frame & 0xFF; + frame = ghost->frame & FF_FRAMEMASK; if (frame != oldghost.frame) { oldghost.frame = frame; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4fcef218a..9c04adbdd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4233,6 +4233,9 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t colormap = sector->extra_colormap; } + if (spr->mobj->frame & FF_SEMIBRIGHT) + lightlevel = 128 + (lightlevel>>1); + if (colormap) sSurf.FlatColor.rgba = HWR_Lighting(lightlevel/2, colormap->rgba, colormap->fadergba, false, true); else @@ -4502,6 +4505,9 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[0].y = wallVerts[1].y = bot; #endif + if (spr->mobj->frame & FF_SEMIBRIGHT) + lightlevel = 128 + (lightlevel>>1); + if (colormap) Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false); else @@ -4680,7 +4686,11 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) extracolormap_t *colormap = sector->extra_colormap; if (!(spr->mobj->frame & FF_FULLBRIGHT)) + { lightlevel = sector->lightlevel; + if (spr->mobj->frame & FF_SEMIBRIGHT) + lightlevel = 128 + (lightlevel>>1); + } if (colormap) Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false); @@ -4788,6 +4798,9 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) colormap = sector->extra_colormap; } + if (spr->mobj->frame & FF_SEMIBRIGHT) + lightlevel = 128 + (lightlevel>>1); + if (colormap) Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false); else @@ -5417,6 +5430,7 @@ static void HWR_ProjectSprite(mobj_t *thing) size_t lumpoff; unsigned rot; UINT8 flip; + boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); angle_t ang; INT32 heightsec, phs; const boolean papersprite = (thing->frame & FF_PAPERSPRITE); @@ -5548,7 +5562,7 @@ static void HWR_ProjectSprite(mobj_t *thing) x1 = tr_x + x1 * rightcos; x2 = tr_x - x2 * rightcos; - if (thing->eflags & MFE_VERTICALFLIP) + if (vflip) { gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale; gzt = gz + FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale; @@ -5635,10 +5649,7 @@ static void HWR_ProjectSprite(mobj_t *thing) //CONS_Debug(DBG_RENDER, "------------------\nH: sprite : %d\nH: frame : %x\nH: type : %d\nH: sname : %s\n\n", // thing->sprite, thing->frame, thing->type, sprnames[thing->sprite]); - if (thing->eflags & MFE_VERTICALFLIP) - vis->vflip = true; - else - vis->vflip = false; + vis->vflip = vflip; vis->precip = false; } diff --git a/src/info.c b/src/info.c index 9d545eae0..92b392acc 100644 --- a/src/info.c +++ b/src/info.c @@ -969,7 +969,7 @@ state_t states[NUMSTATES] = {SPR_MSCF, FF_FULLBRIGHT|FF_TRANS30|11, 1, {NULL}, 0, 0, S_MSSHIELD_F1}, // S_MSSHIELD_F12 // Ring - {SPR_RING, FF_ANIMATE, -1, {NULL}, 23, 1, S_RING}, // S_RING + {SPR_RING, FF_SEMIBRIGHT|FF_ANIMATE|FF_GLOBALANIM, -1, {NULL}, 23, 1, S_RING}, // S_RING {SPR_RING, 0, 1, {NULL}, 0, 0, S_FASTRING2}, // S_FASTRING1 {SPR_RING, 2, 1, {NULL}, 0, 0, S_FASTRING3}, // S_FASTRING2 {SPR_RING, 4, 1, {NULL}, 0, 0, S_FASTRING4}, // S_FASTRING3 diff --git a/src/p_enemy.c b/src/p_enemy.c index 92bcd9aec..ffb89e9ab 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3607,12 +3607,6 @@ void A_AttractChase(mobj_t *actor) } else // Collecting { - // Flicker fullbright - if (leveltime & 1) - actor->frame |= FF_FULLBRIGHT; - else - actor->frame &= ~FF_FULLBRIGHT; - if (actor->extravalue1 >= 16) { if (actor->target->player->kartstuff[k_rings] >= 20) @@ -3647,12 +3641,6 @@ void A_AttractChase(mobj_t *actor) } else { - // Flicker fullbright - if (leveltime & 1) - actor->frame |= FF_FULLBRIGHT; - else - actor->frame &= ~FF_FULLBRIGHT; - // Don't immediately pick up spilled rings if (actor->threshold > 0) actor->threshold--; diff --git a/src/p_mobj.c b/src/p_mobj.c index 21f83b1c8..e62632533 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -85,6 +85,37 @@ void P_AddCachedAction(mobj_t *mobj, INT32 statenum) actioncachehead.prev = newaction; } +// +// P_SetupStateAnimation +// +FUNCINLINE static ATTRINLINE void P_SetupStateAnimation(mobj_t *mobj, state_t *st) +{ + if (!(st->frame & FF_ANIMATE)) + return; + + if (st->var1 <= 0 || st->var2 == 0) + { + mobj->frame &= ~FF_ANIMATE; + return; // Crash/stupidity prevention + } + + mobj->anim_duration = (UINT16)st->var2; + + if (st->frame & FF_GLOBALANIM) + { + // Attempt to account for the pre-ticker for objects spawned on load + if (!leveltime) return; + + mobj->anim_duration -= (leveltime + 2) % st->var2; // Duration synced to timer + mobj->frame += ((leveltime + 2) / st->var2) % (st->var1 + 1); // Frame synced to timer (duration taken into account) + } + else if (st->frame & FF_RANDOMANIM) + { + mobj->frame += P_RandomKey(st->var1 + 1); // Random starting frame + mobj->anim_duration -= P_RandomKey(st->var2); // Random duration for first frame + } +} + // // P_CycleStateAnimation // @@ -93,6 +124,7 @@ FUNCINLINE static ATTRINLINE void P_CycleStateAnimation(mobj_t *mobj) // var2 determines delay between animation frames if (!(mobj->frame & FF_ANIMATE) || --mobj->anim_duration != 0) return; + mobj->anim_duration = (UINT16)mobj->state->var2; // compare the current sprite frame to the one we started from @@ -212,7 +244,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation(mobj, st); // Modified handling. // Call action functions when the state is set @@ -280,7 +312,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation(mobj, st); // Modified handling. // Call action functions when the state is set @@ -334,7 +366,7 @@ boolean P_SetMobjStateNF(mobj_t *mobj, statenum_t state) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation(mobj, st); return true; } @@ -353,7 +385,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation((mobj_t*)mobj, st); return true; } @@ -3983,10 +4015,7 @@ static void P_RingThinker(mobj_t *mobj) return; } - if (mobj->state == &states[S_RING]) // sync map rings to a global timer - mobj->frame = (leveltime % ((UINT32)mobj->state->var1)) | (mobj->state->frame & ~FF_FRAMEMASK); - else - P_CycleMobjState(mobj); + P_CycleMobjState(mobj); } // @@ -9688,7 +9717,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation(mobj, st); mobj->friction = ORIG_FRICTION; @@ -10139,6 +10168,7 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. + P_SetupStateAnimation(mobj, st); mobj->friction = ORIG_FRICTION; @@ -10231,7 +10261,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation((mobj_t*)mobj, st); // set subsector and/or block links P_SetPrecipitationThingPosition(mobj); diff --git a/src/p_pspr.h b/src/p_pspr.h index e74266002..f5ecbeb92 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -35,14 +35,9 @@ #pragma interface #endif -/// \brief Frame flags: only the frame number -#define FF_FRAMEMASK 0x1ff -/// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION) -#define FF_PAPERSPRITE 0x800 -/// \brief Frame flags: Simple stateless animation -#define FF_ANIMATE 0x4000 -/// \brief Frame flags: frame always appears full bright -#define FF_FULLBRIGHT 0x8000 +/// \brief Frame flags: only the frame number (frames from 0 to 63, but a bit of headroom for 2.2 compat) +#define FF_FRAMEMASK 0xff + /// \brief Frame flags: 0 = no trans(opaque), 1-15 = transl. table #define FF_TRANSMASK 0xf0000 /// \brief shift for FF_TRANSMASK @@ -58,6 +53,23 @@ #define FF_TRANS80 (tr_trans80<colormap; - if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" + if (!(vis->cut & SC_PRECIP) && (vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { // translate certain pixels to white colfunc = transcolfunc; @@ -889,18 +889,18 @@ static void R_DrawVisSprite(vissprite_t *vis) frac = vis->startfrac; windowtop = windowbottom = sprbotscreen = INT32_MAX; - if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES) + if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES) this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale); if (this_scale <= 0) this_scale = 1; if (this_scale != FRACUNIT) { - if (!vis->isScaled) + if (!(vis->cut & SC_ISSCALED)) { vis->scale = FixedMul(vis->scale, this_scale); vis->scalestep = FixedMul(vis->scalestep, this_scale); vis->xiscale = FixedDiv(vis->xiscale,this_scale); - vis->isScaled = true; + vis->cut |= SC_ISSCALED; } dc_texturemid = FixedDiv(dc_texturemid,this_scale); } @@ -946,7 +946,7 @@ static void R_DrawVisSprite(vissprite_t *vis) #else column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); #endif - if (vis->vflip) + if (vis->cut & SC_VFLIP) R_DrawFlippedMaskedColumn(column, patch->height); else R_DrawMaskedColumn(column); @@ -1026,7 +1026,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) // // R_SplitSprite // runs through a sector's lightlist and -static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) +static void R_SplitSprite(vissprite_t *sprite) { INT32 i, lightnum, lindex; INT16 cutfrac; @@ -1062,6 +1062,8 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) // adjust the heights. newsprite = M_Memcpy(R_NewVisSprite(), sprite, sizeof (vissprite_t)); + newsprite->cut |= (sprite->cut & SC_FLAGMASK); + sprite->cut |= SC_BOTTOM; sprite->gz = testheight; @@ -1101,13 +1103,17 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) ; else */ - if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) + if (!((newsprite->cut & SC_FULLBRIGHT) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT); if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; + + if (newsprite->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >> 1); + newsprite->colormap = spritelights[lindex]; } } @@ -1135,6 +1141,7 @@ static void R_ProjectSprite(mobj_t *thing) size_t rot; UINT8 flip; + boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); INT32 lindex; @@ -1340,7 +1347,7 @@ static void R_ProjectSprite(mobj_t *thing) } //SoM: 3/17/2000: Disregard sprites that are out of view.. - if (thing->eflags & MFE_VERTICALFLIP) + if (vflip) { // When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned. // sprite height - sprite topoffset is the proper inverse of the vertical offset, of course. @@ -1482,7 +1489,12 @@ static void R_ProjectSprite(mobj_t *thing) else if (thing->frame & FF_TRANSMASK) vis->transmap = transtables + (thing->frame & FF_TRANSMASK) - 0x10000; - if (((thing->frame & FF_FULLBRIGHT) || (thing->flags2 & MF2_SHADOW)) + if (thing->frame & FF_FULLBRIGHT || thing->flags2 & MF2_SHADOW) + vis->cut |= SC_FULLBRIGHT; + else if (thing->frame & FF_SEMIBRIGHT) + vis->cut |= SC_SEMIBRIGHT; + + if (vis->cut & SC_FULLBRIGHT && (!vis->extra_colormap || !(vis->extra_colormap->fog & 1))) { // full bright: goggles @@ -1496,20 +1508,17 @@ static void R_ProjectSprite(mobj_t *thing) if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; + if (vis->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >> 1); + vis->colormap = spritelights[lindex]; } - vis->precip = false; - - if (thing->eflags & MFE_VERTICALFLIP) - vis->vflip = true; - else - vis->vflip = false; - - vis->isScaled = false; + if (vflip) + vis->cut |= SC_VFLIP; if (thing->subsector->sector->numlights) - R_SplitSprite(vis, thing); + R_SplitSprite(vis); // Debug ++objectsdrawn; @@ -1681,15 +1690,12 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->transmap = NULL; vis->mobjflags = 0; - vis->cut = SC_NONE; + vis->cut = SC_PRECIP; vis->extra_colormap = thing->subsector->sector->extra_colormap; vis->heightsec = thing->subsector->sector->heightsec; // Fullbright vis->colormap = colormaps; - vis->precip = true; - vis->vflip = false; - vis->isScaled = false; } // R_AddSprites @@ -2482,7 +2488,7 @@ void R_DrawMasked(void) next = r2->prev; // Tails 08-18-2002 - if (r2->sprite->precip == true) + if (r2->sprite->cut & SC_PRECIP) R_DrawPrecipitationSprite(r2->sprite); else R_DrawSprite(r2->sprite); diff --git a/src/r_things.h b/src/r_things.h index 6f48cc5bf..f3024f92c 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -102,9 +102,20 @@ typedef struct // ----------- typedef enum { + // actual cuts SC_NONE = 0, SC_TOP = 1, - SC_BOTTOM = 2 + SC_BOTTOM = 1<<1, + // other flags + SC_PRECIP = 1<<2, + //SC_LINKDRAW = 1<<3, -- 2.2 compat + SC_FULLBRIGHT = 1<<4, + SC_SEMIBRIGHT = 1<<5, + SC_VFLIP = 1<<6, + SC_ISSCALED = 1>>7, + // masks + SC_CUTMASK = SC_TOP|SC_BOTTOM, + SC_FLAGMASK = ~SC_CUTMASK } spritecut_e; // A vissprite_t is a thing that will be drawn during a refresh, @@ -153,9 +164,6 @@ typedef struct vissprite_s INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH]; - boolean precip; - boolean vflip; // Flip vertically - boolean isScaled; INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing } vissprite_t; From 0b667406fb717aba6666b72fcafb8febf04c927f Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 18 Apr 2019 14:01:53 +0100 Subject: [PATCH 2/4] Swap FF_GLOBALANIM and FF_RANDOMANIM's values to reflect priority of behaviour. --- src/p_pspr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_pspr.h b/src/p_pspr.h index f5ecbeb92..b42692462 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -65,10 +65,10 @@ /// \brief Frame flags - Animate: Simple stateless animation #define FF_ANIMATE 0x01000000 -/// \brief Frame flags - Animate: Start at a random place in the animation (mutually exclusive with below) -#define FF_RANDOMANIM 0x02000000 -/// \brief Frame flags - Animate: Sync animation to global timer (mutually exclusive with above) -#define FF_GLOBALANIM 0x04000000 +/// \brief Frame flags - Animate: Sync animation to global timer (mutually exclusive with below, currently takes priority) +#define FF_GLOBALANIM 0x02000000 +/// \brief Frame flags - Animate: Start at a random place in the animation (mutually exclusive with above) +#define FF_RANDOMANIM 0x04000000 /** \brief translucency tables From f26909718025cef800d68104fba8465a6868ae87 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 19 Apr 2019 17:46:42 +0100 Subject: [PATCH 3/4] Don't adjust lightlevel EVERY splitsprite loop, only the ones where lightlevel is modified. --- src/hardware/hw_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9c04adbdd..499fd0cb4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4220,7 +4220,11 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t INT32 light = R_GetPlaneLight(sector, spr->mobj->floorz, false); if (!(spr->mobj->frame & FF_FULLBRIGHT)) + { lightlevel = *sector->lightlist[light].lightlevel; + if (spr->mobj->frame & FF_SEMIBRIGHT) + lightlevel = 128 + (lightlevel>>1); + } if (sector->lightlist[light].extra_colormap) colormap = sector->lightlist[light].extra_colormap; @@ -4233,9 +4237,6 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t colormap = sector->extra_colormap; } - if (spr->mobj->frame & FF_SEMIBRIGHT) - lightlevel = 128 + (lightlevel>>1); - if (colormap) sSurf.FlatColor.rgba = HWR_Lighting(lightlevel/2, colormap->rgba, colormap->fadergba, false, true); else @@ -4436,7 +4437,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) + { lightlevel = *list[i].lightlevel; + if (spr->mobj->frame & FF_SEMIBRIGHT) + lightlevel = 128 + (lightlevel>>1); + } colormap = list[i].extra_colormap; } @@ -4505,9 +4510,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[0].y = wallVerts[1].y = bot; #endif - if (spr->mobj->frame & FF_SEMIBRIGHT) - lightlevel = 128 + (lightlevel>>1); - if (colormap) Surf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false); else From 0e3b95873ff1677f22ec2b04a141a5f789fcfecd Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 19 Apr 2019 17:55:36 +0100 Subject: [PATCH 4/4] Missed a spot. Turns out this probably needed a minor refactoring, too. --- src/hardware/hw_main.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 499fd0cb4..ed5b73d2a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4396,16 +4396,20 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) alpha = Surf.FlatColor.s.alpha; - // Start with the lightlevel and colormap from the top of the sprite - lightlevel = *list[sector->numlights - 1].lightlevel; - colormap = list[sector->numlights - 1].extra_colormap; - i = 0; temp = FLOAT_TO_FIXED(realtop); - if (spr->mobj->frame & FF_FULLBRIGHT) - lightlevel = 255; - #ifdef ESLOPE + // Start with the lightlevel and colormap from the top of the sprite + lightlevel = 255; + colormap = list[sector->numlights - 1].extra_colormap; + + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + { + lightlevel = *list[sector->numlights - 1].lightlevel; + if (spr->mobj->frame & FF_SEMIBRIGHT) + lightlevel = 128 + (lightlevel>>1); + } + for (i = 1; i < sector->numlights; i++) { fixed_t h = sector->lightlist[i].slope ? P_GetZAt(sector->lightlist[i].slope, spr->mobj->x, spr->mobj->y) @@ -4413,7 +4417,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (h <= temp) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) + { lightlevel = *list[i-1].lightlevel; + if (spr->mobj->frame & FF_SEMIBRIGHT) + lightlevel = 128 + (lightlevel>>1); + } colormap = list[i-1].extra_colormap; break; } @@ -4421,7 +4429,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) #else i = R_GetPlaneLight(sector, temp, false); if (!(spr->mobj->frame & FF_FULLBRIGHT)) + { lightlevel = *list[i].lightlevel; + if (spr->mobj->frame & FF_SEMIBRIGHT) + lightlevel = 128 + (lightlevel>>1); + } colormap = list[i].extra_colormap; #endif