High dynamic range rendering

From GameStudio Wiki

Jump to: navigation, search
HDR Rendering in Half Life 2
Enlarge
HDR Rendering in Half Life 2
High dynamic range rendering (HDRR or HDR Rendering), also known as high dynamic range lighting, is the rendering of 3D computer graphics scenes by using lighting calculations done in a larger dynamic range. Video games benefit from this as it creates more realistic scenes than with the previous lighting model (referred to as "low dynamic range lighting" or "standard lighting").

Contents

Features

Preservation of detail

One of the primary features of HDR is that both dark and bright areas of a scene can be accurately represented. Without HDR (sometimes called low dynamic range, or LDR, in comparison), areas that are too dark are clipped to black and areas that are too bright are clipped to white. These are represented by the hardware as a floating point value of 0.0 and 1.0 for pure black and pure white, respectively.

Graphics processor company nVIDIA summarizes one of HDRR's features in three points:

  • Bright things can be really bright
  • Dark things can be really dark
  • And details can be seen in both

Preservation of light

Without HDRR, the sun and most lights are clipped to 100% (1.0 in the framebuffer). When this light is reflected the result must then be less than or equal to 1, since the reflected value is calculated by multiplying the original value by the surface reflectiveness, usually in the range 0 to 1. This gives the impression that the scene is dull or bland. However, using HDRR, the light produced by the sun and other lights can be represented with appropriately high values, exceeding the 1.0 clamping limit in the frame buffer, with the sun possibly being stored as high as 60000. When the light from them is reflected it will remain relatively high (even for very poor reflectors), which will be clipped to white or properly tonemapped when rendered.

Limits

Human eye

Lost Coast HDRR Demo from Vavle
Enlarge
Lost Coast HDRR Demo from Vavle
The human eye has a very high dynamic contrast ratio, around 1,000,000:1. Adaptation is achieved in part through adjustments of the iris and slow chemical changes, which take some time (ie, the delay in being able to see when switching from bright lighting to pitch darkness.) At any given time, the eye's static range is smaller, around 10,000:1. However, this is still generally higher than the static range achievable by most current display technology.

Output to displays

Current plasma displays are specified at a 10,000:1 contrast ratio (most are 50% lower). However, the contrast of commercial displays is measured as the ratio of a full white screen to a full black screen in a completely dark room. The simultaneous contrast of real content under normal viewing conditions is significantly lower.

Some increase in dynamic rendering in LCD monitors can be achieved by automatically reducing the backlight for dark scenes (LG calls it Digital Fine Contrast, Samsung are quoting "dynamic contrast ratio"), or having an array of brighter and darker LED backlights (BrightSide Technologies - now part of Dolby, and Samsung in development).

Otherwise HDR rendering systems have to map the full dynamic range to what the eye would see in the rendered situation. This tone mapping is done relative to what the virtual scene camera sees, combined with several full screen effects, e.g. to simulate dust in the air which is lit by direct sunlight in a dark cavern.

There are currently two graphical effects used to combat these limitations, tone mapping and light blooming, which are often used together.

Tone mapping

Tone mapping, in the context of graphics rendering, is a technique used to map colours from high dynamic range (in which lighting calculations are performed) to low dynamic range that matches the capabilities of a computer display device. Typically, the mapping is non-linear - it preserves enough range for dark colours and gradually limits the dynamic range for bright colours. This technique often produces visually appealing images with good overall detail and contrast. Various tone mapping operators exist, ranging from simple real-time methods used in computer games to more sophisticated techniques that attempt to imitate the perceptual response of the human visual system.

Light bloom

Light blooming exaggerates a bright spot in a scene. For example, a bright light in the background will appear to bleed over onto objects in the foreground. This is used to create an illusion to make the bright spot brighter than it really is.

HDRR through DirectX

Complex shader effects began their days with the release of Shader Model 1.0 with DirectX 8. Shader Model 1.0 illuminated 3D worlds with what is now called standard lighting. However, standard lighting had two problems:

  1. Lighting precision was confined to 8 bit integers, which limited the contrast ratio to 256:1. Using the HVS color model, the value (V), or brightness of a color has a range of 0 - 255. This means the brightest white (a value of 255) is only 256 levels brighter than the darkest shade above pure black (i.e.: value of 0).
  2. Lighting calculations were integer based, which didn't offer much accuracy because the real world is not confined to whole numbers. “Nature isn't clamped to [0..1], neither should CG”.

Before HDRR was fully developed and implemented, games would create an illusion of HDR by using light blooming and sometimes using an option called "Enhanced Contrast Settings".

On December 24, 2002, Microsoft released a new version of DirectX. DirectX 9.0 introduced Shader Model 2.0, which offered one of the necessary components to enable rendering of high dynamic range rendering: lighting precision was not limited to just 8-bits. Although 8-bits was the minimum in applications, programmers could choose up to a maximum of 24 bits for lighting precision. However, all calculations were still integer-based. One of the first graphics cards to support DirectX 9.0 natively was ATI's Radeon 9700, though the effect wasn't programmed into games for years afterwards. On August 23, 2003, Microsoft updated DirectX to DirectX 9.0b, which enabled the Pixel Shader 2.x (Extended) profile for ATI's Radeon X series and NVIDIA's GeForce FX series of graphics processing units.

On August 9, 2004, Microsoft updated DirectX once more to DirectX 9.0c. This also exposed the Shader Model 3.0 profile for HLSL. Shader Model 3.0's lighting precision, according to Dr. Sim Dietrich Jr., has a minimum of 32 bits as opposed to 2.0's 8-bit minimum. Also all lighting-precision calculations are now floating-point based. NVIDIA states that contrast ratios using Shader Model 3.0 can be as high as 65535:1 using 32-bit lighting precision. At first, HDRR was only possible on video cards capable of Shader-Model-3.0 effects, but software developers soon added compatibility for Shader Model 2.0. The difference between HDRR scenes rendered in Shader Models 3.0 and 2.0 is negligible at this point. As a side note, when referred to as Shader Model 3.0 HDR, HDRR is really done by FP16 blending. FP16 blending is not part of Shader Model 3.0, but is supported mostly by cards also capable of Shader Model 3.0 (exceptions include the GeForce 6200 series). FP16 blending can be used as a faster way to render HDR in video games.

Shader Model 4.0 is a feature of DirectX 10, which has been released with Windows Vista. Shader Model 4.0 will allow for 128-bit HDR rendering, as opposed to 64-bit HDR in Shader Model 3.0 (although this is theoretically possible under Shader Model 3.0).

Graphics cards which support HDRR

It is implied that because the minimum requirement for HDR rendering is Shader Model 2.0 (or in this case DirectX 9), any graphics card that supports Shader Model 2.0 can do HDR rendering. However, HDRR may greatly impact the performance of the software using it; refer to your software's recommended specifications in order to find specifications for acceptable performance.