Jump to content
  • Advertisement
Sign in to follow this  

Exponential VSM problem

This topic is 795 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!