The Cascading Shadow Map System is Done!

Dorian now supports cascading shadow maps for better quality shadows! (Click to see full size!)

What are Cascading Shadow Maps (CSM) and what does it achieve?

Shadow map based systems create a depth texture representing the shadows from a light source’s point of view. This depth texture is then sampled across a whole scene to work out what’s in shadow and what isn’t.

The issue with shadow maps is that the greater the range of depth that you are dealing with, the more the depth texture has to be stretched in terms of its depth to cover all possible values. ie you are trying to squeeze larger ranges of depth information into the fixed number values that a single pixel can hold. This can then lead to sub-par shadows.

You’ve probably seen these low resolution shadows in some commercial games where the shadows have jagged triangular looking edges.

Dorian’s CSM system gets around this by creating multiple depth textures that are range dependent. These are called cascades. Each cascade is responsible for creating shadows over a specific depth range.

Having multiple depth textures in cascades reduces how much each one is stretched out to fill the scene depth. What’s more, these cascades are tuned so that the nearer cascades have smaller overall depth ranges (less stretching). This results in pin sharp shadows!

Medium to long distance cascades have larger depth ranges which results in fuzzier shadows, but in these cases the objects are far enough away that a player won’t notice.

The overall impression that the player gets is one of pin sharp shadows!

The image at the top of this post shows the effect of ramping up the cascades – Dorian supports differing numbers of cascade on a per light source basis.

The one cascade image on the left is what a typical shadow mapped engine looks like. The shadows don’t look too bad in that example, but the bigger the world, the worse it gets – and the demo world above is very small.

Note that as I add more cascades, the shadow quality improves 🙂

I’m happy with the shadows system but I still have a lot more work to do and this work should be done now whilst the iron is hot.

Why?

I tend to forget hard won knowledge unless I continually work at it. I had the same issue with Ionian – the previous graphics engine. That graphics engine lasted over twenty years – but it was so reliable that I rarely had to look at its code which resulted in my graphical knowledge draining away.

It’s the driving reason why Dorian’s capabilities will be taken to a much higher level than Sojour needs as the expectation is that once it’s done, I’ll rarely touch the actual code again – which means lost knowledge. Hence my determination to strike whilst the iron is hot!

Please have patience!

Have Fun!

RobP

Leave a comment