Deferred Shadows and precision

Started by
1 comment, last by skytiger 11 years, 11 months ago
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):

7Pj81.jpg


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


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
Advertisement
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
in depth discussion:
http://mynameismjp.wordpress.com/2010/09/05/position-from-depth-3/

my way:
http://skytiger.wordpress.com/2012/03/17/deferred-shading-with-reflections/

This topic is closed to new replies.

Advertisement