7
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – user1118321 Oct 18 '16 at 2:29
  • $\begingroup$ This is for a game but do people anyway notice it in a CAD Visualization or in Cinema Rendering? $\endgroup$ – Arjan Singh Oct 18 '16 at 5:33
  • 4
    $\begingroup$ 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. $\endgroup$ – user1118321 Oct 18 '16 at 16:19
  • $\begingroup$ "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. $\endgroup$ – Julien Guertault Oct 21 '16 at 3:09
5
$\begingroup$

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.

| improve this answer | |
$\endgroup$
2
$\begingroup$

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.

| improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.