I'm going through the online version of the GPU Gems books held on the nvidia website and this chapter concludes with a nice, compact set of recommendations on the generally mind-twisting problem of gamma correction:
I thought I'd share it here as it is as much of an issue during asset generation (i.e. creating textures outside of Terasology) as it is in dealing with them within shaders.
- Assume that most game players are using uncalibrated, uncorrected monitors that can roughly be characterized by an exponential response with gamma = 2.2. (For an even higher-quality end-user experience: Have your game setup display a gamma calibration chart and let the user choose a good gamma value.)
- When performing lookups from nonlinear textures (those that look "right" on uncorrected monitors) that represent light or color values, raise the results to the power gamma to yield a linear value that can be used by your shader. Do not make this adjustment for values already in a linear color space, such as certain high-dynamic-range light maps or images containing normals, bump heights, or other noncolor data. Use sRGB texture formats, if possible, for increased performance and correct texture filtering on GeForce 8 GPUs (and later).
- Apply a gamma correction (that is, raise to power 1/gamma) to the final pixel values as the very last step before displaying them. Use sRGB frame-buffer extensions for efficient automatic gamma correction with proper blending.
I thought I'd share it here as it is as much of an issue during asset generation (i.e. creating textures outside of Terasology) as it is in dealing with them within shaders.