Sign in to follow this  
Mchart

VSM without filtering the maps and easiest way to filter them

Recommended Posts

Mchart    130

Hi! 

 

I have finished right now to implement the VSM, they seem to work fine in terms of visibility, however I can't notice any improvement in quality if compared with the basic shadow map test (less than). Is this technique beneficial only if a pre-filtering of the maps is performed or I am doing something wrong? Is there a way to obtain a better result with them without using additional passes (e.g. a previous blur with a gaussian blur)? 

 

 

Thank you!

Share this post


Link to post
Share on other sites
kalle_h    2464

Prefiltering is just an optimization. You could use NxN sampling kernel with gaussian weights in your shadow shader. Try to also use bilinear filtering, You can also generate mipmaps and use trilinear/anistro filtering.

Share this post


Link to post
Share on other sites
Mchart    130

Prefiltering is just an optimization. You could use NxN sampling kernel with gaussian weights in your shadow shader. Try to also use bilinear filtering, You can also generate mipmaps and use trilinear/anistro filtering.

 

I am doing trilinear (GL_MIN and GL_MAG with GL_LINEAR and I generate mipmaps) but the result is somehow disappointing. I have no penumbra at all. 

I am using almost exactly the code here: http://fabiensanglard.net/shadowmappingVSM/  and my result is http://imgur.com/nkVtTYI which is rather blocky and no much better than a basic less than test :\

 

I know I can increase the resolution, but still no better than a simple test. PCF gives much more pleasing results

Edited by Mchart

Share this post


Link to post
Share on other sites
kalle_h    2464

 

Prefiltering is just an optimization. You could use NxN sampling kernel with gaussian weights in your shadow shader. Try to also use bilinear filtering, You can also generate mipmaps and use trilinear/anistro filtering.

 

I am doing trilinear (GL_MIN and GL_MAG with GL_LINEAR and I generate mipmaps) but the result is somehow disappointing. I have no penumbra at all. 

I am using almost exactly the code here: http://fabiensanglard.net/shadowmappingVSM/  and my result is http://imgur.com/nkVtTYI which is rather blocky and no much better than a basic less than test :\

 

I know I can increase the resolution, but still no better than a simple test. PCF gives much more pleasing results

 

 

Have you tried aniso? How about more samples? Have you played with minimum variance constant? How about fast single pass 3x3 blur before creating mipmaps?

Share this post


Link to post
Share on other sites
Mchart    130

 

 

Prefiltering is just an optimization. You could use NxN sampling kernel with gaussian weights in your shadow shader. Try to also use bilinear filtering, You can also generate mipmaps and use trilinear/anistro filtering.

 

I am doing trilinear (GL_MIN and GL_MAG with GL_LINEAR and I generate mipmaps) but the result is somehow disappointing. I have no penumbra at all. 

I am using almost exactly the code here: http://fabiensanglard.net/shadowmappingVSM/  and my result is http://imgur.com/nkVtTYI which is rather blocky and no much better than a basic less than test :\

 

I know I can increase the resolution, but still no better than a simple test. PCF gives much more pleasing results

 

 

Have you tried aniso? How about more samples? Have you played with minimum variance constant? How about fast single pass 3x3 blur before creating mipmaps?

 

 

 

Thank you for your reply.

Yes I've tried aniso and the result is still the above. Regarding the min. variance constant what it change is just what change with the classic epsilon bias (i.e. acne and peter panning) and change the "blackness" of the shadow which however remains uniform. nothing about the penumbra. 

As for the 3x3 pass before the mip maps I wanted to avoid to write another shader for it, also for my application I may have to re-render the shadow maps at each frame so if I have to perform a filtering everytime, what's the advantage over a simple PCF? 

Note that my subject is one and all I'm dealing with is the correct selfshadowing as the in the picture above, don't know if this changes anything. 

Edited by Mchart

Share this post


Link to post
Share on other sites
MJP    19754

Hardware filtering on its own is not going to give you a large penumbra. A large penumbra is achieved by using a very large filter kernel, and bilinear is only 2x2. Trilinear and anisotropic are only going to kick in once there's some minification involved (shadow map resolution is greater than than the effective pixel shader resolution), and are designed to preserve texture detail while avoiding aliasing. If you want a large penumbra that "softens" your shadows everywhere, then you should pre-filter your shadow map with a large filter kernel (try 7x7 or so).

If you were using PCF, you could not pre-filter your shadow map. You would have to filter in the pixel shader, using however many samples are necessary. Since VSM's are filterable, you can use a separable filter kernel when pre-filtering to reduce the actual number of samples required. In addition, if you use a caching scheme for your shadow maps then you can amortize the filtering cost across multiple frames by caching the filtered result. With standard shadow maps, you must pay the filtering cost every time you sample the shadow map. 

Aside from that, VSM also lets you utilize MSAA and hardware trilinear + anisotropic filtering. MSAA will increase your rasterization resolution to reduce sub-pixel aliasing, but you won't have to pay the cost of filtering or sampling at that increased resolution. As I already mentioned, trilinear and anisotropic will prevent aliasing when there is minification involved. This usually happens when viewing surfaces at a grazing angle. Here's some images from my sample app to show you what I mean:

 

[attachment=23211:Shadows_PCF.png] [attachment=23210:Shadows_Aniso.png]

 

The image on the left shows shadows being cast onto a ground plane, using only 2x2 PCF filtering. You can see that as you get further away from the camera, the shadows just turn into a mess of aliasing artifacts due to extreme undersampling. The image on the right is using EVSM (a variant of VSM) with mipmaps and 16x anisotropic filtering. Notice how the shadows don't have the same aliasing artifacts, and smoothly fade into a mix of shadowed and non-shadowed lighting.

 

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