I know how shadow mapping works but I am not getting the cause of shadow acne! Can anyone tell me cause of shadow acne in a simple way and how is it related to depth map resolution?
2 Answers
Image 1: A bad case of shadow acne. (Synthetic and a bit exaggerated)
Shadow acne is caused by the discrete nature of the shadow map. A shadow map is composed of samples, a surface is continuous. Thus, there can be a spot on the surface where the discrete surface is further than the sample. The problem does persist even if you multi sample, but you can sample smarter in ways that can nearly eliminate this at significant cost.
Image 2: A side cutaway of a shadow function and its discrete samples.
The canonical way to solve this is to offset the shadow map slightly so the object no longer self shadows itself. This offset is called a bias. One can use more smart offsets than just a fixed value but a fixed value works quite well and has minimal overhead.
Image 3: Shadow function biased (offset) forward.

- 8,437
- 1
- 24
- 47
-
And this discrete nature of depth map is created because of floating point precision. Right? – videogamechef Mar 16 '16 at 20:12
-
1No its created because images are discrete as in have only one value for a area that varies. – joojaa Mar 16 '16 at 21:00
-
Images are different in camera and light space? – videogamechef Mar 16 '16 at 21:04
-
Ok is that zigzag line represents depth map? – videogamechef Mar 17 '16 at 14:14
-
It represents the function of the depth map, the dashed lines represent the pixel samples of the depth map. – joojaa Mar 17 '16 at 14:16
-
Ok so when we sample from a depth map..Its not necessary you will sample from the exact same position..but the different one which can be either higher or lower than the depth map? – videogamechef Mar 17 '16 at 14:25
-
Yes you got it. – joojaa Mar 18 '16 at 05:39
As an addition to the answer of joojaa: Using a bias to offset the shadow function does indeed solve the problem with shadow acne, but it can introduce an additional problem: Peter Panning
As you see in the picture on the left the shadow is disconnected from the shadow casting wall. This gives the impression that the geometry hovers over the ground (just like Peter Pan can hover, hence the name Peter Panning).
To solve this problem you have to use "thick" geometry that has a volume and then render the shadow map using the back-faces. If the offset is smaller than the thickness of the geometry there will be no Peter Panning.
Both images are taken from this tutorial where you can also learn more about how shadow mapping works, how shadow acne is created and solved and what Peter Panning is.

- 1,810
- 1
- 11
- 24
-
-
3I would have thought it's called Peter Panning because some films depict Peter Pan's shadow as having a mind of its own and detaching itself from Peter. – Martin Ender Mar 17 '16 at 14:27
-
@MartinBüttner Well, yes. That seems to be a sensible reason to call it that way. The tutorial I refered to uses the explanation that I gave. – Dragonseel Mar 17 '16 at 16:12