• Advertisement
Sign in to follow this  

Exponential VSM problem

Recommended Posts

Hi guys :) I´m having real troubles implementing Exponential VSM and I need someone to tell me whether this is a bug or an expected behaviour.

In my scene, I have several shadow casters and a terrain that doesn´t cast shadows.

For creating the VSM, i do the following thing:

First, i do a depth prepass without any color outputs, from lights point of view.
Secondly, i transform the depth to the exponential VSM format in a separate fullscreen pass, outputting R=WarpedDepth, G=WarpedDepth*WarpedDepth. (my implementation is exactly the same as in MJP´s great article :)
Next, i apply a separable gaussian blur to the VSM shadow map.
Lastly, i apply the shadow and lighting to my scene.

Everything works fine, as long as the shadows are casted to other shadow casters, it looks smooth and great. But when the shadows are casted on the terrain (or any object which is not in the shadowmap) the VSM seems to work pretty bad, is this an expected behaviour ?.

Here are some pics that show the problem:




Left small cube = smooth shadow, since the shadow is being casted on the bigger cube
Right small cube = horrible shadow, in this case, having a big gaussian blur kernel even makes the problem worse (it makes the shadow smaller, but not smoother!). 

Here is another pic with more detail.



Notice how the rooftops have super nice and smooth shadows, but the terrain (roads, etc) and basically every shadow casted on an object that doesn´t cast shadows is ugly. In the pics i made the shadowmap resolution smaller to better show the problem. But the problem is also noticeable using a 2048x2048 shadowmap 


Am i doing something terribly wrong or this expected behaviour ? :) 

Any help is appreciated, many thanks! 

Share this post

Link to post
Share on other sites
9 minutes ago, LandonJerre said:

It is an expected behaviour, with VSM (and any other related techniques) you have to render both the occluders and the receivers into the shadow map. If you think about it, when you blur the VSM without the receivers in it (or even if you just sample that map with proper texture filtering), you blur between the occluder depths, and the maximum z value, meaning that the blurred values will strongly tend towards the max z. Tending towards max z also means that the blurred values will be "behind" the receiver pretty quickly, and that messes up the whole thing. (This explanation is exactly mathematically precise, but hopefully it's enough to illustrate the problem.)

Thank you very much for your answer, it really makes sense to me :). Im thinking how to "fix" this, maybe adding a proxy geometry (like a plane) under the terrain could fix this issue. If anyone has a better idea i´d be glad to read it :) 

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  

  • Advertisement