r/GraphicsProgramming • u/LegendaryMauricius • May 11 '25
A WIP experimental precise shadowmap technique
I'm working on an idea I had for some time, also similar (coincidence) to an old paper I discussed in this post. To prove there's still merit to old undiscovered ideas and that classic rasterizing isn't dead, I tried implementing it, calling it Edge alias adjusted shadow mapping (EAA). Obviously WIP, but since I made a big breakthrough today, I wanted to post how it looks :P
From first to last image: EAA shadow with linear fade, EAA without fade, bilinear filtering, nearest-neighbor filtering. All using the same shadow resolution.
The pros: it produces shadow edges following real 3D models without blocky artifacts from rasterizing. Supports nice shadows even on low resolutions. Can be used both for sharp shadows akin to stencil shadows, without the terrible fillrate hit, or softer well-shaped shadows with a penumbra of less than 1 pixel of the shadowmap's resolution (could have bigger penumbra with mipmapped shadowmaps).
The cons: it requires rendering the outer contour of the shadow mesh. Currently it's done by drawing a shifted wireframe after polygon drawing for shadowmaps, and it is quite finicky. Gets quite confused when inner polygon edges overlap with outer contours. Needs an additional texture target for the alias (currently Norm8 format). Requires some more complex math and sampling when doing the filtering.
I hope I'll be able to solve the artifacts by fixing rounding issues and edge rendering.
If my intuition is right, a similar idea could be used to anti-alias the final image, but I'm less experienced with AA.
32
u/olawlor May 11 '25
Very neat! I'm always surprised at the lack of progress in shadow map tech over the last 20 years.
I wrote a paper in 2006 on getting more physical correctness into soft shadow maps:
https://www.cs.uaf.edu/~olawlor/papers/2006/shadow/lawlor_shadow_2006.pdf
(The technique itself is similar to everybody else's, and requires silhouette geometry, but might give you some ideas on how you might compare shadow outputs, like in Figure 11.)
10
2
u/Tableuraz Jun 02 '25
Very interesting! Cudos for the simple math and piece of code, as a dev I appreciate it when researchers don't just put complicated formulas 👍
I think the lack of research is due to the arrival of hardware PCF filtering, generalization of TAA (I know I heavily use stochastic filtering for my shadow sampling), the increase in computing power which means filtering on shadow sampling is now reasonable and raytracing must have played a role in slowing down research in that specific department.
10
u/x1rom May 11 '25
Nah No way that's the same shadow resolution, that's crazy.
Mind linking that old paper?
Edit: nvm you already did.
7
u/LegendaryMauricius May 11 '25
It's in the first link... of the first link.
Keep in mind this is not the same thing. I just went into the same direction as that author, and couldn't find anything similar until halfway implementing my idea.
6
2
u/schnautzi May 12 '25
Amazing work! Looking forward to any additional improvements you come up with. It reminds me a bit of how we put distance fields in textures alpha channels to render detailed transparent shapes.
1
2
u/waramped May 12 '25
Cool! Does it work with overlapping geometry? Like a near and far caster overlapping the same shadowmap texels?
2
u/LegendaryMauricius May 12 '25
Haven't tested on many models, but the artefact in the picture is one example of that. After improving the technique it shouldnt have issues with that, but only one caster will be saved per pixel. It should still have a smooth curve, but you can't magically add real detail without increasing resolution.
50
45
u/scrufflor_d May 11 '25
tbh if anyone says that classic raster is dead then they're probably either an idiot or trying to gas up their nvidia stock. also great shadows!
2
1
u/_voidstorm May 14 '25
Maybe this thesis: https://repository.tugraz.at/publications/n163q-e7237 is also of interest to you then. Its called Edge Distance Shadow Mapping and I don't know of any engines that implemented it, but it always looked interesting to me. Maybe there are some similarities to your approach?
2
u/LegendaryMauricius May 14 '25
VERY interesting. I've yet have to figure out their silhouette rendering in detail, but my edge detection seems to be much dumber, with less caveats (hopefully). Seems like a very similar approach, I regret not finding it sooner.
1
u/UnalignedAxis111 Jul 24 '26 edited Jul 28 '26
Did you continue working on this?
Just a random idea I got rn, combining shadow maps with a vis-buffer. It would probably have similar artifacts with overlapping edges but should be much simpler to generate. Determining visibility would be simply intersecting one/a few triangles within the sampling radius, which shouldn't be that expansive.
Edit: it obviously has been tried before, and apparently UE5 implements a similar approach. The problem is that you need per-pixel lists to mitigate gaps, which doesn't seem very cheap.
2
u/LegendaryMauricius Jul 24 '26
Currently I'm refactoring the engine to provide more control over texture memory. Hopefully soon I'll continue on this, because I think I figured what the real culprit behind the artifacts is.
It's definitely not just because of overlapping edges. Due to edge curve interpolation, pixels that don't fit each other still shouldn't produce such inconsistencies.
-14
u/susosusosuso May 11 '25
These kind of techniques are not worth nowadays for multiple reasons. One is that knife sharp shadows are not desirable. The other one is that it introduces lots of polygonal complexity.
10
u/LegendaryMauricius May 11 '25
What do you mean by polygonal complexity? Also, it's not knife sharp. It allows change in penumbra width.
2
1
u/666forguidance May 13 '25
Idk I prefer the knife sharp shadows. They make a game look less cartoonish
1




43
u/LegendaryMauricius May 11 '25
Obviously, if I perfect it I'll write some blog post/paper about it in detail. If anybody wants to see the code, it is in the ShadowFiltering plugin for my VitraeEngine (branch eaa-shadows). The engine is very WIP and only tested on Linux, but its SDK is here.