My time-wasting for the day

This seems to happen when I start getting low on tasks for a milestone build.

Today I integrated SMAA (“Subpixel Morphological Anti-Aliasing”) into the game, as an alternative to the old MSAA (“Multi Sample Anti-Aliasing”) that we’ve had forever.

For our conversation, here’s a screenshot of a group of players, with no anti-aliasing at all. Notice the stair-step effect along the top and sides of the skeletons’ heads, and… well, along almost every straight line in the image, really. This is kind of ugly. Even shrunk down in the forum view, you can really see those jagged edges.


As a rough simplification, you can think of MSAA as working basically by drawing the image larger than normal, and then shrinking the image down, blending pixels into each other. This isn’t quite as bad as it sounds in terms of performance (it only actually renders the extra pixels near polygon edges), but it does use far more memory than non-antialiased rendering; if you’re rendering using MSAA x4 (as I am here), that uses four times as much memory as rendering with no anti-aliasing, and potentially could use up to four times as much GPU power.

For that reason, and because MSAA doesn’t play well with deferred rendering, you don’t see it very often these days. But since MMORPG Tycoon 2 uses a forward-renderer (well, mostly), it works just fine for us.

You can see that the edges look nicer here. If you expand the image by clicking on it you’ll see that there’s still a little bit of a stair-step effect, but it isn’t hitting you over the head the way that it did without any anti-aliasing at all. In my book, this has been perfectly acceptable for years.

MSAA x4 anti-aliasing:

But with that said, SMAA has become the new preferred anti-aliasing solution for a lot of people. Take a look at this to see why:

SMAA 1x:

Now that’s impressively smooth edges, I feel. And it uses less memory and is faster than MSAA. Unlike MSAA, SMAA doesn’t draw the picture bigger and then scale it down, or think about polygons at all; instead, it just goes looking for jagged edges in the final rendered screen image, and then tries to blur just those edges. Here’s what it sees when looking at this scene:

All of these colored lines are spots where it has found jagged lines that it’s considering blurring. (There’s a second step after this where it chooses which of these lines to actually blur, and how much, and precisely in what directly). Notice that SMAA is even smoothing the edges of the clouds, which MSAA completely misses because the edges of the clouds aren’t at polygon edges. The same is true (although difficult to see in this image) of the edges of grass. SMAA spots that and smooths it, MSAA doesn’t.

And it’s faster!

There’s really only one problem with SMAA, and it’s that it doesn’t get along well with the game’s text. It looks at my carefully pre-antialiased text, and decides to blur its edges, which makes the text look a bit blurry, instead of being crisp. I’m going to have to figure out how to stop that from happening. But for right now, other than that one small issue, I’m pretty impressed by SMAA as a technique.

In theory, there are more advanced versions of SMAA (as you might have guessed by the screenshot being titled “SMAA x1”). There’s an “SMAA S2x”, which involves drawing the scene using 2x MSAA, splitting that 2x MSAA image into two different images, running SMAA on both, and then blending halfway between those results. So you’re basically anti-aliasing two very slightly different views into the same scene, and then blending those together. I guess I’ll probably try that at some point, but I haven’t experimented with it yet. I’m pleased enough just having bog standard SMAA 1x working.

But if someday I want to go properly nuts, there’s also SMAA T2x, which involves making all your polygons vibrate very slightly over time, and then blending between those two antialiased views which were taken at different times. (This can lead to ghosting and other glitches as objects move, but there are plenty of complicated ways to work around those problems, apparently)

And then, of course, there’s SMAA 4x, which combines S2x and T2x, so you’re blending your final image from two different perspectives each drawn from two different points in time. I don’t even want to think about how bonkers that is. It’s neat to live in a world where people are doing this stuff, though! :smile:

1 Like

Game is looking great! been waiting a while for this could you mind hooking me up with a copy?

1 Like