Better Shadow Mapping Techniques

Computer Graphics Asked by Arjan Singh on August 27, 2021

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

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?

2 Answers

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

There's a family of "back-projection" shadow techniques 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

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

Another improvement to handle the gaps and overlaps is to use bitmask soft shadowing 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" 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.

Correct answer by JarkkoL on August 27, 2021

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

Answered by pmw1234 on August 27, 2021

Add your own answers!

Related Questions

glutSolid* source code

1  Asked on November 22, 2021 by tado-mi


How to retrieve data from Compute Shader to CPU?

0  Asked on November 15, 2021 by ethan-ma


unwanted patterns in simplex noise

1  Asked on November 13, 2021 by sam-apostel


Procedural generation of biological models

1  Asked on November 13, 2021 by daniel-cooke


What method is used for baking grayscale curvature maps

1  Asked on November 10, 2021 by jummit


Why are texture coordinates often called UVs?

2  Asked on August 27, 2021 by samanthaj


Dynamic Ray-Triangle Intersection

1  Asked on August 27, 2021 by cemklkn


Draw Line on Arbitrary Surface

0  Asked on August 27, 2021 by valentin-molina


How to raytrace Bezier surfaces?

5  Asked on August 27, 2021 by luser-droog


Better Shadow Mapping Techniques

2  Asked on August 27, 2021 by arjan-singh


What does GPU assembly look like?

4  Asked on August 27, 2021 by sebastien-finor


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir