A More Unique Approach to Shadow Maps - by Taha
Lotus Spring
SubscribeSign in
A More Unique Approach to Shadow Maps
Taha<br>May 26, 2026
10
Share
I recently upgraded how the shadows look in the game, using a lesser-known technique called Light Space Perspective Shadow Maps.<br>For the longest time, I’ve been using a fairly simple PCF shadow mapping setup with an orthographic projection that followed the camera. Considering how easy shadow maps are to implement, it served me quite well. The shadow area was large enough to comfortably cover the camera frustum when looking straight down, and since my game is top-down, it was a good enough solution that let me focus on other parts of the engine.<br>However, over time the camera has moved higher up, the viewing distance has increased significantly, and the field of view has widened. As a result, the old shadow map could no longer keep up. You can now clearly see beyond the shadow region, where objects suddenly receive no shading at all, creating a harsh, abrupt cut that looks quite ugly.
The easiest fix would be to simply increase the area covered by the shadow map. However, this comes at a cost. Each screen pixel now maps to fewer texels in the shadow map, effectively lowering its resolution. As a result, the shadows become noticeably pixelated. This phenomenon is called perspective aliasing.
Effect of increasing shadow map area coverage. The resolution is the same in both versions. The version on the left covers a bigger area, so it correctly casts shadows for distant objects, but the reduced effective resolution means that the shadows have less definition.<br>Another option is to increase both the coverage and the shadow map resolution. While this works, it’s only viable to a certain point. Since increasing the shadow map resolution will incur huge performance penalties, and take significant VRAM space.<br>So there is a tug of war between wanting high shadow map resolution and wanting coverage of a huge area. But an important observation can be made from the comparison shot above. The difference in shadows is very perceptible for objects close to the camera, and much less noticeable for shadows further away.<br>This means we can get away with the perception of really high-quality shadows by allocating more shadow map pixels to objects closer to the camera and fewer pixels to objects farther away. And this actually becomes a data compression problem: how can we take advantage of this fact to maximize the shadow map texture usage?<br>Most video games that use shadow mapping take advantage of this with a technique called Cascaded Shadow Maps (CSM). It works by splitting the view frustum into multiple cascades, where the cascades closer to the camera cover a smaller area but receive higher resolution, while farther cascades cover much larger areas at lower resolution. There’s a lot more to it, but I’ll skip the details since it’s a very well-known technique with plenty of excellent resources available. Also see the end of this article for more reading resources.<br>But I didn’t want to go with CSMs at this point in the development process, since it’s actually quite a lot of effort to implement. I’ve learned that it’s very easy to fall into the endless “improving graphics” rabbit hole, so I try to be careful with my time as there are other parts of the game that need work, especially when it comes to shadow mapping, since it’s a gift that keeps on giving. :)<br>There is a lesser-known family of techniques called Perspective Shadow Maps. Instead of splitting the shadow map into multiple cascades, these techniques warp the sun’s projection matrix so that more shadow map pixels are allocated to the areas closest to the camera.<br>Light Space Perspective Shadow Maps (LSPSM) has been on my radar for a while, and I finally wanted to try implementing it. It seemed relatively straightforward to add, and the benefits are significant. I also like that it’s a more novel approach to shadow mapping, and I knew the learning experience would be fun.<br>I won’t cover the exact math and technical details of LSPSM here, but the basic idea is that you take the camera’s view-projection matrix to find the relevant points of the camera frustum (and its intersection with the scene). From there, you calculate an optimal warping of the sun’s projection matrix so that more texels and detail are allocated close to the camera’s position.
Simple shadow map setup (Left) vs LSPSM (Right). It’s worth pointing out that in the simple shadow map setup, a large part of the shadow map texture is wasted and left unused.<br>LSPSM also has a nice advantage over CSM. Because the texels decrease in detail smoothly and linearly away from the camera, you don’t get the visible seam transitions that often appear between CSM cascades.
Transition boundary between CSM cascades. Image from Microsoft.<br>A quick note on shadow shimmering: With CSMs, a typical method to remedy shimmering is to do a technique called Texel Snapping. But...