<p>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</p>

<p><a href="https://i.sstatic.net/mdoX0.png" rel="noreferrer"><img src="https://i.sstatic.net/mdoX0.png" alt="Sample image that has Peter Panning"></a></p>

<p>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).</p>

<p>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.</p>

<p><a href="https://i.sstatic.net/TwFxZ.png" rel="noreferrer"><img src="https://i.sstatic.net/TwFxZ.png" alt="Scene with thick geometry and thereby no Peter Panning"></a></p>

<p>Both images are taken from <a href="http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/" rel="noreferrer">this tutorial</a> where you can also learn more about how shadow mapping works, how shadow acne is created and solved and what Peter Panning is.</p>

CC BY-SA 3.0
2016-03-17T14:18:53.710Z
One can also be more clever and render mid distance maps.
joojaa
CC BY-SA 3.0
2016-03-17T14:27:12.473Z
I 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](http://movies.stackexchange.com/q/13552/15400).
Martin Ender
CC BY-SA 3.0
2016-03-17T16:12:43.823Z
@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
CC BY-SA 3.0
2016-03-17T13:44:31.807Z
2016-03-17T13:44:31.807Z
Dragonseel
<p><a href="https://i.sstatic.net/o7MUP.png" rel="noreferrer"><img src="https://i.sstatic.net/o7MUP.png" alt="enter image description here"></a></p>

<p><strong>Image 1</strong>: A bad case of shadow acne. (Synthetic and a bit exaggerated)</p>

<p>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.</p>

<p><a href="https://i.sstatic.net/5HSkc.png" rel="noreferrer"><img src="https://i.sstatic.net/5HSkc.png" alt="enter image description here"></a></p>

<p><strong>Image 2:</strong> A side cutaway of a shadow function and its discrete samples.</p>

<p>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.</p>

<p><a href="https://i.sstatic.net/SyZdy.png" rel="noreferrer"><img src="https://i.sstatic.net/SyZdy.png" alt="enter image description here"></a></p>

<p><strong>Image 3:</strong> Shadow function biased (offset) forward.</p>

CC BY-SA 3.0
2016-03-16T20:12:31.963Z
And this discrete nature of depth map is created because of floating point precision. Right?
videogamechef
CC BY-SA 3.0
2016-03-16T21:00:08.700Z
No its created because images are discrete as in have only one value for a area that varies.
joojaa
CC BY-SA 3.0
2016-03-16T21:04:51.713Z
Images are different in camera and light space?
videogamechef
CC BY-SA 3.0
2016-03-17T14:14:02.127Z
Ok is that zigzag line represents depth map?
videogamechef
CC BY-SA 3.0
2016-03-17T14:16:55.647Z
It represents the function of the depth map, the dashed lines represent the pixel samples of the depth map.
joojaa
CC BY-SA 3.0
2016-03-17T14:25:36.870Z
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
CC BY-SA 3.0
2016-03-18T05:39:50.807Z
Yes you got it.
joojaa
CC BY-SA 3.0
2016-03-16T18:49:36.300Z
2016-03-16T20:05:24.677Z
2016-03-16T20:05:24.677Z
joojaa
<p>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? </p>

<opengl><raytracing><rendering><shader><transformations>
Cause of shadow acne
videogamechef
# Cause of shadow acne

(Asked by: username_0 on 2016-03-16)

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?

**Tags:** opengl, raytracing, rendering, shader, transformations


---

## 2 answers

### Answer by username_2 on 2016-03-16. Score: 20 | Accepted answer

[![enter image description here](https://i.sstatic.net/o7MUP.png)](https://i.sstatic.net/o7MUP.png)

**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.

[![enter image description here](https://i.sstatic.net/5HSkc.png)](https://i.sstatic.net/5HSkc.png)

**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.

[![enter image description here](https://i.sstatic.net/SyZdy.png)](https://i.sstatic.net/SyZdy.png)

**Image 3:** Shadow function biased (offset) forward.

> **Comments:**
> **username_0**: And this discrete nature of depth map is created because of floating point precision. Right?  
> **username_2**: No its created because images are discrete as in have only one value for a area that varies.  
> **username_0**: Images are different in camera and light space?  
> **username_0**: Ok is that zigzag line represents depth map?  
> **username_2**: It represents the function of the depth map, the dashed lines represent the pixel samples of the depth map.  
> **username_0**: 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?  
> **username_2**: Yes you got it.  

---

### Answer by username_1 on 2016-03-17. Score: 10

As an addition to the answer of username_2:
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

[![Sample image that has Peter Panning](https://i.sstatic.net/mdoX0.png)](https://i.sstatic.net/mdoX0.png)

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.

[![Scene with thick geometry and thereby no Peter Panning](https://i.sstatic.net/TwFxZ.png)](https://i.sstatic.net/TwFxZ.png)

Both images are taken from [this tutorial](http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/) where you can also learn more about how shadow mapping works, how shadow acne is created and solved and what Peter Panning is.

> **Comments:**
> **username_2**: One can also be more clever and render mid distance maps.  
> **username_3**: I 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](http://movies.stackexchange.com/q/13552/15400).  
> **username_1**: @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.  

---

