<p>PCSS is looking less attractive as a real time shadowing technique since it has limited performance, largely due to the size of the shadow map and the number of samplers that must be taken in order to get acceptable results. I would recommend implementing it anyway largely because the same techniques are used in other shadow generation algorithms and it is very well documented, so it is easy to find information that will help you out if you run into an issue. Also, there are plenty of use cases where PCSS is &quot;good enough&quot; so you can spend your energy on other aspects of your application. Especially given the wide range hardware that any given game can find itself running on. A high end machine with PCSS may not be &quot;the best use of resources&quot; but it certainly gives extra bang for the rendering buck.</p>
<p>Also, once implemented, it isn't to difficult to migrate it to another algorithm like VSSM (Variance Soft Shadow Mapping) which requires 32bit buffers but allows for the use of smaller shadow maps. But VSSM isn't documented as well so it is more difficult to write from scratch. Nvidia has a good paper on the subject:<a href="http://developer.download.nvidia.com/SDK/10/direct3d/Source/VarianceShadowMapping/Doc/VarianceShadowMapping.pdf" rel="nofollow noreferrer">Link to Nvidia VSSM Paper</a>. They also have an application with code so you can compare the two algorithms side by side.</p>
<p>The book Real-Time Shadows is a good reference for shadow mapping. And can usually be picked up used for a reasonable price.</p>

CC BY-SA 4.0
2020-07-14T16:46:25.173Z
2020-07-14T16:46:25.173Z
pmw1234
<p>For light sources with larger solid angle and where the shadow caster is relatively closer to the light than the receiver, you get notable soft shadowing effect. So if you render larger light sources closer to the shadow receiver it's important to handle soft shadows properly for realistic lighting. Even with the Sun which has quite small solid angle, you can still see fairly large penumbras from tall buildings.</p>

<p>PCSS is fairly simple algorithm for implementing contact hardening shadows, but it has some notable issues. PCSS fails when you have soft and hard shadows intersecting (blocker search fails), so it's not a good algorithm to use when large penumbras are needed. See in the below image where shadows from the box &amp; triangle intersect. This artifact is particularly disturbing when animated.</p>

<p><a href="https://i.sstatic.net/VQ4ln.png" rel="noreferrer"><img src="https://i.sstatic.net/VQ4ln.png" alt="PCSS artifact"></a></p>

<p>There's a family of <a href="http://www.labri.fr/perso/guenneba/docs/SoftShadowMapping-egsr06.pdf" rel="noreferrer">"back-projection" shadow techniques</a> though, which is able to handle larger penumbras. However, there's a little research done how to implement this efficiently for real-time applications that I'm aware of.</p>

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

<p>In back-projection the principle idea is to project shadow map texels to the light source for every pixel to calculate light occlusion, which when implemented naively is obviously extremely slow and furthermore introduces shadow gaps &amp; overlaps. However, there are some techniques to try to avoid the artifacts, such as adjusting the microquad extents as shown below.</p>

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

<p>Another improvement to handle the gaps and overlaps is to use <a href="http://research.michael-schwarz.com/publ/files/bmss-eg07.pdf" rel="noreferrer">bitmask soft shadowing</a> algorithm, where occlusion bitmask determines the occluded areas of the light source.</p>

<p>The most recent paper I have seen on the topic is "<a href="http://www.geomerics.com/wp-content/uploads/2014/03/AltDevConf-SamMartin-RealTimeAreaLighting.pdf" rel="noreferrer">Real Time Area Lighting. Now and Next</a>" by Sam Martin from 2012, where the cost was several milliseconds for a single light, but it's definitely worth the read if you are interested of the topic, to get general idea about the state-of-the-art real-time shadow techniques.</p>

CC BY-SA 3.0
2016-10-22T03:52:07.037Z
2016-10-22T03:52:07.037Z
JarkkoL
<p>Currently I have basic shadow mapping setup in my engine. I am currently trying to implement something more realistic like <strong>PCSS</strong> (percentage closer soft shadows), to get a more physically accurate result just like the image below. (See how the shadow becomes softer &amp; softer towards the end?)</p>

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

<p>My 2 questions are:</p>

<p><strong>1)</strong> Is it worth implementing a shadow mapping technique like this? <strong>Will people actually notice the difference?</strong></p>

<p><strong>2)</strong> If it is worth it, what are some resources where I can learn more about it? What are the <strong>major techniques like PCSS?</strong></p>

CC BY-SA 3.0
2016-10-18T02:29:45.093Z
What is your use case? Are you working on a game? Photo-realistic rendering for cinema? CAD? That makes a huge difference to whether people will notice or not.
user1118321
CC BY-SA 3.0
2016-10-18T05:33:41.820Z
This is for a game but do people anyway notice it in a CAD Visualization or in Cinema Rendering?
Arjan Singh
CC BY-SA 3.0
2016-10-18T16:19:55.693Z
Certainly in cinema rendering it would be noticeable, especially if it was mixed with live action footage. For CAD, it would probably be desired for renderings shown to, say, an architectural client, but probably not as necessary when doing the modeling, I would think. Most games I've played have not had the greatest shadows. I usually notice, but don't know how much a typical person would. Anyway, I just wanted to clarify the use case because it can make a difference between whether you need realtime or not and what quality vs. time tradeoffs you might be willing to make.
user1118321
CC BY-SA 3.0
2016-10-21T03:09:10.190Z
_"Is it worth it?"_ entirely depends on *your use case*. You can (and should) look at what is done in products with a similar use case and set of constraints as yours, but in the end only you can make that decision.
Julien Guertault
<opengl><lighting><physically-based><shadow>
Better Shadow Mapping Techniques
Arjan Singh
# Better Shadow Mapping Techniques

(Asked by: username_0 on 2016-10-17)

Currently I have basic shadow mapping setup in my engine. I am currently trying to implement something more realistic like **PCSS** (percentage closer soft shadows), to get a more physically accurate result just like the image below. (See how the shadow becomes softer & softer towards the end?)

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

My 2 questions are:

**1)** Is it worth implementing a shadow mapping technique like this? **Will people actually notice the difference?**

**2)** If it is worth it, what are some resources where I can learn more about it? What are the **major techniques like PCSS?**

**Tags:** opengl, lighting, physically-based, shadow

> **Comments:**
> **username_1**: What is your use case? Are you working on a game? Photo-realistic rendering for cinema? CAD? That makes a huge difference to whether people will notice or not.  
> **username_0**: This is for a game but do people anyway notice it in a CAD Visualization or in Cinema Rendering?  
> **username_1**: Certainly in cinema rendering it would be noticeable, especially if it was mixed with live action footage. For CAD, it would probably be desired for renderings shown to, say, an architectural client, but probably not as necessary when doing the modeling, I would think. Most games I've played have not had the greatest shadows. I usually notice, but don't know how much a typical person would. Anyway, I just wanted to clarify the use case because it can make a difference between whether you need realtime or not and what quality vs. time tradeoffs you might be willing to make.  
> **username_2**: _"Is it worth it?"_ entirely depends on *your use case*. You can (and should) look at what is done in products with a similar use case and set of constraints as yours, but in the end only you can make that decision.  

---

## 2 answers

### Answer by username_4 on 2016-10-22. Score: 5 | Accepted answer

For light sources with larger solid angle and where the shadow caster is relatively closer to the light than the receiver, you get notable soft shadowing effect. So if you render larger light sources closer to the shadow receiver it's important to handle soft shadows properly for realistic lighting. Even with the Sun which has quite small solid angle, you can still see fairly large penumbras from tall buildings.

PCSS is fairly simple algorithm for implementing contact hardening shadows, but it has some notable issues. PCSS fails when you have soft and hard shadows intersecting (blocker search fails), so it's not a good algorithm to use when large penumbras are needed. See in the below image where shadows from the box & triangle intersect. This artifact is particularly disturbing when animated.

[![PCSS artifact](https://i.sstatic.net/VQ4ln.png)](https://i.sstatic.net/VQ4ln.png)

There's a family of ["back-projection" shadow techniques](http://www.labri.fr/perso/guenneba/docs/SoftShadowMapping-egsr06.pdf) though, which is able to handle larger penumbras. However, there's a little research done how to implement this efficiently for real-time applications that I'm aware of.

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

In back-projection the principle idea is to project shadow map texels to the light source for every pixel to calculate light occlusion, which when implemented naively is obviously extremely slow and furthermore introduces shadow gaps & overlaps. However, there are some techniques to try to avoid the artifacts, such as adjusting the microquad extents as shown below.

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

Another improvement to handle the gaps and overlaps is to use [bitmask soft shadowing](http://research.michael-schwarz.com/publ/files/bmss-eg07.pdf) algorithm, where occlusion bitmask determines the occluded areas of the light source.

The most recent paper I have seen on the topic is "[Real Time Area Lighting. Now and Next](http://www.geomerics.com/wp-content/uploads/2014/03/AltDevConf-SamMartin-RealTimeAreaLighting.pdf)" by Sam Martin from 2012, where the cost was several milliseconds for a single light, but it's definitely worth the read if you are interested of the topic, to get general idea about the state-of-the-art real-time shadow techniques.


---

### Answer by username_3 on 2020-07-14. Score: 2

PCSS is looking less attractive as a real time shadowing technique since it has limited performance, largely due to the size of the shadow map and the number of samplers that must be taken in order to get acceptable results. I would recommend implementing it anyway largely because the same techniques are used in other shadow generation algorithms and it is very well documented, so it is easy to find information that will help you out if you run into an issue. Also, there are plenty of use cases where PCSS is "good enough" so you can spend your energy on other aspects of your application. Especially given the wide range hardware that any given game can find itself running on. A high end machine with PCSS may not be "the best use of resources" but it certainly gives extra bang for the rendering buck.

Also, once implemented, it isn't to difficult to migrate it to another algorithm like VSSM (Variance Soft Shadow Mapping) which requires 32bit buffers but allows for the use of smaller shadow maps. But VSSM isn't documented as well so it is more difficult to write from scratch. Nvidia has a good paper on the subject:[Link to Nvidia VSSM Paper](http://developer.download.nvidia.com/SDK/10/direct3d/Source/VarianceShadowMapping/Doc/VarianceShadowMapping.pdf). They also have an application with code so you can compare the two algorithms side by side.

The book Real-Time Shadows is a good reference for shadow mapping. And can usually be picked up used for a reasonable price.


---

