leakage in backface shadow mapping

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

leakage in backface shadow mapping

Post 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.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: leakage in backface shadow mapping

Post 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.
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: leakage in backface shadow mapping

Post 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.
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: leakage in backface shadow mapping

Post 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)
Last edited by sparkprime on Sat Jan 09, 2010 12:49 pm, edited 1 time in total.
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: leakage in backface shadow mapping

Post 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.
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: leakage in backface shadow mapping

Post 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.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: leakage in backface shadow mapping

Post 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.
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: leakage in backface shadow mapping

Post 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?
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: leakage in backface shadow mapping

Post 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.)
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
sparkprime
Ogre Magi
Posts: 1137
Joined: Mon May 07, 2007 3:43 am
Location: Ossining, New York
x 13
Contact:

Re: leakage in backface shadow mapping

Post 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?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: leakage in backface shadow mapping

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