Jump to content

  • Log In with Google      Sign In   
  • Create Account

VSM without filtering the maps and easiest way to filter them


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Mchart   Members   -  Reputation: 130

Like
0Likes
Like

Posted 15 August 2014 - 01:14 PM

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!



Sponsor:

#2 kalle_h   Members   -  Reputation: 1565

Like
0Likes
Like

Posted 16 August 2014 - 03:16 AM

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.



#3 Mchart   Members   -  Reputation: 130

Like
0Likes
Like

Posted 16 August 2014 - 04:29 AM

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, 16 August 2014 - 04:33 AM.


#4 kalle_h   Members   -  Reputation: 1565

Like
0Likes
Like

Posted 16 August 2014 - 09:05 AM

 

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?



#5 Mchart   Members   -  Reputation: 130

Like
0Likes
Like

Posted 16 August 2014 - 10:43 AM

 

 

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, 16 August 2014 - 10:43 AM.


#6 MJP   Moderators   -  Reputation: 11741

Like
3Likes
Like

Posted 17 August 2014 - 11:45 PM

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:

 

Shadows_PCF.png 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.

 






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS