🌈

Gamma

Tagsgraphics

Overview

The intensity of light generated by a monitor is not a linear function in terms of the applied input signal.

A gamma of 2.2 is typically used for computer monitors and televisions.

The response of a monitor follows approximately a pow(x, 2.2) curve (red on the graph).

The horizontal axis is the original luminance of the image.

The vertical axis is the luminance of the image as it displays on a monitor.

Middle tones to darker parts of images display darker than they actually are.

Images are stored in gamma-corrected space, so that they look correct on a monitor.

The gamma-correction applied to the images cancel out the gamma-curve of the monitor, leading to a linear response.

In game development proceeds, the following problems can occur because of gamma:

Linear Workflow

The problems related to gamma can be resolved by handling images in a linear color space.

This method is called linear workflow.

In a renderer, the lighting calculations are performed in linear space, to get correct results when working with light intensities.

When the image is output from the frame buffer to the display, the frame buffer is gamma-corrected to cancel the monitor gamma.

It produces the correct output on the monitor.

Renderer

Depending on the render device, there are two ways to properly handle gamma-correction.

Textures

When loading diffuse/albedo textures, undo the gamma-correction.

⚠️
Only textures with light intensity data should use the sRGB format.

Frame Buffer