Development Blog: Programming – FXAA

Today we wanted to talk about FXAA, what kinds of magic it brings to the table, and what kinds of magic it doesn’t.

First and foremost, what is FXAA? FXAA is an anti-aliasing method developed by Timothy Lottes over at Nvidia. During it’s developement, Timothy set three major goals to what FXAA should accomplish:

  1. SCALES – Full performance and quality scaling from the low to the high end. Use the same code on console and PC and it just works. Can adaptively adjust FXAA cost at run-time for adaptive frame-rate control.
  2. QUALITY – High-end quality of FXAA II is a tiny better than FXAA I, low-end quality is remarkably better.
  3. BETTER FXAA+MSAA – Attempting to provide better quality when mixing with MSAA or another AA method. For example 2xMSAA for better sub pixel features + FXAA for better edge gradients.

FXAA source can be found out in the wild now, as well as on Timothy’s blog spot.

Technical bits and bobs

So, getting on to the good stuff. FXAA is a pretty great anti-aliasing method. One of it’s biggest upsides is that it applies aliasing to not only polygonal edges, but also to textures (with alpha channels as well) and even post processing effects. More or less, it applies to everything on screen almost. FXAA costs nearly a twentieth of the cost of MSAA, it’s even lower then the lowest of MSAA methods such as 2x -4x MSAA while being able to provide a better quality than the two. We’ll be supporting FXAA in city17, and we suggest turning off normal AA, and turning on FXAA for the amazing frame boost. Before getting too ahead of ourselves though, let’s get a little more technical about our implementation of FXAA.

We didn’t really know how well FXAA was going to work when we ran into it, but we decided to give it a go, and implement it anyways. Magically it worked on the first compile.  FXAA offers some flexibility and customization right out of the box. Currently we are using FXAA implementation 3.11.

When we implemented FXAA we were quite amazed with the performance, however there were a few good and bad things we noticed:

  • Offers better quality than the lowest of MSAA methods out there, while being cheaper. Typical FXAA is about 2.0ms at 720p.
  • FXAA 3.11 has some bigger optimization: 2.2ms cost at 1080p, about 2.0ms on 720p still.
  • FXAA applies to not only polygonal edges, but also to translucent and alpha-tested textures. Big plus here for alpha-tested textures because of how horribly alpha testing rapes image quality.
  • FXAA can still be combined with MSAA methods. We ourselves currently use 4x MSAA and still are able to enjoy the benefits of both methods at once, while still retaining a better cost then jacking AA all the way up.
  • FXAA applies to post process shaders as well, such as our god rays.
  • Lastly, FXAA offers a nice amount of headroom for other bigger things we’d like to spend budget on.
  • Blurred the entire screen
  • Lost some detail in textures because of the way FXAA worked.

While two drawbacks pale in comparison to what FXAA brought to the table, those two issues were rather large and annoying.If we wanted to fully support FXAA we new we’d have to do something about the loss of quality in some high res details.

Frame counter on the top right of the image!




Using full screen Sharpen Filters to get details back

This is where our Unsharp shader came to the rescue. Our Unsharp shader is a feature we talked a while back in one of our updates.

Unsharp Mask is a high quality sharpening algorithm. In City 17, Unsharp Mask brings out texture detail that is normally hidden or lost.

For FXAA we modified our Unsharp shader so it uses specific settings when FXAA is turned on, and reverts back when FXAA is turned off, or normal MSAA/other AA methods are in use. Lets look at the previous images again:


Unsharp FXAA

Here are a few more comparisons of just FXAA and Unsharp FXAA:



Unsharp FXAA

As always a lot of this is heavily wip. We have a couple of other expensive shaders on at the moment so the overall frame rate is effected by these somewhat costly shaders! However AA perf in all the shots is still indicative of actual performance costs.

So in the end, Unsharp gets us some nice quality back with FXAA that we lost. We are applying Unsharp post FXAA when FXAA is on. The Unsharp settings however are longed to be tweaked, and we shall continue to do that to find the right middle ground of bringing detail back, but also not sharpening the fuck out of it. You can expect to see FXAA in a media release later this autumn, accompanied by a gameplay video.


2 thoughts on “Development Blog: Programming – FXAA

  1. I’m not sure what to think about this. Image quality looks really crappy and unsharp isn’t helping that much. I’d rather play without AA to be honest.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: