- changed the light parameter of ShadowTest to a position vector.

This was one of two places where game state leaked into the shadowmap implementation.
This commit is contained in:
Christoph Oelckers 2020-04-26 14:53:26 +02:00
parent 02832297ff
commit 0a3e9a49f8
3 changed files with 5 additions and 5 deletions

View file

@ -98,10 +98,10 @@ CUSTOM_CVAR (Bool, gl_light_shadowmap, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
}
}
bool IShadowMap::ShadowTest(FDynamicLight *light, const DVector3 &pos)
bool IShadowMap::ShadowTest(const DVector3 &lpos, const DVector3 &pos)
{
if (light->shadowmapped && light->GetRadius() > 0.0 && IsEnabled() && mAABBTree)
return mAABBTree->RayTest(light->Pos, pos) >= 1.0f;
if (mAABBTree)
return mAABBTree->RayTest(lpos, pos) >= 1.0f;
else
return true;
}

View file

@ -19,7 +19,7 @@ public:
void Reset();
// Test if a world position is in shadow relative to the specified light and returns false if it is
bool ShadowTest(FDynamicLight *light, const DVector3 &pos);
bool ShadowTest(const DVector3 &lpos, const DVector3 &pos);
// Returns true if gl_light_shadowmap is enabled and supported by the hardware
bool IsEnabled() const;

View file

@ -106,7 +106,7 @@ void HWDrawInfo::GetDynSpriteLight(AActor *self, float x, float y, float z, FLig
frac *= (float)smoothstep(light->pSpotOuterAngle->Cos(), light->pSpotInnerAngle->Cos(), cosDir);
}
if (frac > 0 && (!light->shadowmapped || screen->mShadowMap.ShadowTest(light, { x, y, z })))
if (frac > 0 && (!light->shadowmapped || (light->GetRadius() > 0 && screen->mShadowMap.ShadowTest(light->Pos, { x, y, z }))))
{
lr = light->GetRed() / 255.0f;
lg = light->GetGreen() / 255.0f;