From c76431414a967731c5f951efc9f2cfbe52c49304 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Fri, 21 Oct 2016 06:54:45 -0400 Subject: [PATCH 1/3] - Implemented r_fullbrightignoresectorcolor from QZDoom --- src/r_bsp.cpp | 5 +++-- src/r_data/colormaps.cpp | 4 ++++ src/r_data/colormaps.h | 1 + src/r_main.cpp | 7 +++++++ src/r_segs.cpp | 11 ++++++----- src/r_things.cpp | 21 ++++++++++++++------- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 1 + 8 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 934d2d3e5..8d423b3b3 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -105,6 +105,7 @@ TArray WallPortals(1000); // note: this array needs to go away as subsector_t *InSubsector; CVAR (Bool, r_drawflat, false, 0) // [RH] Don't texture segs? +EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); void R_StoreWallRange (int start, int stop); @@ -1108,7 +1109,7 @@ void R_Subsector (subsector_t *sub) } else { - basecolormap = frontsector->ColorMap; + basecolormap = (r_fullbrightignoresectorcolor && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap; } portal = frontsector->ValidatePortal(sector_t::ceiling); @@ -1142,7 +1143,7 @@ void R_Subsector (subsector_t *sub) } else { - basecolormap = frontsector->ColorMap; + basecolormap = (r_fullbrightignoresectorcolor && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap; } // killough 3/7/98: Add (x,y) offsets to flats, add deep water check diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index b46342463..73265b20e 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -59,6 +59,7 @@ static bool R_CheckForFixedLights(const BYTE *colormaps); extern "C" { FDynamicColormap NormalLight; +FDynamicColormap FullNormalLight; //[SP] Emulate GZDoom brightness } bool NormalLightHasFixedLights; @@ -551,6 +552,9 @@ void R_InitColormaps () NormalLight.Color = PalEntry (255, 255, 255); NormalLight.Fade = 0; NormalLight.Maps = realcolormaps; + FullNormalLight.Color = PalEntry (255, 255, 255); + FullNormalLight.Fade = 0; + FullNormalLight.Maps = realcolormaps; NormalLightHasFixedLights = R_CheckForFixedLights(realcolormaps); numfakecmaps = fakecmaps.Size(); diff --git a/src/r_data/colormaps.h b/src/r_data/colormaps.h index 0764191a3..09006fc1e 100644 --- a/src/r_data/colormaps.h +++ b/src/r_data/colormaps.h @@ -80,6 +80,7 @@ extern BYTE DesaturateColormap[31][256]; extern "C" { extern FDynamicColormap NormalLight; +extern FDynamicColormap FullNormalLight; } extern bool NormalLightHasFixedLights; diff --git a/src/r_main.cpp b/src/r_main.cpp index 1e0de7ecc..6f0ebcb3c 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -455,6 +455,8 @@ void R_CopyStackedViewParameters() // //========================================================================== +EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) + void R_SetupColormap(player_t *player) { realfixedcolormap = NULL; @@ -481,6 +483,11 @@ void R_SetupColormap(player_t *player) else if (player->fixedlightlevel >= 0 && player->fixedlightlevel < NUMCOLORMAPS) { fixedlightlev = player->fixedlightlevel * 256; + // [SP] Emulate GZDoom's light-amp goggles. + if (r_fullbrightignoresectorcolor && fixedlightlev >= 0) + { + fixedcolormap = &FullNormalLight; + } } } // [RH] Inverse light for shooting the Sigil diff --git a/src/r_segs.cpp b/src/r_segs.cpp index edb1949b6..d265d626f 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -57,6 +57,7 @@ CVAR(Bool, r_np2, true, 0) +EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); //CVAR (Int, ty, 8, 0) //CVAR (Int, tx, 8, 0) @@ -313,7 +314,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - dc_colormap = basecolormap->Maps + fixedlightlev; + dc_colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; @@ -630,7 +631,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - dc_colormap = basecolormap->Maps + fixedlightlev; + dc_colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; @@ -1788,7 +1789,7 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - dc_colormap = basecolormap->Maps + fixedlightlev; + dc_colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; @@ -3187,11 +3188,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - WallC.sx1) * rw_lightstep; if (fixedlightlev >= 0) - dc_colormap = usecolormap->Maps + fixedlightlev; + dc_colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (usecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - dc_colormap = usecolormap->Maps; + dc_colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : usecolormap->Maps; else calclighting = true; diff --git a/src/r_things.cpp b/src/r_things.cpp index 99ca68b60..047ee9295 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -99,6 +99,7 @@ EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Int, r_drawfuzz) EXTERN_CVAR(Bool, r_deathcamera); +CVAR(Bool, r_fullbrightignoresectorcolor, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); // // Sprite rotation 0 is facing the viewer, @@ -548,7 +549,7 @@ void R_DrawWallSprite(vissprite_t *spr) else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - dc_colormap = usecolormap->Maps; + dc_colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : usecolormap->Maps; else calclighting = true; @@ -1066,7 +1067,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->deltax = float(pos.X - ViewPos.X); vis->deltay = float(pos.Y - ViewPos.Y); vis->renderflags = renderflags; - if(thing->flags5 & MF5_BRIGHT) vis->renderflags |= RF_FULLBRIGHT; // kg3D + if(thing->flags5 & MF5_BRIGHT) + vis->renderflags |= RF_FULLBRIGHT; // kg3D vis->Style.RenderStyle = thing->RenderStyle; vis->FillColor = thing->fillcolor; vis->Translation = thing->Translation; // [RH] thing translation table @@ -1140,7 +1142,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } else if (!foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) { // full bright - vis->Style.colormap = mybasecolormap->Maps; + vis->Style.colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : mybasecolormap->Maps; } else { // diminished light @@ -1462,11 +1464,11 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double } if (fixedlightlev >= 0) { - vis->Style.colormap = mybasecolormap->Maps + fixedlightlev; + vis->Style.colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (mybasecolormap->Maps + fixedlightlev); } else if (!foggy && pspr->GetState()->GetFullbright()) { // full bright - vis->Style.colormap = mybasecolormap->Maps; // [RH] use basecolormap + vis->Style.colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : mybasecolormap->Maps; // [RH] use basecolormap } else { // local light @@ -1516,6 +1518,11 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double { noaccel = true; } + // [SP] If emulating GZDoom fullbright, disable acceleration + if (r_fullbrightignoresectorcolor && fixedlightlev >= 0) + mybasecolormap = &FullNormalLight; + if (r_fullbrightignoresectorcolor && !foggy && pspr->GetState()->GetFullbright()) + mybasecolormap = &FullNormalLight; colormap_to_use = mybasecolormap; } else @@ -2057,7 +2064,7 @@ void R_DrawSprite (vissprite_t *spr) } else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) { // full bright - spr->Style.colormap = mybasecolormap->Maps; + spr->Style.colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : mybasecolormap->Maps; } else { // diminished light @@ -2615,7 +2622,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, } else if (particle->bright) { - vis->Style.colormap = map; + vis->Style.colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : map; } else { diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 096d0832c..18ff6ce04 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1787,6 +1787,7 @@ DSPLYMNU_PICKUPFADE = "Pickup Flash Intensity"; DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used DSPLYMNU_ATTACHEDSURFACES = "Use attached surfaces"; // Not used DSPLYMNU_SKYMODE = "Sky render mode"; +DSPLYMNU_GZDFULLBRIGHT = "Emulate GZDoom FullBright"; DSPLYMNU_DRAWFUZZ = "Use fuzz effect"; DSPLYMNU_TRANSSOUL = "Lost Soul translucency"; DSPLYMNU_FAKECONTRAST = "Use fake contrast"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 7b06a7e7f..765fe6674 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -682,6 +682,7 @@ OptionMenu "VideoOptions" } Option "$DSPLYMNU_SKYMODE", "r_skymode", "SkyModes" + Option "$DSPLYMNU_GZDFULLBRIGHT", "r_fullbrightignoresectorcolor", "OnOff" Option "$DSPLYMNU_DRAWFUZZ", "r_drawfuzz", "Fuzziness" Slider "$DSPLYMNU_TRANSSOUL", "transsouls", 0.25, 1.0, 0.05, 2 Option "$DSPLYMNU_FAKECONTRAST", "r_fakecontrast", "Contrast" From df6214b142cb61dda7604da4c3bf97543248d1af Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Fri, 21 Oct 2016 07:21:56 -0400 Subject: [PATCH 2/3] - Fixes --- src/r_main.cpp | 2 +- src/r_segs.cpp | 10 +++++----- src/r_things.cpp | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index 6f0ebcb3c..4252f4155 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -486,7 +486,7 @@ void R_SetupColormap(player_t *player) // [SP] Emulate GZDoom's light-amp goggles. if (r_fullbrightignoresectorcolor && fixedlightlev >= 0) { - fixedcolormap = &FullNormalLight; + fixedcolormap = FullNormalLight.Maps; } } } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index d265d626f..d1ec04f6d 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -314,7 +314,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; @@ -631,7 +631,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; @@ -1789,7 +1789,7 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); + dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; @@ -3188,11 +3188,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - WallC.sx1) * rw_lightstep; if (fixedlightlev >= 0) - dc_colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (usecolormap->Maps + fixedlightlev); + dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (usecolormap->Maps + fixedlightlev); else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - dc_colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : usecolormap->Maps; + dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; else calclighting = true; diff --git a/src/r_things.cpp b/src/r_things.cpp index 047ee9295..a88624443 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -549,7 +549,7 @@ void R_DrawWallSprite(vissprite_t *spr) else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - dc_colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : usecolormap->Maps; + dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; else calclighting = true; @@ -1142,7 +1142,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } else if (!foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) { // full bright - vis->Style.colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : mybasecolormap->Maps; + vis->Style.colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : mybasecolormap->Maps; } else { // diminished light @@ -1464,11 +1464,11 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double } if (fixedlightlev >= 0) { - vis->Style.colormap = (r_fullbrightignoresectorcolor) ? (&FullNormalLight->Maps + fixedlightlev) : (mybasecolormap->Maps + fixedlightlev); + vis->Style.colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (mybasecolormap->Maps + fixedlightlev); } else if (!foggy && pspr->GetState()->GetFullbright()) { // full bright - vis->Style.colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : mybasecolormap->Maps; // [RH] use basecolormap + vis->Style.colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : mybasecolormap->Maps; // [RH] use basecolormap } else { // local light @@ -2064,7 +2064,7 @@ void R_DrawSprite (vissprite_t *spr) } else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) { // full bright - spr->Style.colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : mybasecolormap->Maps; + spr->Style.colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : mybasecolormap->Maps; } else { // diminished light @@ -2622,7 +2622,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, } else if (particle->bright) { - vis->Style.colormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight->Maps : map; + vis->Style.colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : map; } else { From 8678baf6f589a68635939a1063a28231a0aa01a1 Mon Sep 17 00:00:00 2001 From: raa-eruanna Date: Fri, 21 Oct 2016 07:32:18 -0400 Subject: [PATCH 3/3] - Fullbright fixes --- src/r_data/colormaps.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index 73265b20e..2d3c0e49d 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -73,6 +73,7 @@ struct FakeCmap TArray fakecmaps; BYTE *realcolormaps; +BYTE *realfbcolormaps; //[SP] For fullbright use size_t numfakecmaps; @@ -460,6 +461,11 @@ void R_DeinitColormaps () delete[] realcolormaps; realcolormaps = NULL; } + if (realfbcolormaps != NULL) + { + delete[] realfbcolormaps; + realfbcolormaps = NULL; + } FreeSpecialLights(); } @@ -549,12 +555,20 @@ void R_InitColormaps () } } } + + // [SP] Create a copy of the colormap + if (!realfbcolormaps) + { + realfbcolormaps = new BYTE[256*NUMCOLORMAPS*fakecmaps.Size()]; + memcpy(realfbcolormaps, realcolormaps, 256*NUMCOLORMAPS*fakecmaps.Size()); + } + NormalLight.Color = PalEntry (255, 255, 255); NormalLight.Fade = 0; NormalLight.Maps = realcolormaps; FullNormalLight.Color = PalEntry (255, 255, 255); FullNormalLight.Fade = 0; - FullNormalLight.Maps = realcolormaps; + FullNormalLight.Maps = realfbcolormaps; NormalLightHasFixedLights = R_CheckForFixedLights(realcolormaps); numfakecmaps = fakecmaps.Size();