r/GraphicsProgramming • • 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.

320 Upvotes

33 comments sorted by

View all comments

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.