Antialiasing

Originally posted to Shawn Hargreaves Blog on MSDN, Wednesday, April 20, 2011

I've been meaning to write about antialiasing for a while, but now I sit down to do that I realize I have too much to say for a single article. So this post is the introduction to a series.

Antialiasing is one of the most important yet least widely understood areas of computer graphics. If I had a penny for every time I heard the developer of a 2D game say "I turned on antialiasing but my sprites still look jaggy", well, I'd be up to six or even seven pennies by now!

The thing is, "antialiasing" is really too vague a term to mean anything at all! The important word is "aliasing", which is surprisingly hard to pin down. Dictionary.com gives two definitions:

  1. Jagged distortions in curves and diagonal lines in computer graphics caused by limited or diminished screen resolution.
  2. Distortion in a reproduced sound wave caused by a low sampling rate during the recording of the sound signal as digital information.

These are both examples of aliasing, but really just special cases of a more generic underlying meaning:

Artifacts created when a source value (which can be either analog or digital) is replaced by a digital approximation.

We perform such approximations in many places when rendering computer graphics:

  1. We approximate the shape of arbitrary objects as a list of triangles
  2. We approximate the shape of a triangle as a grid of dots (screen pixels)
  3. We approximate arbitrary images as grids of dots (textures)
  4. We frequently approximate one grid of dots as another different grid of dots (scaling images, rotating, or mapping them onto 3D geometry)
  5. Our shader programs use many digital approximations, as varied as the things for which we use shaders (ie. basically infinite)
  6. We approximate moving objects as a series of static images (animation)

Any or all of these approximations can cause ugly aliasing artifacts. Antialiasing really just means "a technique used to avoid or cover up an aliasing problem". Since there are many different kinds of aliasing, and many techniques to overcome each of them, it should be no surprise that there are many, many different forms of antialiasing. And of course, they only work if you choose an antialiasing technique that matches the specific kind of aliasing you were suffering from in the first place!

Ok, that was kinda dry. Next up, more theory. Then after that, some practical examples.

Blog index   -   Back to my homepage