Search public documentation:


Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Rendering > Gamma Correction in UE3

Gamma Correction in UE3

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.

Gamma in UE3

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.

One exception from this is that UI is currently blended in gamma space for legacy reasons.

Gamma on Mobile

As of June 2011

Gamma correction is supported on mobile devices allowing the creation of levels and content with consistent lighting across platforms.


To Enable Mobile Gamma Correction

Gamma correction on mobile platforms is not enabled by default. To make use of gamma correction for mobile games, enable the Use Gamma Correction property in the World Properties for your map(s).


Performance Considerations

Gamma correction on mobile devices can cause a fairly noticeable impact on performance. It is mainly meant as a feature for use on future mobile devices. Currently, iPad 2 is the only device that is really capable of running games using gamma correction.