shadow map filtering

I noticed ATI has a long DX9 pixel shader at to show you how to do filtered shadow maps in fragment programs.

Part of the pixel shader is this:

// jittered sample offset table for 1k shadow maps
def c0, -0.000692, -0.000868, -0.002347, 0.000450
def c1, 0.000773, -0.002042, -0.001592, 0.001880
def c2, -0.001208, -0.001198, -0.000425, -0.000915
def c3, -0.000050, 0.000105, -0.000753, 0.001719
def c4, -0.001855, -0.000004, 0.001140, -0.001212
def c5, 0.000684, 0.000273, 0.000177, 0.000647
def c6, -0.001448, 0.002095, 0.000811, 0.000421
def c7, 0.000542, 0.001491, 0.000537, 0.002367

How did they come up with these numbers?

These are probably offsets to the texture. If they use a 1024x1024 resolution for the shadow map, and since tex coords are in the [0-1] range, an offset of exactly one pixel would be 1/1024 = 0.0009765. Now they’re probably using a filter that is not perfectly aligned on pixels (like circularly around the pixel’s center), which explains why you don’t get exactly this value. You’d have to draw it on a paper to see exactly what they’re using.


These numbers are “random” points in a Poisson distribution around the origin. Their exact positions are shown in some graphs and code in this presentation on slide 29 and slides 43-46.