Aliasing
Joren Van Onder
Table of Contents
Introduction
Imagine the following scene:
Figure 1: 100x100px image with red and green alternating circles, each with a diameter of 10px
Reducing the size of each circle to 1px gives a predictable result. The resulting image has alternating green and red vertical lines:
Figure 2: 100x100px image with red and green alternating circles, each with a diameter of 1px (uniform sampling, 1 sample/px)
Different sampling methods
Depending on the sampling method used the lines may not have a uniform color. The same scene rendered with jittered sampling results in:
Figure 3: 1px circles rendered with jittered sampling (16 samples/px)
The end result however is still an image with vertical lines containing either shades of green or shades of red i.e. a vertical green line contains no shades of red and vice versa.
Aliasing artifacts
When the size of the circles varies slightly from the sampling frequency, aliasing artifacts occur. E.g. sampling 1.05px circles uniformly (1 sample/px):
Figure 4: Aliasing artifacts with circles with a 1.05px diameter, rendered with uniform sampling (1 sample/px)
This shows a clear pattern that does not exist in the scene. Although usually more subtle, this demonstrates clearly why most rendering methods use various anti-aliasing techniques to avoid this.
Jittered sampling is quite effective at eliminating most forms of aliasing. Although it looks better, for this case the end result is not acceptable:
Figure 5: Aliasing artifacts with circles with a 1.05px diameter, rendered with jittered sampling (16 samples/px)
Analysis
Uniform
When sampling circles of 1px the sampling occurs in in lockstep:
Figure 6: Lockstep uniform sampling (1 sample/px)
Although different sampling techniques might sample these individual pixels differently, there is only either green or red in each pixel.
When the circle is slightly larger than the pixel size (1.05px) the sampling no longer occurs in lockstep:
Figure 7: Non-lockstep uniform sampling (1 sample/px), sample points are given in blue
With uniform sampling at 1 sample/px this results in the black symmetric spots in Figure 4. The regular pattern of the scene results in the multiple areas where only the background is sampled. In figure 7 happens in the bottom right pixels.
Jittered
The core issue with this pattern is that every sampled pixel will contain a varying amount of red and green. From left to right the pixels will contain:
- only green (+ background)
- mostly green, little bit of red (+ background)
- equal amounts green and red (+ background)
- mostly red, little bit of green (+ background)
- only red (+ background)
- etc…
The jittered sampling in Figure 5 gets rid of the symmetric black spots but still has some aliasing artifacts. There are multiple vertical bands of noise. These noisy bands occur when the pixels are being sampled as described in steps 2, 3 and 4.
More advanced jittered sampling patterns like e.g. multi-jittered sampling won't do any better:
Figure 8: Aliasing artifacts with circles with a 1.05px diameter, rendered with multi-jittered sampling (16 samples/px)
The core issue remains the same, namely that going left to right pixels contain a varying amount of red and green.
Conclusion
Avoiding these vertical noise bands is not straight-forward. An ideal solution would necessarily have to result in uniform noise. There is simply not enough available resolution to do better. Therefore it is best to avoid this situation all together by either:
- increasing the image resolution
- changing the world-to-image scaling factor (pixel size)
- modifying the scene
Interestingly, the classic anti-aliasing checkerboard example side-steps this problem 1:
Figure 9: Anti-aliased checkerboard
The same bands appear, but because the square size decreases rapidly as the distance from the camera increases they are not noticeable.
Footnotes:
By Portsmouth (Own work) [Public domain], via Wikimedia Commons