Interactive Raytracer 5: Oversampling

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.

Visual effect

So for instance this is the original image:

No oversampling normally-sampled-zoom
No oversampling Zoom

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:

uniform-oversampled uniform-oversampled-zoom
2×2 oversampling Zoom

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 uniform-grid-4
Random Rays will be cast from random locations random-grid-4
Jittered Rays will be cast from an uniform grid with a small jitter jittered-grid-4
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 nrook-original-grid-4
Multi-jittered This method combines the jittered and n-rooks algorithms multi-jittered-original-grid-4

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!

Buy Me a Coffee!
Other Amount:
Your Email Address:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.