Hello,
I started with Babylon.js’s Physics Helpers example
and added a few lines to casts shadow:
changed lights - line 29
added shadow generator - line 32
made the ground to receive the shadow - line 36
and made boxes to cast shadow - line 152
When I click “radial explosion” and run for 10 seconds, shadows become corrupted.
Any suggestions why that happens and how that can be fixed?
thank you
I am guessing that I am not hitting the limit of object to cast because even with the original object count initially I am getting the correct shadows. The problem starts when I use one of the helpers. Therefore, we might be dealing with memory corruption…
That’s because, by default, the light frustum is calculated automatically according to the shadow caster positions. So, it also takes into account the boxes when they have fallen far apart from the ground, which extents the light frustum and reduce the shadow quality.
You should use a static light frustum, by setting light.autoUpdateExtends = false; and set values to orthoLeft/orthoRight/orthoTop/orthoBottom/shadowMinZ/shadowMaxZ: