Jump to content
  • Advertisement
Sign in to follow this  
asmCode

Shadow Mapping, dont understand linear filter for shadow map

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

If you intended to correct an error in the post then please contact us.

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
else
   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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!