Original Post
I´m developing a project for which i need very very hard shadows, like stencil-volumes hard, but using shadowmaps. I´ve been toying around with the idea of generating 2d distance fields from shadowmaps and using them to perform the shadow test. Right now, this is my method: 4 averaged custom bilinear filtering taps on 4 different shadow test results to generate a pseudo-distance field. The output looks a lot like 3x3 bilinear filtered pcf. Then i alpha test it (>=0.5?) to obtain the final shadow.
The image shows a 512x512 shadowmap. The results are ok for my needs, although since it is not a true distance field, small "wavy" artifacts can be seen on the edges of the shadow (highlighted in red). It naturally eliminates all self-occlusion artifacts due to the alpha-testing, though. But of course, the shadow jitters when moving, because of the low shadowmap resolution, but that can´t be helped. Here´s where i need a bit of help to get it 100% right: Does anyone know a good way (...or any way :( ) of generating a true distance field from a relatively low res bilinearly filtered input, so that the wavy artifacts disappear? Has anyone tried this before and managed to get it working properly? I was thinking of a method that involved using a variation of marching squares on the shadow map instead of bilinear filtering, then computing distance to the resulting segments. But it will look too "segmented" and probably be very slow too. Bilinearly filtering the shadow test twice might give good results too, but it is also an ugly hack. Some ideas?
The image shows a 512x512 shadowmap. The results are ok for my needs, although since it is not a true distance field, small "wavy" artifacts can be seen on the edges of the shadow (highlighted in red). It naturally eliminates all self-occlusion artifacts due to the alpha-testing, though. But of course, the shadow jitters when moving, because of the low shadowmap resolution, but that can´t be helped. Here´s where i need a bit of help to get it 100% right: Does anyone know a good way (...or any way :( ) of generating a true distance field from a relatively low res bilinearly filtered input, so that the wavy artifacts disappear? Has anyone tried this before and managed to get it working properly? I was thinking of a method that involved using a variation of marching squares on the shadow map instead of bilinear filtering, then computing distance to the resulting segments. But it will look too "segmented" and probably be very slow too. Bilinearly filtering the shadow test twice might give good results too, but it is also an ugly hack. Some ideas?
