Jump to content
  • Advertisement
Sign in to follow this  
myers

PCSS - unusable?

This topic is 3756 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It seems to me there's a fundamental problem with Percentage Closer Soft Shadows, which makes them unsuited to all but the simplest scenes. For those who are unfamiliar with the algorithm, it's described in this paper. Basically you average the depth values in a particular area of the shadow map, and then perform standard PCF using a kernel size based on that average. In theory, this makes shadows appear "softer" the further they are from an occluder. The problem occurs when a shadow receiver is occluded by more than one shadow caster. Because the shadow map will contain only the depth of the nearest occluder to the light, any more distant occluders will effectively be ignored. This means that shadows' softness will only be "correct" for receivers that are occluded by one caster: a pretty major drawback. This is similar, I think, to the "light bleeding" artifact in Variance Shadow Maps. The only ideas I can think of to solve this are to use very small penumbrae so you don't notice any inaccuracies (which pretty much negates the whole point of PCSS); or somehow use a "deep" shadow map, with the depth of each occluder stored in a different component (which would be costly, horrible to implement, and would *still* break at a certain number of overlapping occluders); or have a shadow map per caster. But I haven't seen this problem mentioned in any discussions of PCSS, which makes me wonder if I'm missing something obvious. Am I? Is there a simple solution? Otherwise, it seems to me that PCSS is unusable.

Share this post


Link to post
Share on other sites
Advertisement
"Each shadow map"? How do you mean? There is only one shadow map.

Do you mean, have one per caster? That stops PCSS being a general solution, and certainly rubbishes Nvidia's claim, in the paper I linked to, that it "seamlessly replaces a traditional shadow map query" and is "independent of scene complexity". If there's no straightforward way around this, PCSS is in fact highly dependent on scene complexity. Are Nvidia just plain wrong?

Share this post


Link to post
Share on other sites
I haven't read the paper, but I think I get the idea from what you're describing. And I don't think it matters. Pretend that I'm a light, and I'm looking at an occluder and a receiver (behind the occluder). To the limits of what we're trying to simulate here, the size of the penumbra is entirely determined by the distance to the closest occluder and the receiver. The fact that there might (or might not) be another 100 objects between those two seems (to me) irrelevant. Put another way, how would you expect the shadows to change due to a second occluder which is, itself, occluded?

Share this post


Link to post
Share on other sites
Quote:
Original post by osmanb
I haven't read the paper, but I think I get the idea from what you're describing. And I don't think it matters. Pretend that I'm a light, and I'm looking at an occluder and a receiver (behind the occluder). To the limits of what we're trying to simulate here, the size of the penumbra is entirely determined by the distance to the closest occluder and the receiver. The fact that there might (or might not) be another 100 objects between those two seems (to me) irrelevant. Put another way, how would you expect the shadows to change due to a second occluder which is, itself, occluded?


I would expect the penumbra to be correct for the nearest occluder to the receiver, not the nearest occluder to the light. If a second occluder is occluded, then to be visually correct, the penumbra should "restart" at that occluder.

Imagine a big tower casting a shadow on a small hut, which is within the penumbral region of the tower's shadow. Any shadows cast by the hut will look very soft, because they're far away from the nearest occluder to the light (the tower) - but they should in fact be hard, because they're near to the hut.

Here's a visual example - the sun shining on a large rectangle, behind which is a small triangle:



The shadow cast by the triangle should be hard, because the receiver (the ground) is so close. But because the shadow map contains the depth values of the large rectangle (which is far from the receiver), not the triangle, the shadow is soft - until the point at which the occluders are no longer overlapping, and only the triangle is between the light and the ground. At this point, the triangle's shadow suddenly becomes hard again, resulting in a discontinuity. Clearly this is not a minor inaccuracy that we can just live with - it looks pretty terrible, and far worse cases could be constructed.

As I say, Nvidia are so insistent that PCSS maps seamlessly onto a vanilla shadow map implementation that I must, surely, have misunderstood something. But I can't see what!

[Edited by - myers on August 3, 2008 2:09:52 PM]

Share this post


Link to post
Share on other sites
The screen shot you've posted is a pathological case, and frankly does look like a "minor inaccuracy". I'm surprised it handles it that well... Your reaction seems oddly extreme, because the benefits of the method appear to outwiegh the small problem in the extreme cases.

That said, Its almost inconceivable that any of these soft shadow mapping methods are going to be perfect; all have flaws..PCSS seems to have fewer than VSM and EXPSM.

Share this post


Link to post
Share on other sites
Quote:
Original post by Matt Aufderheide
The screen shot you've posted is a pathological case, and frankly does look like a "minor inaccuracy". I'm surprised it handles it that well... Your reaction seems oddly extreme, because the benefits of the method appear to outwiegh the small problem in the extreme cases.

It barely handles these cases 'well' - it fails like this even for small occluders that are behind each other with a slight offset, the penumbra estimation fails to produce correct (or at least visually pleasing) results.
Quote:

That said, Its almost inconceivable that any of these soft shadow mapping methods are going to be perfect; all have flaws..PCSS seems to have fewer than VSM and EXPSM.


You can't compare PCSS to VSM, since PCSS is a different usage method for PCF, and can in much the same way be applied to VSM (VSMSS).

Share this post


Link to post
Share on other sites
Quote:
Original post by Matt Aufderheide
The screen shot you've posted is a pathological case, and frankly does look like a "minor inaccuracy". I'm surprised it handles it that well... Your reaction seems oddly extreme, because the benefits of the method appear to outwiegh the small problem in the extreme cases.


I don't think this is a pathological example at all. In fact, I'm kind of regretting posting it, because it's probably about as minor as the artifact gets and makes the problem look less severe than it actually is. In a scene as simple as that, it's not a big deal, but in an even slightly more complex one it would be.

Consider my example of a hut which falls within the penumbra of a shadow cast by a distant tower. All shadows within that hut will use such a large PCF kernel that they'll be effectively invisible. If you have a detailed room inside that hut, it'll look like none of the objects in it are casting shadows. The same goes for shadows cast by the hut itself: the whole room will be lit as if it was outside, because the shadow cast by the hut's ceiling and walls will be basically invisible. Remove that distant tower, and suddenly the room goes dark.

Or what if the room is half inside the tower's penumbra, and half outside. Half of the room will be illuminated by the sun while the other half will be dark.

Or forget the tower, and just imagine an enclosed room, with a light in the street outside. The room is dark because it's enshadowed by its walls and ceiling. Suddenly, someone walks past the building, between the room and the light. Inside the room, a person-shaped "patch" of light moves across the darkness of the room.

It's easy to see the major issues that could result in a city scene, with lots of buildings casting shadows on each other. The only way to reduce it to a "minor inaccuracy" is to make all penumbrae very small, but then the visual benefit of PCSS is almost insignificant.

Quote:
Original post by rozz666
myers, could you add some jitter to your shadows? It should reduce banding.


I suppose it's a matter of taste: I've always thought jittered shadows look too grainy and actually worse than banding, which is pretty unnoticeable when shadows are cast on a high-res textured surface (unlike the extremely low-res texture I used in the pic). Anyway, I think it's much less of an issue (and solveable by brute force) than the PCSS artifacts!

Share this post


Link to post
Share on other sites
Quote:
Original post by myers
Quote:
Original post by Matt Aufderheide
The screen shot you've posted is a pathological case, and frankly does look like a "minor inaccuracy". I'm surprised it handles it that well... Your reaction seems oddly extreme, because the benefits of the method appear to outwiegh the small problem in the extreme cases.


I don't think this is a pathological example at all. In fact, I'm kind of regretting posting it, because it's probably about as minor as the artifact gets and makes the problem look less severe than it actually is. In a scene as simple as that, it's not a big deal, but in an even slightly more complex one it would be.

Consider my example of a hut which falls within the penumbra of a shadow cast by a distant tower. All shadows within that hut will use such a large PCF kernel that they'll be effectively invisible. If you have a detailed room inside that hut, it'll look like none of the objects in it are casting shadows. The same goes for shadows cast by the hut itself: the whole room will be lit as if it was outside, because the shadow cast by the hut's ceiling and walls will be basically invisible. Remove that distant tower, and suddenly the room goes dark.

Or what if the room is half inside the tower's penumbra, and half outside. Half of the room will be illuminated by the sun while the other half will be dark.

Or forget the tower, and just imagine an enclosed room, with a light in the street outside. The room is dark because it's enshadowed by its walls and ceiling. Suddenly, someone walks past the building, between the room and the light. Inside the room, a person-shaped "patch" of light moves across the darkness of the room.

It's easy to see the major issues that could result in a city scene, with lots of buildings casting shadows on each other. The only way to reduce it to a "minor inaccuracy" is to make all penumbrae very small, but then the visual benefit of PCSS is almost insignificant.


Maybe use some kind of a feedback. It may be very slow, but you could try it. When you take samples from the shadowmap, adjust the kernel size. Start with a size determined by your first sample and then if you find a sample that is closer, reduce the size accordingly.



[Edited by - rozz666 on August 3, 2008 5:59:07 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!