Saturday, February 26, 2011

Morphological Anti-Aliasing

This post is going to be a bit technical, but perhaps this angle will also be interesting to some of you.

We are in the process of implementing Morphological Anti-Aliasing in the graphics engine. You may have noticed the jaggy lines - aliasing artifacts - in previously posted screenshots, and MLAA is a method to lessen the problem. With the new deferred shading technique in our renderer, we can no longer use standard MSAA techniques. The two technologies are incompatible.

There is a brute force anti-aliasing solution - supersampling, also known as Full Scene Anti Aliasing (FSAA), but the performance hit is considerable. We will offer supersampling as an option in the game - the scene looks just great with it if you have a powerful graphics card with fill-rate to spare and lots of memory to allocate the larger buffers needed. But we also wanted to make the picture better on middle class or low-end hardware.

This is where MLAA comes handy. It is a very smart post-processing pass on the rendered image, basically selectively smoothing out parts of the image where a smart filter detects a jaggy line. It is not perfect, sometimes it blurs things that would be better left untouched, and it also cannot really reconstruct single-pixel width objects (for example electrical wires in the distance) to make a smooth line out of them like MSAA or FSAA could. But it helps considerably in many situations, and the performance cost is acceptable. You can read more on the method here http://www.geeks3d.com/20101023/tips-what-is-the-morphological-anti-aliasing-mlaa/. It is not our invention, the algorithm was invented by a very smart engineer at Intel.

As the picture below illustrates, the benefits of MLAA can be clearly seen on the big concrete blocks near the camera. However, the technique cannot really fix the problem with the road on the other side of the river just below the castle. The amount of information preserved in pixels of this part of the image is not high enough.