0

I am currently implementing and modifing some alternative biasing solutions for shadow mapping. And I am of course combining them with different techniques for soft shadows.

And I am having some problems with the PCF. I am shadowing the backfaces of surfaces via testing if the dotproduct of the light direction and the normal of the fragment is greater than 0, therefore it can only be the backside of whatever. Works absolutly fine for hard shadows.

So basicly this line of code in my fragment shader shades the backfaces of any object:

 isLit= dot(lsFragNormal.xyz, lightViewPos.xyz) > 0.0f ? 0.0 : isLit;

and works as mentioned fine with hard shadows. When it comes to PCF, my first intention was to use this just as above, to check if the current texel in the filter kernel is in shadow or not. This is this statement for shadow testing the current texel of the PCF filter kernel:

if((currentDepth < shadowMapDepth) && !(dot(lsFragNormal.xyz, lightViewPos.xyz) > 0.0f ))

But then the "shadow edge" from the front of an object to back of an object is still a hard "shadow edge". This of course makes sense, since for any texel of the PCF filter kernel, always the normal of the current fragment is tested, and therefore if the fragment is on the backside of an object this fragment would completely be shadowed. But when I remove the "dot product test", on the fading from front to backside of an object I have problems with appearing artifacts, due to the grazing light.

With "dot product testing": As you can see, the shadow which is actually casted looks good, but the shadow that is on the backface of an object is a hard shadow: enter image description here

Without "dot product testing": The edge of the "backside shadow" starts to soften towards the light front, but then still ends in a hard edge. And you can also see some artifacts, which I guess come from the undersampling in that region: enter image description here

What could I do to get a good (or at least better) soft shadow on the edges of the "backside shadows"? Without introducting very complex algorithms like "queried virtual shadow maps", which would of course be the perfect solution for that case, but this is for interactive applications, so it is not possible to use a procedure like this.

Or do I simply not have a chance against aliasing like this for interactive applications.

And I am interested if you think the hard edge of the "backside shadows" would be accepable?

nurgan
  • 309
  • 1
  • 4
  • 22
  • Have you tried some simple interpolation from the edge to the inner part of the backfacing region? – Dragan Okanovic Jun 29 '14 at 14:35
  • Do do so, I would Need to know how far from the edge I am, to lets say interpolate from lit to shadowed over the 6 next fragments to the edge. But how can I know, since this is tested with the fragments normal, so to know how far from the edge I am I would need the normals of the neighbouring fragments (and I would introduce a lot of "dot product testing") – nurgan Jul 01 '14 at 11:45
  • Use dot product to interpolate along the backface region. You wouldn't use "distance" from edge, but orientation of the surface. It would probably suffer from weird behavior on really complex-looking objects, but that's another problem and the chances are small. – Dragan Okanovic Jul 01 '14 at 17:15

0 Answers0