🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Shadow map acne and distance to light

Started by
3 comments, last by ErnstH 3 years ago

I'm implementing shadow mapping and noticed that the acne not only depends on the angle between the normal and the light (the distance to the contours in the shadow map), but also on the distance to the light.

My guess is that this is the result of the floating point precision that decreases with higher numbers. To fight this I adjust the bias like this:

bias *= (1.0+DistanceToLight/500.0);

This works fine, but I worry about it because I have not seen any paper/tutorial doing something similar. And if it is the result of the limited precision it probably has to be another (logarithmic?) function.

Does this makes sense or am I doing something wrong?

Advertisement

If you are using DirectX you can configure the depth and slope scale depth bias in your rasterizer description. If your shadowmap render target is in the D24. D32. etc… format the calculation will be automagically applied.

Thank you for your answer. Yes, I'm using DX11. The shadow map texture format is DXGI_FORMAT_R16_FLOAT and the far clipping plane is set to 2000. The fixed bias and slope bias already work fine, but only for points near the light. For objects further away I have to add a 3rd bias that depends on the distance to the light (the z component of the directional light view space). I'm puzzled by this and wonder why I have to do this.

For a directional light it should not matter where the object is placed. But it does: the very same object with the very same rotation placed further away from the light requires a slightly bigger bias. Is it the limited precision of floats? Or something else?

Switching from DXGI_FORMAT_R16_FLOAT to DXGI_FORMAT_R32_FLOAT solved the issue. Limited floating point precision must have caused it.

This topic is closed to new replies.

Advertisement