- change per-level attenuation of dynamic lights for each viewpoint.

To avoid unnecessary work, the current state is tracked.
This commit is contained in:
Christoph Oelckers 2019-01-29 20:09:06 +01:00
parent 6451b7d592
commit 4af5ea25c1
5 changed files with 16 additions and 7 deletions

View file

@ -1552,8 +1552,6 @@ void FLevelLocals::Init()
brightfog = info->brightfog < 0? gl_brightfog : !!info->brightfog;
lightadditivesurfaces = info->lightadditivesurfaces < 0 ? gl_lightadditivesurfaces : !!info->lightadditivesurfaces;
notexturefill = info->notexturefill < 0 ? gl_notexturefill : !!info->notexturefill;
FLightDefaults::SetAttenuationForLevel();
}
//==========================================================================

View file

@ -76,7 +76,7 @@ public:
void SetSpot(bool spot) { if (spot) m_lightFlags |= LF_SPOT; else m_lightFlags &= ~LF_SPOT; }
void SetSpotInnerAngle(double angle) { m_spotInnerAngle = angle; }
void SetSpotOuterAngle(double angle) { m_spotOuterAngle = angle; }
static void SetAttenuationForLevel();
static void SetAttenuationForLevel(bool);
void OrderIntensities()
{

View file

@ -156,6 +156,10 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
if (mainview && toscreen)
UpdateShadowMap();
// Update the attenuation flag of all light defaults for each viewpoint.
// This function will only do something if the setting differs.
FLightDefaults::SetAttenuationForLevel(!!(camera->Level->flags3 & LEVEL3_ATTENUATE));
// Render (potentially) multiple views for stereo 3d
// Fixme. The view offsetting should be done with a static table and not require setup of the entire render state for the mode.
auto vrmode = VRMode::GetVRMode(mainview && toscreen);

View file

@ -55,6 +55,7 @@ inline PClassActor * GetRealType(PClassActor * ti)
}
TDeletingArray<FLightDefaults *> LightDefaults;
int AttenuationIsSet = -1;
//-----------------------------------------------------------------------------
//
@ -101,14 +102,18 @@ void FLightDefaults::ApplyProperties(FDynamicLight * light) const
light->SetOffset(m_Pos); // this must be the last thing to do.
}
void FLightDefaults::SetAttenuationForLevel()
void FLightDefaults::SetAttenuationForLevel(bool yes)
{
for (auto ldef : LightDefaults)
if (AttenuationIsSet != int(yes))
{
if (ldef->m_attenuate == -1)
for (auto ldef : LightDefaults)
{
if (level.flags3 & LEVEL3_ATTENUATE) ldef->m_lightFlags |= LF_ATTENUATE; else ldef->m_lightFlags &= ~LF_ATTENUATE;
if (ldef->m_attenuate == -1)
{
if (yes) ldef->m_lightFlags |= LF_ATTENUATE; else ldef->m_lightFlags &= ~LF_ATTENUATE;
}
}
AttenuationIsSet = yes;
}
}

View file

@ -53,6 +53,7 @@ void InitializeActorLights(TArray<FLightAssociation> &LightAssociations);
TArray<UserShaderDesc> usershaders;
extern TDeletingArray<FLightDefaults *> LightDefaults;
extern int AttenuationIsSet;
//-----------------------------------------------------------------------------
@ -1777,6 +1778,7 @@ void ParseGLDefs()
const char *defsLump = NULL;
LightDefaults.DeleteAndClear();
AttenuationIsSet = -1;
//gl_DestroyUserShaders(); function says 'todo'
switch (gameinfo.gametype)
{