From c5fc7a01e87e5789b4064d4d952ff6a39e4cf8a8 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 1 Mar 2019 15:06:42 -0800 Subject: [PATCH] remove an incorrect assert() in shadow mapping when we compute the depth range of the shadow map, if znear is behind zfar, it just means we don't have any shadow caster in front of a receiver, and we can just bail out without shadowing -- as opposed to asserting. --- filament/src/ShadowMap.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/filament/src/ShadowMap.cpp b/filament/src/ShadowMap.cpp index 3273763799..afce13f0bd 100644 --- a/filament/src/ShadowMap.cpp +++ b/filament/src/ShadowMap.cpp @@ -285,7 +285,12 @@ void ShadowMap::computeShadowCameraDirectional( // i.e. the -z axis (see: ortho) const float znear = -lsLightFrustum.max.z; const float zfar = -lsLightFrustum.min.z; - assert(znear < zfar); + + // if znear >= zfar, it means we don't have any shadow caster in front of a shadow receiver + if (UTILS_UNLIKELY(znear >= zfar)) { + mHasVisibleShadows = false; + return; + } // The light's projection, ortho for directional lights, perspective otherwise const mat4f Mp = mat4f::ortho(-1, 1, -1, 1, znear, zfar);