Eye Adaptation (Auto-Exposure)

Eye Adaptation, or automatic exposure, causes the exposure of the scene to automatically adjust to recreate the effect experienced as human eyes adjust when going from a bright environment into a dark environment or vice versa.

Camera Exposure

Editor Settings
In Unreal Engine version 4.19, the Level Editor exposure control has been changed for an EV100 slider and a game settings check-box in the view mode menu. When Game Settings is checked, the level viewport will use the in-game setting configuration for exposure behavior (see next section). Otherwise, the EV100 slider allows a user override, with a range of -10 to 20, supporting very dark to very bright scenes, using realistic scene illumination.

Click for full image

For other viewports than the level viewport, the "Game Settings" check-box is replaced by an "Auto" check-box and implements an automatic exposure behavior.
Game Setting
The in-game settings for exposure are controlled within the post process settings. In 4.19, some options have been renamed but otherwise previous settings are compatible. The following image shows the three metering mode supported, as well as which options are enabled in each mode and their default settings.
Click for full image

Auto Exposure Histogram behaves as the previous histogram mode. Auto Exposure Basic is the previous basic mode, with the addition that the calibration constant is now exposed in the advanced tab. The Calibration Constant defines the target average brightness of the image after exposure, and is used for white balancing.

Otherwise, 4.19 adds a new metering mode named Manual, where the value of the camera exposure is defined by new camera settings: Shutter Speed (1/t), ISO (S) and Aperture (N). The formula used to compute the camera exposure scale is :

  • Exposure = 1 / (1.2 * 2^EV100)
 With:
  • EV100 = log2( N²/t * 100/S )

The Exposure here defines the relationship between the scene surface luminance (L in cd/m²) and pixel brightness (B), before the tonemapper and exposure compensation (see below) are applied:
  • B = Exposure * L 
This can be verified by disabling the Tonemapper through the Show Flags and inspecting the scene brightness with the pixel inspector. Note that the EV100 editor overrides directly sets the EV100 in this equation.
Click for full image
At last, the Exposure Compensation (ExpComp) camera setting defines an additional scale of (2^ExpComp) on top of the exposure computed from the current metering mode, except when using the EV100 Editor overrides.

Pre-Exposure

UE4 can now apply the previous frame scene exposure within the shaders before writing to the scene color. This enables the engine to render the scene with a range similar to the one of the final color (after exposure). This reduces the risks of arithmetic overflow for low precision render target formats when using very bright lights. This also increases the quality of the Auto Exposure Basic metering mode.

The amount of exposure applied in the shaders is called pre-exposure. The feature can be enabled through the console variable r.UsePreExposure. The pre-exposure can also be overridden through r.EyeAdaptation.PreExposureOverride command.


Eye Adaption

The above image shows an example of going from a bright environment to a dark environment.

Property

Description

Shutter Speed (1/s)

The camera shutter speed in seconds.

ISO

The camera sensor sensitivity.

Aperture (F-Stop)

Defines the size of the opening for the camera lens. Using larger numbers will reduce the DOF effect.

Exposure Compensation

Logarithmic adjustment for the exposure. Only used if a tonemapper is specified. 0: no adjustment, -1:2x darker, -2:4 darker, 1:2x brighter, 2:4x brighter.

Metering Mode

Lumiance computation method.

Min Brightness

This value limits the lower brightness that the eye adapts within. Value must be greater than 0 and should be less than or equal to EyeAdaptationMaxBrightness. Actual values depend on the HDR range the content is using.

Max Brightness

This value limits the upper brightness that the eye adapts within. Value must be greater than 0 and should be greater than or equal to EyeAdaptationMinBrightness. Actual values depend on the HDR range the content is using.

Speed Up

The speed at which the adaptation occurs from a dark environment to a bright environment.

Speed Down

The speed at which the adaptation occurs from a bright environment to a dark environment.

Low Percent

The eye adaptation will adapt to a value extracted from the luminance histogram of the scene color. The value defines the lower percentage of the histogram that is used to find the average scene luminance. We want to avoid clamping of the bright image parts so it is best to ignore most of the dark areas. e.g. 80 avoid 80% of the darks. Values should be in the range [0, 100].

Values in the range 70-80 give the best results.

High Percent

The eye adaptation will adapt to a value extracted from the luminance histogram of the scene color. The value defines the upper percentage of the histogram that is used to find the average scene luminance. We want to clip a few percent of the upper range off as it is ok to have some bright pixels (usually sun). Values should be in the range [0, 100]. 

Values in the range 80-98 give the best results.

Histogram Log Min

Temporary exposed until we found good values, -8: 1/256, -10: 1/1024

Histogram Log Max

Temporary exposed until we found good values, 4: 16, 8: 256

Calibration Constant

Calibration constant for 18% Albedo.

Eye adaptation is histogram based and uses the following method:

  • Let's say EyeAdaptationLowPercent is 80% and EyeAdaptationHighPercent is 95%.
  • Now we search the histogram for two values:
    • 80% of the screen pixels are darker than luminance value A.
    • 95% of the screen pixels are darker than luminance value B.
    • The average between A and B is the current scene luminance (C).
  • Over time, the eye will adapt to this value. Adapting to a dark environment is usually perceived slower so we have two values to adjust: EyeAdaptionSpeedUp and EyeAdaptionSpeedDown.
  • In order to not adapt completely to very dark or very bright environments, we clamp the adaptation within a defined range: EyeAdaptationMinBrightness and EyeAdaptationMaxBrightness.

Histogram

The Histogram properties are used by the automatic eye adaptation feature which looks at a histogram of the scene colors to adapt the camera or the eye to a scene. This histogram can be seen by using the console command ShowFlag.VisualizeHDR 1.

Histogram

The above image shows the Histogram visualize that can be activated using the command ShowFlag.VisualizeHDR 1.

Property

Description

Histogram Log Min

Defines the lower bounds for the brightness range of the generated histogram.

Histogram Log Max

Defines the upper bounds for the brightness range of the generated histogram.