From 538897430dfced8492c275c3941f1ccfb0ee9a6d Mon Sep 17 00:00:00 2001 From: drfrag666 Date: Wed, 9 May 2018 19:05:10 +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. (ported patch by Graf) --- src/g_shared/a_dynlightdata.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/g_shared/a_dynlightdata.cpp b/src/g_shared/a_dynlightdata.cpp index 167ae255b..5aaa5eee1 100644 --- a/src/g_shared/a_dynlightdata.cpp +++ b/src/g_shared/a_dynlightdata.cpp @@ -104,6 +104,7 @@ protected: }; TArray LightAssociations; +double lightSizeFactor = 1.; //========================================================================== @@ -313,7 +314,7 @@ static void ParseTriple(FScanner &sc, float floatVal[3]) } -static void AddLightDefaults(FLightDefaults *defaults) +static void AddLightDefaults(FLightDefaults *defaults, double attnFactor) { FLightDefaults *temp; unsigned int i; @@ -330,6 +331,12 @@ static void AddLightDefaults(FLightDefaults *defaults) } } + 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); } @@ -414,7 +421,7 @@ static void ParsePointLight(FScanner &sc) sc.ScriptError("Unknown tag: %s\n", sc.String); } } - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -510,7 +517,7 @@ static void ParsePulseLight(FScanner &sc) } defaults->OrderIntensities(); - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -605,7 +612,7 @@ void ParseFlickerLight(FScanner &sc) } } defaults->OrderIntensities(); - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -705,7 +712,7 @@ void ParseFlickerLight2(FScanner &sc) defaults->SetArg(LIGHT_SECONDARY_INTENSITY, defaults->GetArg(LIGHT_INTENSITY)); defaults->SetArg(LIGHT_INTENSITY, v); } - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -791,7 +798,7 @@ static void ParseSectorLight(FScanner &sc) sc.ScriptError("Unknown tag: %s\n", sc.String); } } - AddLightDefaults(defaults); + AddLightDefaults(defaults, lightSizeFactor); } else { @@ -958,6 +965,7 @@ static const char *CoreKeywords[]= "detail", "#include", "material", + "lightsizefactor", nullptr }; @@ -980,7 +988,8 @@ enum TAG_HARDWARESHADER, TAG_DETAIL, TAG_INCLUDE, - TAG_MATERIAL + TAG_MATERIAL, + TAG_LIGHTSIZEFACTOR, }; @@ -1347,6 +1356,9 @@ static void DoParseDefs(FScanner &sc, int workingLump) case TAG_DETAIL: gl_ParseDetailTexture(sc); break; + case TAG_LIGHTSIZEFACTOR: + lightSizeFactor = ParseFloat(sc); + break; case TAG_DISABLE_FB: { /* not implemented.