Sign in to follow this  

Deferred Shadows and precision

This topic is 2044 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 [url="http://i.imgur.com/m3GMY.jpg"][img]http://i.imgur.com/m3GMY.jpg[/img][/url]

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):

[img]http://i.imgur.com/7Pj81.jpg[/img]


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 [img]http://public.gamedev.net//public/style_emoticons/default/happy.png[/img]

Thanks Mauro


p.s.
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 [b]I got some really nice results without any visible artifacts. [/b]

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.


[img]http://i.imgur.com/Wvp5x.jpg[/img] Edited by mauro78

Share this post


Link to post
Share on other sites
in depth discussion:
[url="http://mynameismjp.wordpress.com/2010/09/05/position-from-depth-3/"]http://mynameismjp.wordpress.com/2010/09/05/position-from-depth-3/[/url]

my way:
[url="http://skytiger.wordpress.com/2012/03/17/deferred-shading-with-reflections/"]http://skytiger.wordpress.com/2012/03/17/deferred-shading-with-reflections/[/url]

Share this post


Link to post
Share on other sites

This topic is 2044 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this