Real Time Shadow Optimization

Hello,

I understand that baking light maps is the most optimized way to have shadows in the engine, but if you need real-time shadows what settings are the least heavy on the game’s performance? For example I’ve noticed there are different kind of shadow types. I’d assume the 8 bit types are take up less computing power than higher bit values, but then how do the variance shadow maps compare to the shadow map pcf’s? Does blurring shadows increase or decrease performance? Should the blurring be Gaussian or box? Does blur size affect performance?If anyone can shed any light on these settings and how they actually behave under the hood that would be great.

Thanks so much,
Jake

Usually the 8 bit shadows are not good enough for larger scenes, so you need at least 16 bits.
It’s hard to compare exact cost, as that really depends on the platform. Often the variance shadows are pretty cheap, as you can get away with lower resolution compared to PCF. The box blur is cheaper than gaussian.
I think the best start would be to either use 16bit VSM of lower resolution, or PCF3 of maybe slightly higher resolution and compare the quality and performance on the devices you need to run on. Often on mobile even PCF2 is being used, but we have not written the shader for this yet, but that would likely be the fastest way to go.

But often there are other things at play. Large cost of rendering to shadow map is the cost caused by the number of objects. So if you have many objects, it’s good idea to try to minimize this by batching, using atlases and similar.

3 Likes