Jump to content
  • Advertisement
Sign in to follow this  
DHCThrive

Shadow mapping depth bias for slopes?

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

Recently, I managed to apply shadow mapping to my terrain project.  However, it came with a few side effects, mainly, it suffered from shadow acne.  I solved most of this by changing the rasterizer state to CULL_FRONT on the shadow pass, however, it did not solve the shadow acne on the slopes of the terrain.

 

I'm not entirely sure how to remove the shadow acne from the slopes of the terrain.  I did a bit of searching and a slope based bias is recommended, however, I couldn't find anything on how to actually implement that.  You can see the issues I'm experiencing below:

 

WmjeF.png

 

ytcPS.png

 

Thank you for any help.

Share this post


Link to post
Share on other sites
Advertisement

Thanks for that, unfortunately I recently tried this and it appears to offset it more and causes serous peter panning.  I don't think bias is the way to go anymore since the terrain is also generated randomly.  So I could get a good set of bias values for a certain seed for it to be causing issues for another.

 

I've also attempted normal offsetting and changing CULL modes, which gets rid of the shadow acne on somewhat flat surfaces.  However, the slope shadow acne is persistent. 

Edited by DHCThrive

Share this post


Link to post
Share on other sites


I don't think bias is the way to go anymore since the terrain is also generated randomly.

 

Randomness is wholly unrelated to depth biases. You should definitely be able to bias it away regardless of how you make your terrain. The problem is that the more you bias it, the more peter panning artifacts you end up with. Normal offsetting will also easily eliminate acne but changes the size and shapes of your shadows. There's no perfect shadow solution really, just good compromises for a given situation that are unlikely to break down.

Share this post


Link to post
Share on other sites
I have personally had some success using Normal Offset Shadows, but there is no panacea and the different approaches all work better or worse in different use cases, with different geometries.

As Dingleberry says, there is no perfect solution, just a case of trying to minimize the artifacts in your particular use case.

Share this post


Link to post
Share on other sites

I ended up using normal offset shadows, then adding a small optimization whereby I simply say 'if the normal is facing away from the light, it's a shadow'.  I then also implemented PCF.

 

Results ended up quite nice:

 

EaAJbIu.png

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!