Messed up with shadow mapping

I’m moving from R152 to R162. I’ve solved all the issues related to the change in the illumination model. But I can’t fix shadow mapping. Tried all the possible settings I’m aware of. There is for sure something really silly that I still miss. Any clue? Thank you.

light.shadow.bias=-0.0004;
Different values: -0.004, -0.04, -0.4, 0.004, 0.04, 0.4 etc.

1 Like

Thank you Chaser_Code. Imho this has to be documented better. I had to set bias -0.02 and normalBias 0.02 but this is trial and error, I have no clue what I’m doing here. Are those values related to the size of the shadow texture? Or to the distance of the directional light?

1 Like

From the documentation:

bias

How much to add or subtract from the normalized depth when deciding whether a surface is in shadow. The default is 0 . Very tiny adjustments here (in the order of 0.0001 ) may help reduce artifacts in shadows

normalBias

Defines how much the position used to query the shadow map is offset along the object normal. The default is 0 . Increasing this value can be used to reduce shadow acne especially in large scenes where light shines onto geometry at a shallow angle. The cost is that shadows may appear distorted.

1 Like

Thanks, Mugen I’ve read those, but it did not help me. What does it mean “may help”? It means to me: do trial and error. Maybe I’m dumb but I’ve lost hours today struggling to understand how it works. What is normalized depth? Why those artifacts are introduced? Maybe an external link in the documentation to a reference paper could help. BTW to anyone who could face the same problem, my previous setting normalBias=0.02 is completely useless in my scene. I’ve removed it and works the same.

1 Like

Shadow acne/shadowmap artifacts are a pretty well know aspect of shadowmapping, going back to the 70s. :smiley:

Here’s some more info: Shadow Acne

TIL about .normalBias… which I wasn’t aware of… but generally I use .bias.
It could be better explained, but It isn’t always an issue for people, so that’s probably why it isn’t mentioned in the docs explicitly.

The main factors that control depth buffer precision is the distance between the camera.far and camera.near… I.e. a far of 10000, and new of .01 will show more shadow acne than a far of 100 and a near of .1
So if you can tweak your camera range to more tightly enclose your scene, that can help a lot.
There are also multiple shadowmap types which each have their own behavior, and there is also the .logarithmicDepthBuffer setting on the renderer which can affect the behavior.