Shadow mapping depth bias for slopes?

Started by
6 comments, last by ExErvus 8 years, 4 months ago

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.

Advertisement

Found this for you:

http://www.gamedev.net/topic/662625-slope-scale-depth-bias-shadow-map-in-hlsl/#entry5191604

:D

.:vinterberg:.

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.


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.

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.

it might not be a perfect solution, but you could try running your shadow map through a PCF blur filter

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

Glad it turned out good for you =)

This topic is closed to new replies.

Advertisement