Here's another example that shows the dramatic differences. Also notice how the non gamma corrected images have that typical computer generated look.
Textures and photo's are usually pre-gamma corrected. This is WRONG! You need to have textures that use a linear scale. The will look too dark on your monitor but when you use them in your 3D scene and apply gamma correction afterwards the result is perfect.
How to apply gamma correction to your textures?
1. Clone the layer in photoshop
2. Set layer transparency to 'Multiply'
3. Save your image
This removes a gamma of 2.0 which is roughly close to the 2.2 or 1.8 that is used normally. Because there is no way to figure out the original gamma that was applied using a gamma of 2.0 is fine.
The easiest way to deal with gamma is this:
All photo/image material needs 'gamma uncorrection'. Example: a wood texture, photo....
Normal, light, depth maps are all linear so no correction needed
Only artist generated images are in non linear-space
If you uncorrect the gamma in photoshop you get banding errors (on 8 bit images)
The best way to do the uncorrection is to do it in your shader!!! here's the trick:
sampler2D SamDiffuseTexture0 = sampler_state
Texture = <DiffuseTexture0>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
SRGBTEXTURE = TRUE;
Simply use this sampler state for any texture you suspect will not be in linear space.
Now look at the images I created. They show all 4 possible cases and only one is correct!
The First image show the result if all the calculations and the textures are correct but there is no gamma applied to the final image. This image is simply too dark.
The Second image shows how it should be. The colors of the texture look nice and all the light blending and gradients are exacly as in real life.
In most games and 3D applications the 3rd image is the case: no gamma correction is applied at all! No correction in the textures and no correction in the final image. The color of the texture is ok but all the light blending and the gradient caused by lighting looks wrong. Also blending of two lights looks wrong! Look at the lighting of the ball and compare that to the second shot. Which one looks more real to you?
The Fourth image shows what happens if you correct the final image but you forget to modify your textures. All the calculations are fine. The lighting is fine and the blending is fine. The only problem is that tha floor texture looks a bit washed out. Maybe the floor should be a bit washed out but if we compare it to the original texture we can see this is not the case. The image looks fine except for the fact that the original color of the floor is not reproduced. Removing the gamma correction from the texture solves this(See second image).