TheRealMJP/Shadows

Ring like effect in the columns test scene

Closed this issue · 2 comments

This is more of a question than an issue. I noticed in the columns test scene that if the camera and light directions are at a sufficient enough angle, the shadows of columns at the far end of the scene take on the shape of concentric rings (see image below).

rings1

I'm guessing this is due to ambiguity between sample positions on the cascade shadow map from the camera's current perspective, but I was curious if you've seen this before and if there is a reason behind the concentric rings shape.

Remaining app settings:

rings2

View from above:

no-rings)

Hey there! The rings you're seeing are actually moiré pattern caused by aliasing. In this cases the aliasing is caused by the shadow map being under-sampled by the pixel shader: basically the shadow map's projection onto the screen results in there being too many texels within the footprint of a screen pixel. You can get this too when sampling "normal" textures, but normally it's avoided by using mipmaps to pre-filter the image. With standard shadow maps you can't pre-filter like that, so the best you can do is filter on-the-fly in the pixel shader using PCF. For extreme oversampling you may need a lot of samples to adequately filter the signal, so it's not really practical to do that for all cases.

On the other hand, techniques like VSM/EVSM/MSM are explicitly designed to allow for pre-filtering the shadow map. So you can totally generate mip levels from the shadow map before sending it to the pixel shader and avoid that class of aliasing. With just trilinear filter you'll often get over-filtering at oblique angles, just like normal textures. But anisotropic filtering will let you avoid that problem. If you switch to any of the VSM/EVSM/MSM modes in the demo you can enable or disable mip mapping and anistropic filter to see how well it works for that columns case:

mip_comparison

Top is EVSM with no mips, middle is with mips enabled, bottom is with mips and 16x anisotropic filtering.

Oh cool, thanks for the detailed explanation :)

I noticed that the effect becomes a lot less pronounced with mip maps and 16x anisotropy as you mentioned.