Fix redundant 2D shadowmap test for lightmap lights

This commit is contained in:
RaveYard 2024-06-19 12:28:33 +02:00 committed by Magnus Norddahl
commit c72092ffed

View file

@ -158,7 +158,7 @@ void HWDrawInfo::GetDynSpriteLight(AActor *self, float x, float y, float z, FLig
dist = (float)L.LengthSquared();
radius = light->GetRadius();
if (dist < radius * radius)
if (radius > 0 && dist < radius * radius)
{
dist = sqrtf(dist); // only calculate the square root if we really need it.
@ -181,7 +181,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 || (light->GetRadius() > 0 && screen->mShadowMap->ShadowTest(light->Pos, { x, y, z }))))
if (frac > 0 && (!light->shadowmapped || light->Trace() || screen->mShadowMap->ShadowTest(light->Pos, { x, y, z })))
{
lr = light->GetRed() / 255.0f;
lg = light->GetGreen() / 255.0f;