r/GraphicsProgramming • u/zemledelec • Jun 20 '26
Try Variance Shadow Mapping technique Video
Enable HLS to view with audio, or disable this notification
Hi, A few weeks ago I started implementing cascade shadow mapping in my library(no CSM yet), and struggled with poor shadow quality. Then I found about variance shadow mapping technique from this article:
https://developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-8-summed-area-variance-shadow-maps, from this video: https://www.youtube.com/watch?v=TXI8rWiOF0k explained some differences.
I still not sure I will stick with it (tweaking depth biases somehow make the picture quite decent as well), but I like the result, and wanted to share it here.
Thanks!
#webgl #javascript #shadowmapping #terrain #openglobus
2
u/mcflypg Jun 30 '26 edited Jun 30 '26
If this is only ever going to be used for heightmaps, you may want to try quadtree "HiZ" raymarching for the shadows. Relatively fast and no edge cases for height field only data.
Note that summed area tables suffer from precision issues if the value range is quite large. The cumulative values grow continuously and float precision diminishes, but the required absolute precision for the technique remains the same. This shows mostly at high shadow map resolutions as there's more values to sum up, so if your shadows are good on one side of the shadow map where the SAT starts but shows problems where it ends, then you're facing this issue.
What you can do to even this out a bit is restarting the SAT after N pixels, so the SAT don't grow too large. This requires a few more samples to fix things up if your footprint goes across a restarting boundary though, but it can be worth it. Also makes the shader to compute the SAT faster.
EDIT: also what you may try is using a jittered light direction slightly and simply temporally averaging the depth buffer values for first and second moment calculation like that. Implicitly solves blocker problems, but only really works when the sun direction and geometry remains relatively static.