From b6d7de7d271dc6faeee3d2d9d968f32447eeb3ef Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 12 Dec 2017 05:14:06 +0000 Subject: [PATCH] Add def "globalflags" bit 4, and for individual palettes the "tint" flag bit 512. This makes fog the same for all shades. Make fog behave normally with sector structure .fogpal. Patch from Fox. git-svn-id: https://svn.eduke32.com/eduke32@6559 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/build.h | 1 + source/build/include/hightile.h | 1 + source/build/include/polymost.h | 7 +++---- source/build/src/polymer.cpp | 10 +++++----- source/build/src/polymost.cpp | 12 ++++++------ 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 09fddb524..565535596 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -864,6 +864,7 @@ EXTERN char *globalpalwritten; enum { GLOBAL_NO_GL_TILESHADES = 1<<0, GLOBAL_NO_GL_FULLBRIGHT = 1<<1, + GLOBAL_NO_GL_FOGSHADE = 1<<2, }; extern int32_t globalflags; diff --git a/source/build/include/hightile.h b/source/build/include/hightile.h index 2c0846404..71d1fb334 100644 --- a/source/build/include/hightile.h +++ b/source/build/include/hightile.h @@ -110,6 +110,7 @@ enum HICTINT_BLENDMASK = 64|128, HICTINT_ALWAYSUSEART = 256, + HICTINT_NOFOGSHADE = 512, HICTINT_PRECOMPUTED = HICTINT_COLORIZE | HICTINT_BLENDMASK, HICTINT_IN_MEMORY = HICTINT_PRECOMPUTED | HICTINT_GRAYSCALE | HICTINT_INVERT, diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index 1d6eb897f..9e03cd2fd 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -102,11 +102,10 @@ static FORCE_INLINE int32_t get_ceiling_fogpal(usectortype const * const sec) { return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->ceilingpal); } -static FORCE_INLINE int32_t fogpal_shade(usectortype const * const sec, int32_t const shade) +static FORCE_INLINE int32_t fogshade(int32_t const shade, int32_t const pal) { - // When fogging is due to sector[].fogpal, don't make the fog parameters - // depend on the shade of the object. - return sec->fogpal ? 0 : shade; + polytintflags_t const tintflags = hictinting[pal].f; + return (globalflags & GLOBAL_NO_GL_FOGSHADE || tintflags & HICTINT_NOFOGSHADE) ? 0 : shade; } static FORCE_INLINE int check_nonpow2(int32_t const x) diff --git a/source/build/src/polymer.cpp b/source/build/src/polymer.cpp index 356208bcc..ca106add2 100644 --- a/source/build/src/polymer.cpp +++ b/source/build/src/polymer.cpp @@ -1478,7 +1478,7 @@ void polymer_drawmaskwall(int32_t damaskwallcnt) if (searchit == 2) { polymer_drawsearchplane(&w->mask, oldcolor, 0x04, (GLubyte *)&maskwall[damaskwallcnt]); } else { - calc_and_apply_fog(wal->picnum, fogpal_shade(sec, wal->shade), sec->visibility, get_floor_fogpal(sec)); + calc_and_apply_fog(wal->picnum, fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec)); polymer_drawplane(&w->mask); } @@ -1507,7 +1507,7 @@ void polymer_drawsprite(int32_t snum) DO_TILE_ANIM(tspr->picnum, tspr->owner+32768); sec = (usectortype *)§or[tspr->sectnum]; - calc_and_apply_fog(tspr->picnum, fogpal_shade(sec, tspr->shade), sec->visibility, + calc_and_apply_fog(tspr->picnum, fogshade(tspr->shade, tspr->pal), sec->visibility, get_floor_fogpal((usectortype *)§or[tspr->sectnum])); if (usemodels && tile2model[Ptile2tile(tspr->picnum,tspr->pal)].modelid >= 0 && @@ -3009,7 +3009,7 @@ static void polymer_drawsector(int16_t sectnum, int32_t domasks) polymer_drawsearchplane(&s->floor, oldcolor, 0x02, (GLubyte *) §num); } else { - calc_and_apply_fog(sec->floorpicnum, fogpal_shade(sec, sec->floorshade), + calc_and_apply_fog(sec->floorpicnum, fogshade(sec->floorshade, sec->floorpal), sec->visibility, get_floor_fogpal(sec)); polymer_drawplane(&s->floor); } @@ -3037,7 +3037,7 @@ static void polymer_drawsector(int16_t sectnum, int32_t domasks) polymer_drawsearchplane(&s->ceil, oldcolor, 0x01, (GLubyte *) §num); } else { - calc_and_apply_fog(sec->ceilingpicnum, fogpal_shade(sec, sec->ceilingshade), + calc_and_apply_fog(sec->ceilingpicnum, fogshade(sec->ceilingshade, sec->ceilingpal), sec->visibility, get_ceiling_fogpal(sec)); polymer_drawplane(&s->ceil); } @@ -3571,7 +3571,7 @@ static void polymer_drawwall(int16_t sectnum, int16_t wallnum) (sector[wal->nextsector].ceilingstat & 1)) parallaxedceiling = 1; - calc_and_apply_fog(wal->picnum, fogpal_shade(sec, wal->shade), sec->visibility, get_floor_fogpal(sec)); + calc_and_apply_fog(wal->picnum, fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec)); if ((w->underover & 1) && (!parallaxedfloor || (searchit == 2))) { diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index f0ac48d16..059547d59 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -2809,7 +2809,7 @@ static void polymost_internal_nonparallaxed(vec2f_t n0, vec2f_t n1, float ryp0, drawpoly_alpha = 0.f; drawpoly_blend = 0; - calc_and_apply_fog(globalpicnum, fogpal_shade(sec, global_cf_shade), sec->visibility, + calc_and_apply_fog(globalpicnum, fogshade(global_cf_shade, global_cf_pal), sec->visibility, POLYMOST_CHOOSE_FOG_PAL(global_cf_fogpal, global_cf_pal)); if (have_floor) @@ -3689,7 +3689,7 @@ static void polymost_drawalls(int32_t const bunch) } if (wal->cstat&256) { xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; } //yflip - calc_and_apply_fog(wal->picnum, fogpal_shade(sec, wal->shade), sec->visibility, get_floor_fogpal(sec)); + calc_and_apply_fog(wal->picnum, fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec)); pow2xsplit = 1; polymost_domost(x1,ocy1,x0,ocy0); if (wal->cstat&8) { xtex.u = ogux; ytex.u = oguy; otex.u = oguo; } @@ -3726,7 +3726,7 @@ static void polymost_drawalls(int32_t const bunch) } if (nwal->cstat&256) { xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; } //yflip - calc_and_apply_fog(nwal->picnum, fogpal_shade(sec, nwal->shade), sec->visibility, get_floor_fogpal(sec)); + calc_and_apply_fog(nwal->picnum, fogshade(nwal->shade, nwal->pal), sec->visibility, get_floor_fogpal(sec)); pow2xsplit = 1; polymost_domost(x0,ofy0,x1,ofy1); if (wal->cstat&(2+8)) { otex.u = oguo; xtex.u = ogux; ytex.u = oguy; } @@ -3774,7 +3774,7 @@ static void polymost_drawalls(int32_t const bunch) } if (wal->cstat&256) { xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; } //yflip - calc_and_apply_fog(wal->picnum, fogpal_shade(sec, wal->shade), sec->visibility, get_floor_fogpal(sec)); + calc_and_apply_fog(wal->picnum, fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec)); pow2xsplit = 1; polymost_domost(x0, cy0, x1, cy1); } while (0); } @@ -4296,7 +4296,7 @@ void polymost_drawmaskwall(int32_t damaskwallcnt) drawpoly_alpha = 0.f; drawpoly_blend = blend; - calc_and_apply_fog(wal->picnum, fogpal_shade(sec, wal->shade), sec->visibility, get_floor_fogpal(sec)); + calc_and_apply_fog(wal->picnum, fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec)); float const csy[4] = { ((float)(cz[0] - globalposz)) * ryp0 + ghoriz, ((float)(cz[1] - globalposz)) * ryp0 + ghoriz, @@ -4517,7 +4517,7 @@ void polymost_drawsprite(int32_t snum) sec = (usectortype *)§or[tspr->sectnum]; - calc_and_apply_fog(tspr->picnum, fogpal_shade(sec, globalshade), sec->visibility, get_floor_fogpal(sec)); + calc_and_apply_fog(tspr->picnum, fogshade(globalshade, globalpal), sec->visibility, get_floor_fogpal(sec)); while (!(spriteext[spritenum].flags & SPREXT_NOTMD)) {