Jump to content
  • Advertisement
Sign in to follow this  

Deferred Shadows and precision

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

Hi All!

I'm trying to reuse the g-buffer for computing a "shadows mask or buffer"; basically after computing the appropriate Shadows Map for a light (point,directional or spot) I just want to reuse g-buffer stored position for performing shadows check for shadows receiving geometry.

Now comes a little problem: If I just store world or view space position (viewpos.x,viewpos.y,viewpos.z) in the g-buffer everything is fine m3GMY.jpg

If I try to store just view space lenght and reconstruct position (just to save memory bandwidth), on shadows check I just got some artifacts almoust just on "caster" geometry and when the camera comes close to them (look at red circle):


in that case depth is stored like this:

float depth = length(ViewPos);

and reconstructed like this:

float3 ER = float3(vScreenCoord.x*gScreenRatio,vScreenCoord.y,1/(tan(gHalfFOV)));
float4 posView = float4(( normalize(ER) * g_buffer_depth),1.0f);

To solve the problem I've raise SHADOWS_EPSILON (or BIAS) value but this lead to other problems...so I'm wondering if someone can point me out where the problem can be.....it's just a numerical imprecision problem?

Any advice appreciated happy.png

Thanks Mauro

I've been using this reconstruction for deferred lighting in the past months without noticeable artifacts....but probably Shadows artifacts are more sensitive to numerical errors Edited by mauro78

Share this post

Link to post
Share on other sites
UPDATE: If I save on the g-buffer (better on a 32 bit target channel ) the projection space depth and then later reconstruct from projection space 2 world space I got some really nice results without any visible artifacts.

So now I'm guessing that storing the view space depth and reconstruct using trigonometric tan(half_FOV) function introduce some imprecision and possibly some instability.......at least when I perform some shadows test.

Wvp5x.jpg Edited by mauro78

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!