Sign in to follow this  

Shadow Mapping, dont understand linear filter for shadow map

Recommended Posts

Hi guys, I understand idea of shadow mapping. Shadow map is used to determine if fragment of scene can see the light. It can see or not - true or false. In some articles they say, that if you want to have smooth shadows, you have to enable linear filter for shadow map. But this is nonsense for me, beucase shadow map has information about distance from light! You can't interpolate distances, cos you still have to check if fragment is in shadow or not - still true or false. This is my code in fragment program (Cg):
if (tex2Dproj(depthTex, texCoordsProj).x < (texCoordsProj.z / texCoordsProj.w))
   outColor = shadow
   outColor = not shadow
So what is the idea for using linear filter for shadows maps in shadow mapping algorithm? How it can be used to smooth shadows? greetz

Share this post

Link to post
Share on other sites
With normal shadow maps, it can't. However, there are some exceptions. The simplest way to filter shadow maps is to read from the shadow map in several (nearby) locations, and accumulate all of the true/false results. Then average those binary results. This is PCF filtering.

It's possible that you've seen people talking about certain NVidia hardware, which does this automatically if the texture that you're reading from has a depth format. Basically, the texture coordinates include the position AND the depth value to compare against. If you enable linear filtering, it reads four values from the texture, does the four comparisons, and then weights the results using normal bi-linear filtering.

If you use fancier shadow map techniques (like variance shadow mapping), then the information that's stored in the textures is no longer pure depth information, and it *can* be filtered.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this