HDR Lighting

Lighting in the real world contains a very high dynamic range (HDR) of luminance values. The real world has about 10 orders of dynamic range (DR) for luminance values spread across the spectrum of darkness to brightness. On the other hand, a computer screen has a very limited display gamut (or range of luminance values): approximately two orders of dynamic range. The challenge to producing HDR rendered images is to map the real world HDR values into the limited gamut of a computer screen.

Tone mapping is the technique used by DirectX for mapping HDR information into a more limited range. Tone mapping applied to CGI rendering can dramatically improve the amount of lighting detail rendered, allowing details in the darkest areas to be seen, and providing contrast in areas that are so bright, they appear burned. The resulting scenes render with far more visible lighting detail.

HDRLighting Sample is a SDK sample that demonstrates HDR lighting.

Tone Mapping

Tone mapping generally simulates optical phenomena that can not be caused by the DR of the monitor. Examples of this are flares or blooming (which are mostly properties of lenses), the blue shift that happens in the human eye in low light conditions, and other adaptations that are a result of the biochemistry of the eye. If the DR of the display were large enough, tone mapping would not be as neccessary, except for providing artistic effects or some of the properties of a camera lens or a charge coupled device (CCD).

Tone mapping divides the range of luminance values in a scene into a set of zones. Each zone encompasses a range of luminance values.

HDR uses the following terms:

To calculate luminance from RGB values, use this:

L = 0.27R + 0.67G + 0.06B;

The log-average luminance is a useful approximation for the key of a scene. A general equation looks like this:

Lw = exp[ 1 / N( sum[ log( delta + Lw( x, y ) ) ] ) ]

Where:

To map this to a middle-gray value, here is a luminance scaling operator:

L( x, y ) = a * Lw( x, y ) / Lw

Where:

And finally, here is a simple tone mapping operator for compressing the high luminances:

Ld( x, y ) = L( x, y ) / ( 1 + L( x, y ) )

Where:

This operator scales high luminances by 1/L and low luminances by 1. For more details, see the following paper.

Reinhard, Erik, Mike Stark, Peter Shirley, and James Ferwerda. "Photographic Tone Reproduction for Digital Images". ACM Transactions on Graphics (TOG), Proceedings of the 29th Annual Conference on Computer Graphics and Interactive Techniques (SIGGRAPH), pp. 267-276. New York, NY: ACM Press, 2002.