A Different Light: Gamma-Corrected Compositing

A simple introduction to gamma-corrected compositing.
Chris and Trish Meyer

The image on the left is a normal computer crossfade; the image on the right uses linear blending - note how the bright areas are emphasized. Footage courtesy Artbeats.

Most of us have been navigating the waters of computer graphics with the assumption that the world is flat. And it's remarkable how well we've done with this fundamentally flawed assumption. However, some of you may have heard whisperings that the world is actually round - often couched in terms of how important it is to understand the subject of gamma, and to composite within a "linear light" model.

An exhaustive treatment of the subject of gamma requires something more akin to a book than a column - along with several bottles of aspirin. Here, we're going to give a very light introduction to the subject of gamma (no pun intended), and demonstrate how you can experiment with these concepts in existing programs such as After Effects, Motion, and combustion. Although visual effects artists - with their pursuit of reality - are often obsessed with accurate recreations, motion graphics artists - with their pursuit of surreality - may find that breaking the rules yields a more interesting result.

(Note: This article was originally written before After Effects natively supported gamma-corrected compositing. As of After Effects 7 and later, there are checkboxes in File > Project Settings which allow you to do this without the extra layers and expressions detailed below. However, the following is still highly useful for understanding the underlying concepts, implementing linear gamma in other programs, and creating your own custom gamma working spaces to create new looks. At the end of this article, we'll discuss those checkboxes in After Effects in more detail.)

When 18 = 50

In most computer software, a 50% luminance value is intended to be perceived on a monitor as "50% gray:" an equal mix of black and white. This is logical and intuitive; many processing functions such as Brightness and Contrast as well as blending modes are based around this. Too bad it's not the way light really works.

In reality, our eyes are very sensitive to low light levels. As some of you know, an "18% gray card" or a similar section of an exposure chart is called this because 18% of available light is being reflected back to the viewer. However, we mentally perceive it as "middle" (or 50%) gray. The signal capture and presentation chain, including cameras and monitors, have corrections built in to bend this reality to the computer's representation that a 50/50 black/white mix is really middle gray. The number most often used is a gamma correction of 2.2 (although different computer systems and file formats can use different values; 2.5 is also a common reference value).

Thanks to these gyrations, we can successfully perform most of our graphics work in the computer's gamma-corrected space. However, if you are trying to accurately recreate the way light works, some of the way colors mix in the computer are off a bit. Therefore, more users are finding ways to undo the computer-based gamma corrections so that they can composite images in "linear light."

Homemade Gamma Correction

It is relatively easy to hotwire your software to allow you to composite in linear light space. If your software allows you to select a higher bit depth, use it; 16-bit linear mode will reduce banding, while floating point mode will allow preservation of extreme shadows and highlights. (The eLin plug-in suite distributed by Red Giant Software simulates the benefits of floating point in After Effects 6.5, while also performing gamma-corrected compositing.) As an experiment, follow these steps:

  • Create a simple crossfade between two images that have good bright and dark areas. Render a reference copy of this transition.

  • Set the gamma for each source footage item to be 0.4545 (1 ÷ 2.2). You can do this in After Effects or Motion by applying a Levels effect to each layer (in Motion, if you are using the Fade In/Out behavior to create the crossfade, apply Levels before the behavior). In combustion, you do this by applying a color correction operator to the layer and adjusting its Histogram.

  • Set the gamma for the final composite to 2.2, which reintroduces the gamma the computer requires - after the processing (in this case, the crossfade) has been done. In After Effects, this can be done by creating an Adjustment Layer above all the other layers, with Levels applied. In Motion, apply Levels to the Layer containing your media and crossfade. In combustion, apply a color correction operator to the Output Node.

  • Render a copy of this new transition, and compare it to your reference render. If possible, set up a side-by-side or split screen between the two renders for easy comparison (see the figures at the top of this page)

If you look closely at the two images at the top of this page, you should notice that in the "linear light" render, the lighter areas in the second clip appear more quickly as that clip fades up, and that the lighter areas in the first clip disappear later. This more accurately mimics our eyes' sensitivity to lower light levels, and is sometimes known as an "optical fade." Aside from being more accurate, this uneven crossfade can look more interesting as well. This phenomenon of emphasizing the brighter areas also shows itself in a number of other ways, such as when an object with motion blur crosses in front of another (the blur trails will appear brighter), or when you have feathered edges or glows around objects.

Prev Next »