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.

leakage in backface shadow mapping

Postby sparkprime » Fri Jan 08, 2010 2:35 pm

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
sparkprime
Ogre Magi
 
Posts: 1132
Kudos: 19
Joined: 07 May 2007
Location: Ossining, New York

Re: leakage in backface shadow mapping

Postby sinbad » Fri Jan 08, 2010 4:28 pm

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
sinbad
OGRE Founder (Retired)
OGRE Founder (Retired)
 
Posts: 25870
Kudos: 63
Joined: 06 Oct 2002
Location: Guernsey, Channel Islands

Re: leakage in backface shadow mapping

Postby sparkprime » Fri Jan 08, 2010 11:32 pm

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: 1132
Kudos: 19
Joined: 07 May 2007
Location: Ossining, New York

Re: leakage in backface shadow mapping

Postby sparkprime » Fri Jan 08, 2010 11:38 pm

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: 1132
Kudos: 19
Joined: 07 May 2007
Location: Ossining, New York

Re: leakage in backface shadow mapping

Postby sparkprime » Fri Jan 08, 2010 11:52 pm

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: 1132
Kudos: 19
Joined: 07 May 2007
Location: Ossining, New York

Re: leakage in backface shadow mapping

Postby sparkprime » Sun Jan 10, 2010 9:52 am

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
sparkprime
Ogre Magi
 
Posts: 1132
Kudos: 19
Joined: 07 May 2007
Location: Ossining, New York

Re: leakage in backface shadow mapping

Postby sinbad » Sun Jan 10, 2010 4:32 pm

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
sinbad
OGRE Founder (Retired)
OGRE Founder (Retired)
 
Posts: 25870
Kudos: 63
Joined: 06 Oct 2002
Location: Guernsey, Channel Islands

Re: leakage in backface shadow mapping

Postby sparkprime » Sun Jan 10, 2010 6:50 pm

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
sparkprime
Ogre Magi
 
Posts: 1132
Kudos: 19
Joined: 07 May 2007
Location: Ossining, New York

Re: leakage in backface shadow mapping

Postby mkultra333 » Mon Jan 11, 2010 4:06 am

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
mkultra333
Beholder
 
Posts: 1541
Kudos: 64
Joined: 08 Mar 2009

Re: leakage in backface shadow mapping

Postby sparkprime » Mon Jan 11, 2010 9:06 am

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
sparkprime
Ogre Magi
 
Posts: 1132
Kudos: 19
Joined: 07 May 2007
Location: Ossining, New York

Re: leakage in backface shadow mapping

Postby sinbad » Mon Jan 11, 2010 12:43 pm

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: viewtopic.php?f=1&t=46819

I'd like to include examples like this but I just haven't had time.
User avatar
sinbad
OGRE Founder (Retired)
OGRE Founder (Retired)
 
Posts: 25870
Kudos: 63
Joined: 06 Oct 2002
Location: Guernsey, Channel Islands


Return to Developer talk

Who is online

Users browsing this forum: No registered users and 5 guests