Search public documentation:
Document Changelog: Created by Daniel Wright.
There's a ton of information on the internet about gamma correction and why it is necessary, for an overview see Gamma Correction on Wikipedia, or even better the GPU Gems 3 chapter. In summary, there are two reasons to convert colors into gamma space:
- To compensate for various monitor's non-linear response (output luminance is not proportional to input intensity).
- To get better precision in the darks where it matters most when colors need to be quantized, as the human eye is more sensitive to small changes in dark colors than detail in light colors.
The gamma-correct (meaning that all math on colors happens in linear space) rendering pipeline in UE3 that is used on all platforms is:
- Input color textures are stored in gamma space (diffuse, specular, etc) to get better precision in the darks. These textures are sampled with sRGB read (D3DSAMP_SRGBTEXTURE in D3D9) which does the conversion from gamma to linear space for free, using the graphics hardware. This is controlled with the SRGB UTexture property.
- Once we have the linear space color, it can be used in various lighting equations with the expected linear result.
- The scene color render target stores linear color. This is important because it means that alpha blending happens in linear space. If we stored scene color in gamma space, alpha blending would happen in that color space and the results would be very different from what you would expect. The downside to storing scene color in linear space is that it needs significantly more precision, an FP 16 render target is necessary to avoid banding in the darks.
- At the end of the post process chain, linear scene color is gamma corrected BEFORE writing scene color to an 8 bit per pixel render target/backbuffer. This is the standard gamma correction to compensate for the non-linear response of common monitors. This happens in UberPostProcessBlendPixelShader.usf or GammaCorrectionPixelShader.usf if there is no UberPostProcess node in the post process chain.
As of June 2011 Gamma correction is supported on mobile devices allowing the creation of levels and content with consistent lighting across platforms.