Advertisement

Exponential VSM problem

Started by August 11, 2017 07:07 PM
2 comments, last by Sytto 7 years, 6 months ago

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:

 

 598dfd1dd6110_ABABEBFE639192CF5ECF0E42A2E9EAFD7A595A3127FB226267pimgpsh_fullsize_distr.png.80f587f48a84c27dc4a6499a7a5a70b3.png 

 

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.

 

598dfe0f358b5_981EB1572D8BE1F72434C6DE9AA9E96E2C4E0EBDF966278667pimgpsh_fullsize_distr.png.2dabb854a8cd90eae5ead708916d080a.png

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! 

56 minutes ago, Sytto said:

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 ?.

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.)

Advertisement
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 :) 

This topic is closed to new replies.

Advertisement