From 3e3bd2722f4e2abc5e4f44e6dafd36f4d65caed1 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 30 Sep 2022 14:58:58 -0700 Subject: [PATCH] fix lispsm when camera and light direction are aligned in that case we have to revert to the ortho projection --- filament/src/ShadowMap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/filament/src/ShadowMap.cpp b/filament/src/ShadowMap.cpp index 3ffa4dd17d..8bffaa21f2 100644 --- a/filament/src/ShadowMap.cpp +++ b/filament/src/ShadowMap.cpp @@ -511,7 +511,8 @@ mat4f ShadowMap::applyLISPSM(mat4f& Wp, mat4f W; // see nopt1 below for an explanation about this test // sinLV is positive since it comes from a square-root - if (sinLV > 0 && 3.0f * (dzn / (zf - zn)) < 2.0f) { + constexpr float epsilon = 0.02f; // very roughly 1 degree + if (sinLV > epsilon && 3.0f * (dzn / (zf - zn)) < 2.0f) { // nopt is the optimal near plane distance of Wp (i.e. distance from P). // virtual near and far planes