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:
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:
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?