Page 1 of 1

leakage in backface shadow mapping

Posted: Fri Jan 08, 2010 2:35 pm
by sparkprime
Rendering backfaces does avoid you having to play the bias game, where you have shadow acne one minute and disconnected shadows the next... But how does one avoid this effect:

(PCF etc turned off for clarity)

Image

One can add a negative bias but that makes the shadow leak out onto the front faces, I can give a screenshot of that if needed.

Re: leakage in backface shadow mapping

Posted: Fri Jan 08, 2010 4:28 pm
by sinbad
Yep, well aware of this: PCF tends to hide it fairly well though.

One way is to use front-casting but use biasing - usually you need a fixed bias and a slope-scale bias to get the best effect.

Another way is to use the a slope-scaled negative bias on the backface casting, ie larger -ve bias for the faces that are most perpendicular to the light direction.

Using linear depth is of course essential if you want consistent results.

Re: leakage in backface shadow mapping

Posted: Fri Jan 08, 2010 11:32 pm
by sparkprime
I'm using linear depth, it's a big help.

Bias doesn't work so well with backfaces though, here's a with + without, note the spilling of shadow at the top of the box now:

Image
Image

Is this your experience too?

How do you do the slope scale bias? Previous I have done something like this

bias = a + b / L

where L is the normal dotted with the light direction, i.e. from the diffuse lighting equation.

Front face shadow casting doesn't have the problem illustrated in the screenshots because it's hidden underneath the object where you can't see it, but choosing the bias is a horrible nightmare. A bias that works well from one angle doesn't work for another angle, and the bigger the PCF tap (in terms of area in texels covered) the bigger the bias has to be too. It's easy to end up with a bias that is too small from some angles (shadow acne) and too large from other angles (appearance of levitation). I wonder if lispsm is really worth it, for all the complications it causes with this kind of thing.

Re: leakage in backface shadow mapping

Posted: Fri Jan 08, 2010 11:38 pm
by sparkprime
Here is it with the PCF softening:

Image

I don't think it hides it that well, the crack is still very evident. This is a basic 3x3 tap with no spinning poisson discs or anything like that (just turned off, they don't make much difference to the appearance of the crack)

Re: leakage in backface shadow mapping

Posted: Fri Jan 08, 2010 11:52 pm
by sparkprime
Hmm with a 1cm bias I can avoid both the bleeding light and the bleeding shadow for the box, but I get the same artifact on the traffic cone still.

The traffic cone itself is a sealed mesh, but the cone part at the top is not sealed, which makes it different to the box/ground combination. When rendered with backfaces, this probably makes a big difference because you get some occluder polys that are more central to the mesh. I wonder if this is just a matter of getting the content right... Adding more polys on the inside of models where there are concave edges...

Putting constraints like this on artists is not ideal though. And it makes it much harder to take free models from the internet, etc.

Re: leakage in backface shadow mapping

Posted: Sun Jan 10, 2010 9:52 am
by sparkprime
I tried out the change to the geometry, it did work but caused the shadow to leak out the other side so it's not a net gain:

Image

No amount of bias fixes this either.

I'm now thinking that I should just forget about bias and do some SSAO to fill in the gaps instead.

Re: leakage in backface shadow mapping

Posted: Sun Jan 10, 2010 4:32 pm
by sinbad
Yeah, SSAO tends to fill these gaps.

Did you try front-casters option? Another trick you can use, which only works with front-casters, is to fade out the shadow within a very small threshold between the caster and receiver ("fuzzy test") which tends to reduce edge case problems.

Re: leakage in backface shadow mapping

Posted: Sun Jan 10, 2010 6:50 pm
by sparkprime
I used front casters for a long time, but I could never find a suitable bias... It was a nightmare, spent ages tuning and there were still odd angles where it didn't work properly.

How do you do the slant bias exactly?

Re: leakage in backface shadow mapping

Posted: Mon Jan 11, 2010 4:06 am
by mkultra333
I found all the tweaking needed to try and get these type of shadows working was a pain, and always ended up failing at some stage. I was much happier once I moved to VSM shadows. No need to worry about casters and receivers, rendering backfaces or tweaking biases (apart from the epsilon.)

Re: leakage in backface shadow mapping

Posted: Mon Jan 11, 2010 9:06 am
by sparkprime
It is tempting but what about the other artifacts you get with VSM, the ones where there are two occluders behind each other or something like that?

What does it take to implement VSM in OGRE? Is there any plan to include it as part of the supplied implementations? The trickiest bit would be building the mipmaps between the caster and receiver phase, presumably? Other than that it's just MRT for the caster and shader magic in the receiver?

Re: leakage in backface shadow mapping

Posted: Mon Jan 11, 2010 12:43 pm
by sinbad
I've always wanted to try using ESM (http://www-flare.cs.ucl.ac.uk/staff/J.K ... m_gi08.pdf) but never got around to it. It's not that hard to add the gaussian phase, you can just apply a compositor to the shadow texture to do it (I've done basic colour shadow blurring that way before).

Here's a VSM & PSSM example from our own forums: http://www.ogre3d.org/forums/viewtopic.php?f=1&t=46819

I'd like to include examples like this but I just haven't had time.