From e77cba1fd8ad45809d207a7c281af3e6baabef36 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 18 Apr 2018 22:15:06 +0200 Subject: [PATCH] - added a 'lightsizefactor' command to gldefs. This is for mitigating the recently discovered problem with attenuated lights getting reduced in size, even on OpenGL 3+. The intent of the shrinking was to account for higher brightness of non-attenuated lights on OpenGL 2 and was never meant to be active on more modern versions. The factor will apply to any attenuated light defined after it and will be inherited by included sub-lumps, but it will only last for the lunp it is set in. If you have a definition for the broken behavior, AddLightAssociation 'lightsizefactor 0.667' at the top of your GLDEFS. --- src/r_data/a_dynlightdata.cpp | 7 ++++++- src/r_data/gldefs.cpp | 22 ++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/r_data/a_dynlightdata.cpp b/src/r_data/a_dynlightdata.cpp index b9c09a6908..6cab5d02c0 100644 --- a/src/r_data/a_dynlightdata.cpp +++ b/src/r_data/a_dynlightdata.cpp @@ -137,7 +137,7 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const extern int ScriptDepth; -void AddLightDefaults(FLightDefaults *defaults) +void AddLightDefaults(FLightDefaults *defaults, double attnFactor) { FLightDefaults *temp; unsigned int i; @@ -153,6 +153,11 @@ void AddLightDefaults(FLightDefaults *defaults) break; } } + if (defaults->GetAttenuate()) + { + defaults->SetArg(LIGHT_INTENSITY, int(defaults->GetArg(LIGHT_INTENSITY) * attnFactor)); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, int(defaults->GetArg(LIGHT_SECONDARY_INTENSITY) * attnFactor)); + } LightDefaults.Push(defaults); } diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index 92c7a91d76..c01b905d9d 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -52,7 +52,7 @@ #include "textures/skyboxtexture.h" #include "gl/shaders/gl_postprocessshader.h" -void AddLightDefaults(FLightDefaults *defaults); +void AddLightDefaults(FLightDefaults *defaults, double attnFactor); void AddLightAssociation(const char *actor, const char *frame, const char *light); void InitializeActorLights(TArray &LightAssociations); @@ -193,6 +193,7 @@ static const char *CoreKeywords[]= "detail", "#include", "material", + "lightsizefactor", nullptr }; @@ -215,7 +216,8 @@ enum TAG_HARDWARESHADER, TAG_DETAIL, TAG_INCLUDE, - TAG_MATERIAL + TAG_MATERIAL, + TAG_LIGHTSIZEFACTOR, }; //========================================================================== @@ -230,6 +232,7 @@ class GLDefsParser int workingLump; int ScriptDepth = 0; TArray &LightAssociations; + double lightSizeFactor = 1.; //========================================================================== // @@ -470,7 +473,7 @@ class GLDefsParser sc.ScriptError("Unknown tag: %s\n", sc.String); } } - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -565,7 +568,7 @@ class GLDefsParser } defaults->OrderIntensities(); - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -660,7 +663,7 @@ class GLDefsParser } } defaults->OrderIntensities(); - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -760,7 +763,7 @@ class GLDefsParser defaults->SetArg(LIGHT_SECONDARY_INTENSITY, defaults->GetArg(LIGHT_INTENSITY)); defaults->SetArg(LIGHT_INTENSITY, v); } - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -846,7 +849,7 @@ class GLDefsParser sc.ScriptError("Unknown tag: %s\n", sc.String); } } - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -1427,7 +1430,6 @@ class GLDefsParser } } } - public: @@ -1461,6 +1463,7 @@ public: sc.ScriptError("Lump '%s' not found", sc.String); GLDefsParser newscanner(lump, LightAssociations); + newscanner.lightSizeFactor = lightSizeFactor; newscanner.DoParseDefs(); break; } @@ -1508,6 +1511,9 @@ public: case TAG_DETAIL: ParseDetailTexture(); break; + case TAG_LIGHTSIZEFACTOR: + lightSizeFactor = ParseFloat(sc); + break; case TAG_DISABLE_FB: { /* not implemented.