diff --git a/src/g_level.cpp b/src/g_level.cpp index a71b481c9..8b67c9107 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -101,6 +101,7 @@ EXTERN_CVAR (Float, sv_gravity) EXTERN_CVAR (Float, sv_aircontrol) EXTERN_CVAR (Int, disableautosave) EXTERN_CVAR (String, playerclass) +EXTERN_CVAR(Int, r_preservesectorcolor) #define SNAP_ID MAKE_ID('s','n','A','p') #define DSNP_ID MAKE_ID('d','s','N','p') @@ -1487,6 +1488,20 @@ bool FLevelLocals::IsFreelookAllowed() const // //========================================================================== +bool FLevelLocals::PreserveSectorColor() const +{ + if (r_preservesectorcolor == 0) + return false; + if (r_preservesectorcolor == 1) + return true; + return !!(level.flags3 & LEVEL3_PRESERVESECTORCOLOR); +} + +//========================================================================== +// +// +//========================================================================== + FString CalcMapName (int episode, int level) { FString lumpname; diff --git a/src/g_level.h b/src/g_level.h index 1fadcee3a..270cf54f0 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -223,6 +223,7 @@ enum ELevelFlags : unsigned int // More flags! LEVEL3_FORCEFAKECONTRAST = 0x00000001, // forces fake contrast even with fog enabled + LEVEL3_PRESERVESECTORCOLOR = 0x00000002, }; diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 357e2e154..0afac37ad 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -79,6 +79,7 @@ struct FLevelLocals bool IsJumpingAllowed() const; bool IsCrouchingAllowed() const; bool IsFreelookAllowed() const; + bool PreserveSectorColor() const; }; extern FLevelLocals level; diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index bb641b23b..3f8e50027 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1282,6 +1282,8 @@ MapFlagHandlers[] = { "unfreezesingleplayerconversations",MITYPE_SETFLAG2, LEVEL2_CONV_SINGLE_UNFREEZE, 0 }, { "spawnwithweaponraised", MITYPE_SETFLAG2, LEVEL2_PRERAISEWEAPON, 0 }, { "forcefakecontrast", MITYPE_SETFLAG3, LEVEL3_FORCEFAKECONTRAST, 0 }, + { "preservesectorcolor", MITYPE_SETFLAG3, LEVEL3_PRESERVESECTORCOLOR, 0 }, + { "nopreservesectorcolor", MITYPE_CLRFLAG3, LEVEL3_PRESERVESECTORCOLOR, 0 }, { "nobotnodes", MITYPE_IGNORE, 0, 0 }, // Skulltag option: nobotnodes { "compat_shorttex", MITYPE_COMPATFLAG, COMPATF_SHORTTEX, 0 }, { "compat_stairs", MITYPE_COMPATFLAG, COMPATF_STAIRINDEX, 0 }, diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 429f69c34..04a53d67d 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -141,9 +141,10 @@ bool FRenderState::ApplyShader() fogset = -gl_fogmode; } } + glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec); glVertexAttrib4fv(VATTR_COLOR, mColor.vec); - glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec); + activeShader->muObjectColor.Set(mObjectColor); activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muFogEnabled.Set(fogset); @@ -152,7 +153,6 @@ bool FRenderState::ApplyShader() activeShader->muCameraPos.Set(mCameraPos.vec); activeShader->muLightParms.Set(mLightParms); activeShader->muFogColor.Set(mFogColor); - activeShader->muObjectColor.Set(mObjectColor); activeShader->muDynLightColor.Set(mDynColor.vec); activeShader->muInterpolationFactor.Set(mInterpolationFactor); activeShader->muClipHeight.Set(mClipHeight); diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 14a2f153f..a28b63d4a 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -54,7 +54,6 @@ #include "g_levellocals.h" CVAR (Bool, r_drawflat, false, 0) // [RH] Don't texture segs? -EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); namespace swrenderer { @@ -1109,7 +1108,7 @@ void R_Subsector (subsector_t *sub) } else { - basecolormap = (r_fullbrightignoresectorcolor && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap; + basecolormap = (!level.PreserveSectorColor() && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap; } portal = frontsector->ValidatePortal(sector_t::ceiling); @@ -1143,7 +1142,7 @@ void R_Subsector (subsector_t *sub) } else { - basecolormap = (r_fullbrightignoresectorcolor && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap; + basecolormap = (!level.PreserveSectorColor() && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap; } // killough 3/7/98: Add (x,y) offsets to flats, add deep water check diff --git a/src/r_main.cpp b/src/r_main.cpp index 7030339c7..8907888f5 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -59,6 +59,7 @@ #include "r_data/colormaps.h" #include "p_maputl.h" #include "r_thread.h" +#include "g_levellocals.h" CVAR (String, r_viewsize, "", CVAR_NOSET) CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE) @@ -78,8 +79,6 @@ CUSTOM_CVAR (Int, r_columnmethod, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Int, r_portal_recursions, 4, CVAR_ARCHIVE) CVAR(Bool, r_highlight_portals, false, CVAR_ARCHIVE) -EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) - extern cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles; extern cycle_t FrameCycles; @@ -488,7 +487,7 @@ void R_SetupColormap(player_t *player) { fixedlightlev = player->fixedlightlevel * 256; // [SP] Emulate GZDoom's light-amp goggles. - if (r_fullbrightignoresectorcolor && fixedlightlev >= 0) + if (!level.PreserveSectorColor() && fixedlightlev >= 0) { fixedcolormap = FullNormalLight.Maps; } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index ccf6ccf20..490de11d0 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -47,13 +47,13 @@ #include "r_draw.h" #include "v_palette.h" #include "r_data/colormaps.h" +#include "g_levellocals.h" #define WALLYREPEAT 8 CVAR(Bool, r_fogboundary, true, 0) CVAR(Bool, r_drawmirrors, true, 0) -EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); namespace swrenderer { @@ -291,7 +291,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_scalestep = ds->iscalestep; if (fixedlightlev >= 0) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); @@ -608,7 +608,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } if (fixedlightlev >= 0) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); @@ -1060,7 +1060,7 @@ void R_RenderSegLoop () fixed_t xoffset = rw_offset; if (fixedlightlev >= 0) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); @@ -2303,11 +2303,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rw_light = rw_lightleft + (x1 - savecoord.sx1) * rw_lightstep; if (fixedlightlev >= 0) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); + R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); + R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : usecolormap, 0, 0); else calclighting = true; diff --git a/src/r_things.cpp b/src/r_things.cpp index 730448706..827a0dca2 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -74,7 +74,6 @@ EXTERN_CVAR(Bool, r_deathcamera); EXTERN_CVAR(Bool, r_drawplayersprites) EXTERN_CVAR(Bool, r_drawvoxels) -CVAR(Bool, r_fullbrightignoresectorcolor, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); //CVAR(Bool, r_splitsprites, true, CVAR_ARCHIVE) namespace swrenderer @@ -537,7 +536,7 @@ void R_DrawWallSprite(vissprite_t *spr) else if (fixedcolormap != NULL) R_SetColorMapLight(fixedcolormap, 0, 0); else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) - R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0); + R_SetColorMapLight((!level.PreserveSectorColor()) ? &FullNormalLight : usecolormap, 0, 0); else calclighting = true; @@ -1128,7 +1127,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } else if (!foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT))) { // full bright - vis->colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : mybasecolormap->Maps; + vis->colormap = (!level.PreserveSectorColor()) ? FullNormalLight.Maps : mybasecolormap->Maps; } else { // diminished light @@ -1455,11 +1454,11 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double } if (fixedlightlev >= 0) { - vis->colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (mybasecolormap->Maps + fixedlightlev); + vis->colormap = (!level.PreserveSectorColor()) ? (FullNormalLight.Maps + fixedlightlev) : (mybasecolormap->Maps + fixedlightlev); } else if (!foggy && pspr->GetState()->GetFullbright()) { // full bright - vis->colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : mybasecolormap->Maps; // [RH] use basecolormap + vis->colormap = (!level.PreserveSectorColor()) ? FullNormalLight.Maps : mybasecolormap->Maps; // [RH] use basecolormap } else { // local light @@ -1506,9 +1505,9 @@ 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) + if (!level.PreserveSectorColor() && fixedlightlev >= 0) mybasecolormap = &FullNormalLight; - if (r_fullbrightignoresectorcolor && !foggy && pspr->GetState()->GetFullbright()) + if (!level.PreserveSectorColor() && !foggy && pspr->GetState()->GetFullbright()) mybasecolormap = &FullNormalLight; colormap_to_use = mybasecolormap; } @@ -2049,7 +2048,7 @@ void R_DrawSprite (vissprite_t *spr) } else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) { // full bright - spr->colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : mybasecolormap->Maps; + spr->colormap = (!level.PreserveSectorColor()) ? FullNormalLight.Maps : mybasecolormap->Maps; } else { // diminished light @@ -2607,7 +2606,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, } else if (particle->bright) { - vis->colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : map; + vis->colormap = (!level.PreserveSectorColor()) ? FullNormalLight.Maps : map; } else { diff --git a/src/r_utility.cpp b/src/r_utility.cpp index d2358d8b3..8b0a04a86 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -91,6 +91,11 @@ static TArray InterpolationPath; // PUBLIC DATA DEFINITIONS ------------------------------------------------- +CUSTOM_CVAR(Int, r_preservesectorcolor, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < -1 || self > 1) self = -1; +} + CVAR (Bool, r_deathcamera, false, CVAR_ARCHIVE) CVAR (Int, r_clearbuffer, 0, 0) CVAR (Bool, r_drawvoxels, true, 0) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index bdc1ce3ae..c2fb0a5a0 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1787,7 +1787,7 @@ DSPLYMNU_WATERFADE = "Underwater Blend Intensity"; DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used DSPLYMNU_ATTACHEDSURFACES = "Use attached surfaces"; // Not used DSPLYMNU_SKYMODE = "Sky render mode"; -DSPLYMNU_GZDFULLBRIGHT = "Fullbright overrides sector color"; +DSPLYMNU_GZDFULLBRIGHT = "Fullbright preserves sector color"; 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 47213a0f6..64e29dfe7 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -651,6 +651,13 @@ OptionValue Fuzziness 2.0, "$OPTVAL_SHADOW" } +OptionValue SectorColor +{ + -1.0, "$OPTVAL_MAPSETTING" + 0.0, "$OPTVAL_OFF" + 1.0, "$OPTVAL_ON" +} + OptionMenu "OpenGLOptions" { Title "$GLMNU_TITLE" @@ -690,7 +697,7 @@ OptionMenu "VideoOptions" } Option "$DSPLYMNU_SKYMODE", "r_skymode", "SkyModes" - Option "$DSPLYMNU_GZDFULLBRIGHT", "r_fullbrightignoresectorcolor", "OnOff" + Option "$DSPLYMNU_GZDFULLBRIGHT", "r_preservesectorcolor", "SectorColor" Option "$DSPLYMNU_DRAWFUZZ", "r_drawfuzz", "Fuzziness" Slider "$DSPLYMNU_TRANSSOUL", "transsouls", 0.25, 1.0, 0.05, 2 Option "$DSPLYMNU_FAKECONTRAST", "r_fakecontrast", "Contrast"