Skip to content

Commit

Permalink
- added a 'lightsizefactor' command to gldefs.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
coelckers committed Apr 18, 2018
1 parent 4ab6034 commit e77cba1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/r_data/a_dynlightdata.cpp
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
22 changes: 14 additions & 8 deletions src/r_data/gldefs.cpp
Expand Up @@ -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<FLightAssociation> &LightAssociations);

Expand Down Expand Up @@ -193,6 +193,7 @@ static const char *CoreKeywords[]=
"detail",
"#include",
"material",
"lightsizefactor",
nullptr
};

Expand All @@ -215,7 +216,8 @@ enum
TAG_HARDWARESHADER,
TAG_DETAIL,
TAG_INCLUDE,
TAG_MATERIAL
TAG_MATERIAL,
TAG_LIGHTSIZEFACTOR,
};

//==========================================================================
Expand All @@ -230,6 +232,7 @@ class GLDefsParser
int workingLump;
int ScriptDepth = 0;
TArray<FLightAssociation> &LightAssociations;
double lightSizeFactor = 1.;

//==========================================================================
//
Expand Down Expand Up @@ -470,7 +473,7 @@ class GLDefsParser
sc.ScriptError("Unknown tag: %s\n", sc.String);
}
}
AddLightDefaults(defaults);
AddLightDefaults(defaults, lightSizeFactor);
}
else
{
Expand Down Expand Up @@ -565,7 +568,7 @@ class GLDefsParser
}
defaults->OrderIntensities();

AddLightDefaults(defaults);
AddLightDefaults(defaults, lightSizeFactor);
}
else
{
Expand Down Expand Up @@ -660,7 +663,7 @@ class GLDefsParser
}
}
defaults->OrderIntensities();
AddLightDefaults(defaults);
AddLightDefaults(defaults, lightSizeFactor);
}
else
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -846,7 +849,7 @@ class GLDefsParser
sc.ScriptError("Unknown tag: %s\n", sc.String);
}
}
AddLightDefaults(defaults);
AddLightDefaults(defaults, lightSizeFactor);
}
else
{
Expand Down Expand Up @@ -1427,7 +1430,6 @@ class GLDefsParser
}
}
}



public:
Expand Down Expand Up @@ -1461,6 +1463,7 @@ class GLDefsParser
sc.ScriptError("Lump '%s' not found", sc.String);

GLDefsParser newscanner(lump, LightAssociations);
newscanner.lightSizeFactor = lightSizeFactor;
newscanner.DoParseDefs();
break;
}
Expand Down Expand Up @@ -1508,6 +1511,9 @@ class GLDefsParser
case TAG_DETAIL:
ParseDetailTexture();
break;
case TAG_LIGHTSIZEFACTOR:
lightSizeFactor = ParseFloat(sc);
break;
case TAG_DISABLE_FB:
{
/* not implemented.
Expand Down

0 comments on commit e77cba1

Please sign in to comment.