From 17698467d7b9055bc83ee7d007125df28a463434 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Dec 2016 12:58:45 +0100 Subject: [PATCH] - made application of dynamic lights to additively blended surfaces a MAPINFO option. In most cases this is not wanted but sometimes this can be used to good effect so it should be there as an option. --- src/gl/data/gl_data.cpp | 26 ++++++++++++++++++++++++-- src/gl/data/gl_data.h | 10 ++++++---- src/gl/renderer/gl_lightdata.cpp | 1 + src/gl/scene/gl_flats.cpp | 2 +- src/gl/scene/gl_walls_draw.cpp | 2 +- src/gl/scene/gl_weapon.cpp | 2 -- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index ad9c824bb..47ad63e99 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -57,6 +57,7 @@ long gl_frameCount; EXTERN_CVAR(Int, gl_lightmode) EXTERN_CVAR(Bool, gl_brightfog) +EXTERN_CVAR(Bool, gl_lightadditivesurfaces) CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE|CVAR_SERVERINFO) { @@ -203,6 +204,7 @@ struct FGLROptions : public FOptionalMapinfoData skyrotatevector = FVector3(0,0,1); skyrotatevector2 = FVector3(0,0,1); pixelstretch = 1.2f; + lightadditivesurfaces = false; } virtual FOptionalMapinfoData *Clone() const { @@ -217,6 +219,7 @@ struct FGLROptions : public FOptionalMapinfoData newopt->skyrotatevector = skyrotatevector; newopt->skyrotatevector2 = skyrotatevector2; newopt->pixelstretch = pixelstretch; + newopt->lightadditivesurfaces = lightadditivesurfaces; return newopt; } int fogdensity; @@ -224,8 +227,9 @@ struct FGLROptions : public FOptionalMapinfoData int skyfog; int lightmode; int brightfog; - SBYTE nocoloredspritelighting; - SBYTE notexturefill; + int8_t lightadditivesurfaces; + int8_t nocoloredspritelighting; + int8_t notexturefill; FVector3 skyrotatevector; FVector3 skyrotatevector2; float pixelstretch; @@ -299,6 +303,20 @@ DEFINE_MAP_OPTION(notexturefill, false) } } +DEFINE_MAP_OPTION(lightadditivesurfaces, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + if (parse.CheckAssign()) + { + parse.sc.MustGetNumber(); + opt->lightadditivesurfaces = !!parse.sc.Number; + } + else + { + opt->lightadditivesurfaces = true; + } +} + DEFINE_MAP_OPTION(skyrotate, false) { FGLROptions *opt = info->GetOptData("gl_renderer"); @@ -353,6 +371,7 @@ void InitGLRMapinfoData() { gl_SetFogParams(opt->fogdensity, level.info->outsidefog, opt->outsidefogdensity, opt->skyfog); glset.map_lightmode = opt->lightmode; + glset.map_lightadditivesurfaces = opt->lightadditivesurfaces; glset.map_brightfog = opt->brightfog; glset.map_nocoloredspritelighting = opt->nocoloredspritelighting; glset.map_notexturefill = opt->notexturefill; @@ -364,6 +383,7 @@ void InitGLRMapinfoData() { gl_SetFogParams(0, level.info->outsidefog, 0, 0); glset.map_lightmode = -1; + glset.map_lightadditivesurfaces = -1; glset.map_brightfog = -1; glset.map_nocoloredspritelighting = -1; glset.map_notexturefill = -1; @@ -380,6 +400,8 @@ void InitGLRMapinfoData() else glset.notexturefill = !!glset.map_notexturefill; if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog; else glset.brightfog = !!glset.map_brightfog; + if (glset.map_lightadditivesurfaces == -1) glset.brightfog = gl_brightfog; + else glset.lightadditivesurfaces = !!glset.map_lightadditivesurfaces; } CCMD(gl_resetmap) diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index f1bc27ee4..d6f789863 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -12,11 +12,13 @@ struct GLRenderSettings bool nocoloredspritelighting; bool notexturefill; bool brightfog; + bool lightadditivesurfaces; - SBYTE map_lightmode; - SBYTE map_nocoloredspritelighting; - SBYTE map_notexturefill; - SBYTE map_brightfog; + int8_t map_lightmode; + int8_t map_nocoloredspritelighting; + int8_t map_notexturefill; + int8_t map_brightfog; + int8_t map_lightadditivesurfaces; FVector3 skyrotatevector; FVector3 skyrotatevector2; diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 288af5c08..37f0a2e85 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -63,6 +63,7 @@ CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL) } } CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); +CVAR(Bool, lightadditivesurfaces, false, CVAR_ARCHIVE); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index c41e7664f..bc47e448b 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -109,7 +109,7 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) { Plane p; - if (renderstyle == STYLE_Add) return; // no lights on additively blended surfaces. + if (renderstyle == STYLE_Add && !glset.lightadditivesurfaces) return; // no lights on additively blended surfaces. if (dli != NULL && *dli != -1) { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index dbc43fd22..d392439e7 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -56,7 +56,7 @@ FDynLightData lightdata; void GLWall::SetupLights() { - if (RenderStyle == STYLE_Add) return; // no lights on additively blended surfaces. + if (RenderStyle == STYLE_Add && !glset.lightadditivesurfaces) return; // no lights on additively blended surfaces. // check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.) switch (type) diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index a2a12f947..7662c7876 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -188,8 +188,6 @@ static bool isBright(DPSprite *psp) // //========================================================================== -EXTERN_CVAR(Bool, gl_brightfog) - void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) { bool brightflash = false;