Sign in to follow this  
Dizzy_exe

precision problems with VSM

Recommended Posts

Hi, I have implemented Variance Shadow Mapping with 16-bit floating point textures for a directional light, but I have severe precision problems when the shadow caster and shadow receiver are very close. My depth range is 2000 and I use and orthogonal projection matrix which maps the depth values between 0 and 1. At a distance of 500 everything look excellent, but when the objects are less than 100 units apart white lines appear through the shadows (I guess because of big relative variance in depth values). How can I resolve this issue?

Share this post


Link to post
Share on other sites
The easiest solution is just to use 32-bit floats, but that may not be feasible depending on your target hardware.

Some things to verify:

1) Use a linear depth metric. For a directional light, "z" is already linear though.

2) Constrain light distances as much as possible, and map the resulting range into [-0.5, 0.5] or [-1, 1] (to use the sign bit). Every bit that you can constrain these near and far ranges gains more precision.

3) Play with the vsm_epsilon (or minimum variance). Decrease it as much as possible before artifacts appear. It's usually not very finicky so it's easy to find a good value.

4) Try the distributed precision trick that I described in my GDC presentation last year (available from nvidia.com) - and in GPU Gems 3 chapter.

5) Try using fixed-point 16-bit formats if supported by your hardware. Naturally then you should map values to [0, 1].

Hopefully those suggestions help, but do note that 16-bits is barely sufficient for standard shadow mapping and may well not be enough for VSM depending on your scene.

Share this post


Link to post
Share on other sites
Hi,

Thank you for answering.
I have a GeForce 6600 so 32 bit floating point is not an option.

1) done (I use an orthographic projection matrix for the light)
2) I tried that, the difference is hardly noticeable when fragment is near occluder
3)To do
4) I tried that, doesn't seem to make too much of a difference (maybe I'm doing it wrong?)
5)To do

The thing is I saw a couple of VSM demo implementation and, although all of them had artifacts, none were as severe as mine are. I seem to miss a crucial point in the implementation and I don't have any idea which is it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dizzy_exe
The thing is I saw a couple of VSM demo implementation and, although all of them had artifacts, none were as severe as mine are. I seem to miss a crucial point in the implementation and I don't have any idea which is it.

Are you seeing floating-point-like "moire" patterns and noise or just fading to white? If the former, you're truly seeing numeric problems, but if the latter you've probably just mis-set one of the parameters, like vsm_epsilon, or chosen an excessively poor depth mapping (which doesn't sound like it to me from your description).

Distributing precision should make a *big* difference (usually 6-8 bits!), and constraining the light range should also help quite a bit. If these two aren't doing anything, perhaps it isn't actually numeric problems you're seeing. To make sure, use FP32 even without filtering and see if the problem still occurs. If it does, it's almost certainly not a numeric issue.

Share this post


Link to post
Share on other sites

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