The antialiasing used on these pages are done with a summed area table technique. Antialiasing is needed to more accurately represent the sampling over a function that a pixel represents. Generally from far away, many texture points may map to a single pixel, and a nearest neighbor sampling of the texture area is going to have aliasing artifacts. With nearest neighbor sampling, the pixel does not accurately represent the collection of texture points under the projected pixel area. There will be color discontinuties and "jaggies" from pixel to pixel, because only one color sample is being used to represent a collection of textures that would all fall into the pixel projection area.

Summed area tables try to solve this by taking an average of the pixels under the pixel projection into texture space. Rather than just selecting one texture point to represent many texels, summed area tables take the average of texels under an area.

A texel (i, j) stored in the system is the sum of all texels from (0, 0) to (i, j). To calculate the average under an area, we take the bounding box of a projected pixel. The bounding box is then shrunk to the same area as the projected pixel, but keeps the same aspect ratio as previously determined. This is an approximation to the pixel, a box with the same area as the pixel. Since a texel contains the sum of all the texels to the left and below it, if (0, 0) is the lower left corner of the texture space, we can find the sum of all the textures in the box by subtracting the upper left and lower right corners, from the upper right corner, and adding in the lower left corner to account for double subtraction. Then to find the average of the box, we just divide the sum by the amount of texels in the box.

In the actual implementation, to calculate the summed area table, each point is calculated incrementally. The sum of (i, j) is equal to (i, j) + (i-1, j) + (i, j-1) - (i-1, j-1), assuming that the previous texels have already been summed. Since this was done with a raytracer, when a ray is cast, 4 rays that correspond to the corners of the pixel are cast along with it and passed to the material handler. The material handler gets the four intersections of the pixel with the object in question. The bounding box is determined from the four corners and is shrunk to match the projected area of the pixel. The box is passed along to a recursive operation to clip the box (because the box may pass over the texture space bounds) and total the colors under the clipped boxes. Once it has calculated the total color sum and total texels, it sends it back and takes the average of all the colors.

There were a few problems I encountered when implementing summed area tables. These ranged from off by one errors, calculating the correct pixel area, what to do if the material handler only gets less than four corners (because maybe the pixel hits an edge of an object so that one or more corners miss the object), getting infinite recursion, how to clip the box to the texture space. I still think there are off by one errors, specifically what to do if the area is around 1 texel, and tiling textures. I don't think my results for tiled textures is exactly correct, but for non tiled textures, it works fine.

This image was sampled with nearest neighbor. You can see "jaggies" the top face and the left face.

This image was sampled with summed area tables. Much more appealing to the eye, as there aren't large color discontinuities from pixel to pixel. The average more accurately represents the texels that fall under the pixel area. Along the top and left side though, there are artifacts from wrapping around the texture.

Nearest neighbor. Really awful aliasing is on the top and left sides of the cube again.

Summed area tables. Quite a difference from the previous image. The color transitions are much more continuous, rather than jumping. Again, I have problems with the edges from texture tiling and how I clip the bounding box to the texture space.

Nearest neighbor. Far in the distance, the checks become noisy, as many texture points map to one pixel and only one is selected to represent the population.

Summed area tables. Now, as we recede into the distance, checks blur together, and the average color of all the points is taken as the sample of the combination of texels. The pop up artifacts far in the distance I believe are from tiling, because the texture used here is tiled across the surface, rather than one giant texture, so sampling across texture boundries causes some problems in color sampling.