Advertisement

Matching filtered EVSM to PCF

Started by July 11, 2019 08:20 PM
4 comments, last by frostbyte0085 5 years, 2 months ago

Hello,

I have been exploring the possibility of switching from using PCF to either VSM or EVSM for my shadow maps. I have it all working at the moment, however I am running into difficulty matching the EVSM shadows' penumbras to the PCF ones. Small details are lost (while usually preserved during PCF) to the point where to get a soft penumbra, I either need to apply lots of blur (and lose all detail), or stick to a harder penumbra (which at that point, I may as well use PCF).

I've tried a box and gaussian blurs of various kernel sizes. I wonder what people thoughts are on this?

Edit: I've also tried a mixture of a small shadow map blur and then a 5-tap average when sampling the filtered map, but this defeats the purpose of pre-filtering I suppose. Results were a little bit better though.

Thank you

 

Well it really depends on how exactly you're implemented your EVSM and your PCF. In general you should be able to use the same exact code that you use for PCF to sample your EVSM map (with point filtering, no mipmaps, no MSAA, etc,) and you should get very similar results in terms of your filtering. If you try that and things don't match up, then your probably have a bug or inconsistency elsewhere.

Could you provide some more details on what you're doing for your PCF and EVSM paths?

Advertisement

Hi Matt,

So for the EVSM I do the following during filter pass:

  • Horizontal compute blur:
    Read from source shadowmap and convert to EVSM. Blur the converted results.
  • Vertical compute blur:
    Read the horizontally blurred EVSM map and blur vertically.

Sampling from the source textures is always done with a point sampler.

And for the shadow test, I use a standard negative & positive exponent Chebyshev function (like you have in your sample). The difference is that I use a bilinear sampler, I will try point later. No mipmaps, no MSAA yet. I've tried several approached to blurring the shadowmaps and they all yield the same result, so I suspect there is an issue in my shadow testing code. The blurred result seems to be correct in PIX.

For PCF, I have both traditional 5-tap PCF and also poisson disc filtering. None of those match the EVSM (and the PCF / Poisson ones are "correct").

So a quick update on my problem, it does seem to be a problem with the testing function.

Judging from the results, the depth range of the occludee and the occluder seem different (although they should be the same, they both in z/w format, [0, 1] range). This would explain for example also why the further away the occludee is from the occluder, the more blocky and unfiltered the result seems (within the same cascade).

 

Okay, so this is now fixed... I was ignoring the fact that we use reversed depth in our engine (moving to a new huge project without knowing what's going on in it exactly is definitely not helping).

This topic is closed to new replies.

Advertisement