Hi everyone,
I’ve been looking around everywhere for a solution to my issue. When the camera faces down on the ground, the shadows from the CSM suddenly disappears. I have tried changing the bias and normal bias, but neither of them worked.
Here is the repository for my code as well as the game.
I would also like to mention that the code for the shadow map can be found under src/modules/scenes/scene.ts
Any help would be appreciated.
Thanks in advance.
Hi @Related9985 and welcome to the forum!
Can you repro is playground please? it makes debugging way easier.
I don’t really want to make a playground since I’ll have to transfer the majority of the code, altough I have included the inspector in the game, by pressing ctrl + shift + alt + i. If not, I could make a simple playground.
Looking straight down works in this PG:
So, I’m not sure why it doesn’t work for you.
[…] Ah, it’s the “auto-calc depth bounds” parameter! I could not reproduce the problem in this PG, though:
What you can try is to create a depth renderer with float type (by default, it is half float), in case it would be a floating point precision problem. Here’s how to do it:
It’s a bit of a hack, because we currently can’t set the type of the texture for the min/max reducer, but if it works I will see to add a clean way to do it.
Creating a depth renderer with float type seems to work, but If you play the game and face the camera down, and start moving around, the shadows start flickering.
I noticed that with a particular rotation of the camera (and only one?), part of the shadow of the sphere disappeared:
It’s the same problem as when the type was HALF_FLOAT but it appears much less often because of the additional precision of FLOAT. So I’m not sure there’s much we can do, we’d need even greater precision…
Is it an option for you not to authorize looking straight down but to limit it to a small angle (if it is an arc rotate camera, not less than 5° for the beta angle, for example)?
Thanks for the solution! It now works after I have limited the camera’s rotation, although I would love to see babylon.js introduce a proper way to set the precision float of the shadows.