This will be my last post on this topic, I’ve actually implemented this in my raytracer a long time ago (2009..), except for the last sampler. I don’t have time to make the raytracer behave better, especially the underlying kd-tree. I have other pet projects that are more interesting to me. But this could still be of interest to some people.
Oversampling in graphics are fundamentals. Without it, you get serious aliasing effects. These can be explained quite easily. In your eye, you don’t get just one ray hitting your retina on one “cell”, you get thousands on them, and then your brain only see the mean value. The issue with the raytracer is that it only uses one ray, instead of thousands of them, because it is quite costly! But even with a small amount of rays, you can enhance the results.
So for instance this is the original image:
The alias effect is clearly visible. This is why AAA games always have an antialiasing option, otherwise they will be so ugly.
Now with a basic antialiasing effect, the same image is now:
Types of oversampling
There are different types of oversampling. Let’s see the difference in a table:
|Uniform||Rays will be cast from a regular grid|
|Random||Rays will be cast from random locations|
|Jittered||Rays will be cast from an uniform grid with a small jitter|
|n-rooks||From an uniform grid, location will be selected from the diagonal of this grid, and then a permutation will be made on the lines or the columns||
|Multi-jittered||This method combines the jittered and n-rooks algorithms||
Here are all the different algorithms in the same image:
You can see the enhancement of the most advanced antialiasing samplers. All antialiasing algorithms can lead to a bad image if the rays hit “bad” objects, but the ones based on random sampling will be better if new values are picked up for each image.
Anti aliasing costs a lot. It multiplies the number of rays, but in the end, the image is better. Additional technics will lower this cost by using SIMD kd-tree traversal, if you want to try them, please do!