How do get the optimal peter-panning offset using shadow resolution?

Started by
1 comment, last by white waluigi 9 years ago

I'm currently working on a dynamic shadow system using depth shadows and deferred shading (light volumes).

The current problem is, that I get shadow acne, meaning theres faulty shadowrings in places, that are completely lit.

Is solved this problem somewhat by putting in a peter-pan offset (I multiply the shadow maps depth by 1.03 in order to get an offset that gets biger with distance) to the depth comaprison in order to get rid of them.

But the current problem is that with shadows with lower resolutions, I still get artifacts and with shadows with higher resolution I get inaccurate shadows, because of the peter-panning.

So is there an algorithm that lets me estimate the required offset considering distance from light and shadow resolution?

Advertisement

Just a small hint here (e.g. how I solved it at one point, and the solution was good enough for me) - when you use enclosed objects, it might be enough to just render back faces into shadow map - that way you would get shadow acne only on faces that are facing away from light (but obviously they won't be hit by direct light from that light).

As for your original question, each shadow caster in my engine has its own offset (which allows you to set these values per-shadow-caster). Within WYSIWYG-like editor, it is pretty enough; so in my case you can determine the value by try & fail.

The value calculated from the following - each shadow caster has range (far - near), and precision (determined by your depth map precision, beware using just floating point value means your precision is not linear on whole scale ~ it will be a function based on the actual distance from your light, e.g. not constant), you can determine the following - if you increase your stored depth value by smallest value you can, how many units in space you "walk away" from light. Based upon this, you can determine the offset to apply on real depth value you are comparing to projected depth map.

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

Backfaceculling worked like a charm (except on very thin objects)

I will experiement with that a little bit more, maybe I need to ignore the shadow if the depth difference is not big enough.

I probably do it similarly to your solution, by using a minimal difference instead of an offset.

Thx alot

This topic is closed to new replies.

Advertisement