PCF enigma

Started by
1 comment, last by bzroom 15 years, 1 month ago
hello, I have this question about Percentage closer filtering. I have implemented the algorithm but I do not know how it can actualy work. all it does is that it averages values of pixels in depth map and uses this averaged value as a shadow factor? I have implemented the algorithm and that's all it does. It takes 4 pixels from depthmap, adds them together and multiply by 1/4 and thus we have a shadow factor? I really do not get it. But it works... but how? I need to understand becouse the artefact of PCF for me is that the areas that are further in depth map, thus having higher depth value, are lighter than areas closer in depth map, and also it results in shadow variance as my shadow map changes. Also areas close to occluder are lighter then those far from occluder. What could be the work around?
Advertisement
This might be what your intuition tells you to do but it's not it.
You should take 4 samples from your depthmap. Then do 4 seperate Z tests on that 4 samples and then you count those samples that have passed and divide by 4. That's where "percentage" comes from, percentage of samples that are visible. With what you're doing now you just get a "better" depth value which is useless.
You are going to see the varying artifacts as your shadows move, this is an unfortunate side effect of bluring your shadows with a small kernel. Maybe if you use a larger kernel, like 9x9 you won't notice as much? Also, i think it's common to move your shadow map in such an interval that the kernel sampling will align from frame to frame. This will hide the effect as your shadow map moves around the scene.

PCF works very intuitively to blur the edge of a shadow. It's just like sampleing the edge of any mask, you'll end up with some percentage of mask coverage.

Another little trick you can do with PCF is expand the kernal size with depth.. this should blur out your shadows as they get further from the ocluder. Maybe.. maybe that work's a bit differently. Don't quote me on any of this :)

Some reading:
http://developer.download.nvidia.com/shaderlibrary/docs/shadow_PCSS.pdf from http://blog.makingartstudios.com/?p=9

This topic is closed to new replies.

Advertisement