What’s Gamma?
In monitors, the relation between the input voltage and its output luminosity is nonlinear. It usually follows a curve with a power of 2.2 (pow(x,2.2)). That curve is commonly known as Gamma.
The Gamma curve power varies across display devices but is usually averaged to 2.2.
When you send a value of 0.5 to your monitor to be displayed, it is displayed with a luminosity of 0.218.
So in order to compensate that and display the image preceptually linear we need to apply Gamma correction.
For a monitor with a Gamma of 2.2, the inverse curve 1/2.2 should be applied in order to display an image correctly.

Size matters!
Gamma correction was not originally designed to “fix the error of monitors”.
Human eye in normal conditions is more sensitive to darkness than it is to brightness.
In order to display a range of colors that would appear linear to the human eye, we would require much more information in dark intensities than in bright. Applying a Gamma curve of approximately 2.2 can effectively represent a perceptually linear range of colors in 8 bits.
If we wanted to create a real linear range of colors we would need a higher amount of data to make it appear linear to the human eye.
Therefore there is a difference between what’s technically linear and perceptually linear.
Original Ramp

Linear enconded in 5 bits

Gamma encoded in 5 bits

It just happened by coincidence that the Gamma of monitors is very close to the inverse of the perception of intensity of human eye.
Input, file, output…
Digital cameras usually don’t apply Gamma correction, the file format is instead the responsible for that.
JPEG file format applies Gamma correction when storing images. RAW file format saves the image linearly with a Gamma of 1.0. MPEG files are Gamma encoded to optimize storage and playback bandwidth.
That’s why when you display a RAW image in a computer it looks dark. The image is saved in linear space and the graphics card is applying a pow(x, 2.2) curve.
So in order to see in your monitor the same that you were seeing when taking the picture, images need to be Gamma encoded and Gamma decoded using the same curve.
So let’s see an ideal case: You take a picture with your camera, the picture is Gamma enconded to pow(x, 1/2.2), you open the picture in your PC, the graphics card Gamma decodes the image using pow(x, 2.2), the image is displayed in your monitor.
How does that affect Game developers ?
Gamma affect Game developers in 2 specific steps: shader calculations and image display.
In modern game engines, textures are read and modified and written through shaders.
The maths behind shaders are done assuming linear inputs, therefore if we input Gamma corrected textures the maths will be wrong.
It could seam at first sight that this is just subtle detail but, trust me, the results of using a correct Gamma pipeline are very noticeable.

Image from GPU Gems 3
On the other hand we need to Gamma correct the image before displaying it on the screen. The problem here is that the Gamma of the many display devices out there is different. So the only thing we can do is assume a Gamma of 2.2 if you are on Xbox360, PS3 or PC. And add options in-game to let the user fine tune the Gamma for their own monitor or TV.
How do we provide the shaders with Linear Space textures?
We have seen that in order to convert a Gamma corrected image, back to Linear Space, we need to apply the inverse Gamma curve.
So the first thing we need to have is a consistent Gamma across all our textures.
In order to accomplish that you will need all your artist’s monitors to be calibrated so that they all display Gamma equally. So first thing, go and buy a monitor calibration device.
Set all your monitors to sRGB to make sure that you are applying a standard and well known Gamma.
Use a sRGB Profile in Photoshop, so your textures will be saved with Gamma embedded information.
Then adjust your textures freely so they look good in Photoshop.
Take into account this when painting textures: Unreal Texturing Guidelines.
After that you will have consistently authored textures in sRGB Gamma Space.
Now the engine can have some consistent information to work with when converting textures back to Linear Space.
Take into account that virtually generated images are already in Linear Space, i.e: Normal Maps, Light Maps, etc. So they don’t need to be Gamma corrected, and can be input directly to the Shaders.
Once the textures are passed to the shaders in Linear Space, all mathematical operations such as Lighting, Alpha Blending, etc. can be done properly.
The engine before displaying the final image to the screen will apply Gamma Correction to the entire frame.
Further reading:
Gamma Correction – Wikipedia
GPU Gems 3 – Chapter 3
John Hable – Linear Space Lighting (Naughty Dog)
Gamma Correction in Unreal Engine