Jump to content
  • Advertisement
Sign in to follow this  
PfhorSlayer

Shadow mapping issue

This topic is 5408 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'm trying to do shadow mapping with the ARB_shadow extension, but I'm having some problems. Here's an example: It's falsely shadowing lots of areas, though the "real" shadows are working just fine. I've heard there's something I can do with offset/biasing something or other, but I'm not sure what to do or how to do it. Any help would be greatly appreciated!

Share this post


Link to post
Share on other sites
Advertisement
Don't know much about shadowing, but that wierd effect you've got there is a moire pattern. It usually comes from a super-high-detail pattern getting re-aliased into screen pixels. What that means is that your light areas are probably getting some sort of every-other-pixel fishbone shadow pattern. HTH.

Share this post


Link to post
Share on other sites
It's quite obvious where the scene you are using to test your implementation comes from - a popular shadow mapping tutorial.

Does the tutorial use a polygon offset? Or does it do something else to avoid using it?

Share this post


Link to post
Share on other sites
yeah, I got the scene from Paul's Projects back when I was implementing shadow mapping on my GF2MX (no ARB_shadow! Also no crazy issues like this...).

I just checked his code, and it does nothing with the offset stuff. The exe also doesn't run on my computer for some reason, so I don't know if his code has the same issue that mine does.

Share this post


Link to post
Share on other sites
Yeah, that's the usual bias issue with shadow mapping. Since the sampling positions of the shadow texture don't exactly match those used when rendering the scene, you get numerical imprecision issues, where sometimes the surface is slightly in front of iteseld, and sometimes slightly behind.

You can either do "second depth" shadow mapping, where you disable drawing front faces into the shadow buffer (glCullFace( GL_FRONT ); glEnable( glCullFace ); ), or you can use glPolygonOffset when drawing the shadow buffer to push them all slightly deeper.

Or write a fragment shader to take the average of the first and second depth. Works the best of the three, in my experience.

Share this post


Link to post
Share on other sites
I feel really stupid. :(

I took another look at Paul's code, and realized that I never turned on face culling. Turning it on eliminated the problems :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if not then see if you are clearing the depthbuffer without hvaing depth test enabled :) i had a gf2mx once and it did nearly the same thing as yours if i was trying to do that..

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!