Intel’s research on morphological antialiasing (PDF paper) is rather interesting: its a post process effect, working on a rendered image. It looks for high contrast areas, recognizes basic pixel patterns and does pixel blending on them.
Very clever stuff, inspiring, so I wanted to see if I can make a fake AA post process in Unreal.
A less groundbreaking but more obvious approach was an edge detection based blending between the original frame buffer and a slightly blurred version. I did the blending based on local contrast so the blurred image appeared where pixel lightness suddenly changed.
This method created ghosting on near vertical and near horizontal edges, so I had to weigh edge types. Then I tried to do the edge search on the depth buffer which produced slightly different results. Eventually I ended up combining the two methods so contrast in lightness and depth both matters.
Here are the results:
 |
 |
Without and with post processing.
(You can use the left-right cursor keys to move
through the images.) |
The effect works best on ~22.5 degree slopes (45 degree ones look smooth even without AA). The shader has difficulties with high contrast, high frequency details: the grate at the top of the building, with its 1-2 pixel wide bars looks really weird after filtering.
This filter does a certain degree of de-noising as well, which helps with the bright edges on the window bars.
Alpha tested foliage looks better with the post process, in spite of the lost sharpness. The loss of high frequency details is quite apparent on the cliff and the dome, but that’s not that obvious while moving.
Interestingly the ideal settings of the effect (7 parameters) depend heavily of the content of the scene: lighting, textures, geometry detail. My test map, DM-Deck and DM-Sanctuary needed a quite different setups, so for best results, the parameters would need tweaking on a room-by-room basis, which would be a hassle. (A script could handle the blending values when moving between rooms.)
The other problem is that the shader is quite expensive, clocks at 86 instructions at the moment, although I haven’t tried to optimize it.
And lastly, I’m not convinced that I need AA this way at all. The effect is very subtle and it would be worth the effort only in really low resolutions. Even in 720p, it’s not very obvious, save for a few extreme cases. Beyond 1080p, the pixel size gets so small that AA is practically unnecessary. More resources spent for less impact.
So until a GPU implementation of the cheap MLAA gets implemented in Unreal, I won’t worry about aliasing too much.