# PCF enigma

This topic is 3444 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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.

##### Share on other sites
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 :)

1. 1
2. 2
3. 3
4. 4
frob
11
5. 5

• 11
• 16
• 13
• 20
• 12
• ### Forum Statistics

• Total Topics
632174
• Total Posts
3004580

×