Jump to content
  • Advertisement
Sign in to follow this  
shirsoft

Jagged edges with shadow maps

This topic is 3611 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

I am currently working on a school game project. I am using shadowmaps for shadowing. Problem is that the shadow looks quite jagged and choppy even though I am using a 1024x1024 shadow map. I am not using any other kind of lighting in the shader not even N.L. The reason is that I have only one light source which is the sun and I thought that it might *not* make a big difference for the game.
  • Advertisement
    Post a screenshot. In general even higher resolution might not help you. You need to use techniques that will use your shadow map texture as efficient as possible, for sun I would shoose cascade/split shadow maps (google it). Another option is to use mentioned technique together with Percentage Close Filtering shadow maps or Variance Shadow maps, check them as well, you will get a much better understanding of the subject.

    Share this post


    Link to post
    Share on other sites
    A common source of heavy aliasing for first-time shadow mappers is using linear filtering instead of point filtering for depth textures. Linear filtering will screw up the depth-test equation, resulting in more aliasing instead of less. Note that I realize you already know of the other, more prevelant cause of aliasing: finite texture resolution. There exist a ton of techniques to remedy that (all with their respective pros and cons).

    Share this post


    Link to post
    Share on other sites
    Linear filtering just rounds off the corners, it doesn't normally affect the depth test very much.. nor does it create more jagged edges. So I disagree that this is a "source" of aliasing.

    Aliasing is caused by the fact that the projected shadow map covers more than one pixel in camera projection space.

    A number of complex methods exist to reduce aliasing. Using higher shadow map resolutions ALWAYS helps, but gets costly.

    The most common methods in modern games are matching the shadow frustum to the viewing frustum, reducing the shadowed area to only a relatively small area in front of the camera (reducing the z-value much closer than the camera z and then fading out the shadows at a distance), and using some form of frustum splitting.

    Frustum splitting, also called parallel split-frustum or cascading shadow maps is probably the most robust and straightforward technique, though it can be costly (because it involves rendering a number of shadow maps, depending on the number of splits). A good, easy to adapt, example for this exists on the web (I dont rememerb the link offhand)

    Share this post


    Link to post
    Share on other sites
    I am really sorry about the missing screenshot. Somehow my message got trucated when it got posted on the forums:( So well yeah here it is

    Screenshot

    Should I make the shadow map bigger? Move the sun with the player.
    Also how should I handle self shadowing for a human being. I have currently switched off as it looks really bad: My character is that of a small boy with a hat. When the sun is overhead, the hat casts a shadow which covers the entire body and so the boy looks black which is bad. Should I go for GI?
    Thanks

    Share this post


    Link to post
    Share on other sites
    That's not aliasing. What you're seeing there is artifacts due to lack of sufficient precision in the depth map. If you're using an RGBA texture, you may want to use a floating point texture, or if you're already using a 16 bit floating point texture, perhaps a higher precision format. There are other tricks which can help. You can try rendering your scene with front-face culling during the depth pass, as that can really help reducing artifacts, or you may need to look into adjusting the depth bias according to the slope of the surface. It's hard to say which you should do without knowing quite what you're doing already.

    Share this post


    Link to post
    Share on other sites
    As sybixsus said, it was indeed aliasing issue + front face culling. Also I added diffuse lighting & soft shadows. So now it looks nice

    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.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!