
116 II Lighting and Shading
more than SM
Dim
samples. It is not necessary to store the height map itself,
so all coarser levels can be packed into SM
Dim
− 1 samples (in case the shadow
map dimension is a power of two). We pack data so that level 1 starts at column
x = 0, level 2 starts at column x = SM
Dim
/2 and so on. The data for the ith
cascade begins at row y = N
Slices
· i.
The first tree level is obtained by reading the slice origin O
UV
and direction
D
UV
from the tex2DSliceUVDirAndOrigin texture, computing the locations of the
two required samples on the shadow map (O
UV
+2i·
D
UV
and O
UV
+(2i+1)·
D
UV
)
and the min/max depth. To obtain conservative bounds,