Shadow Mapping vs. IZB
Interactive comparison of traditional shadow maps and pixel-perfect Irregular Z-Buffer shadows. Companion demo for the full write-up.
Camera view. Drag to rotate the light.
Light view. Click a cell to inspect.
Click a cell in the light view to see which camera pixels sample from it. All those pixels get the same shadow/lit answer. That's what causes the staircase.
What you're looking at
A shape sitting on a ground plane, lit by a single directional light. The camera view on the left shows the scene with shadows applied. The light view on the right shows the scene from the light's perspective, where brighter values mean closer to the light. The depth is normalized to the scene's actual range so you can see the full gradient. Selecting the torus will make it spin continuously so you can watch the shadow change shape over time.
Shadow Map
The classic approach. The scene is rendered from the light into a depth texture (the shadow map), then for each camera pixel, its position is projected into light space and the depth texture is sampled. The problem is that this texture is a regular grid. Camera pixels that land between texels snap to the nearest one, producing staircase edges along shadow boundaries. You can drag the Resolution slider to see the staircase get coarser or finer, but it never fully disappears.
Click a cell in the light view to highlight every camera pixel that reads from that cell. Notice how dozens of pixels all share a single shadow answer.
Irregular Z-Buffer (IZB)
Instead of sampling a depth texture, the IZB projects each camera pixel into light space and tests it directly against the scene's actual triangles. There is no grid to snap to, and each pixel gets a geometrically exact answer. The grid visible in the light view is only used for spatial acceleration (narrowing down which triangles need to be tested for a given pixel). It does not store depth values.
Click a cell to see the actual triangles binned there, each colored distinctly. These are the candidates that every pixel falling in that cell gets tested against.
Controls
Shadow Map / IZB switches which shadow technique is applied to the camera view. It also changes which grid the light view displays: the shadow map's texel grid in Shadow Map mode, or the IZB's spatial acceleration grid in IZB mode.
Sphere / Torus switches between a static unit sphere and a tilted spinning torus. The torus produces a more complex shadow shape that makes the staircase artifacts especially visible.
Grid toggles the grid overlay on the light view. Turn it off for a cleaner look at the depth visualization.
Edges highlights every pixel on the shadow boundary where the shadow value transitions from lit to shadowed. On shadow maps this traces a jagged staircase. On the IZB it traces a smooth curve that follows the actual geometry.
Orbit slowly rotates the light around the scene. This is useful for watching the shadow map staircase crawl and shift in real time without needing to drag.
Resolution controls the shadow map's texel resolution, from 16×16 up to 256×256. Higher resolution means smaller staircase steps, but the fundamental artifact remains. This slider only applies in Shadow Map mode.