HDR - Advanced Rendering - Shader Learning

Advanced Rendering

HDR

Task

In this task, you will work with a very bright scene rendered using deferred shading. Your goal is to support High Dynamic Range (HDR) rendering. Then apply tone mapping compression with an exposure value of 0.5 to ensure you can see the details in the bright parts of the scene.

Theory

Standard Dynamic Range (SDR) has limitations in representing the full range of brightness levels found in real-world scenes. SDR typically uses an 8-bit per channel format, which provides a luminance range of [0, 255]. This limited range can result in loss of detail in both very bright and very dark areas, making images appear less realistic.


High Dynamic Range (HDR) addresses these limitations by using a much wider range of luminance levels. HDR often uses floating-point data types for framebuffers, allowing for a luminance range that can extend to [0.0, 10000.0] or higher. This broader range preserves details in both bright and dark areas, resulting in more realistic and detailed images.


Exposure and Tone Mapping


Exposure refers to the amount of light that reaches the camera sensor or the virtual camera in a rendering engine. By adjusting the exposure, you can control how bright or dark an image appears. This is similar to adjusting the exposure settings on a camera to capture the desired amount of light.


Tone mapping is the process of converting High Dynamic Range (HDR) images to a format that can be displayed on devices with a lower dynamic range, such as standard monitors and screens.


How They Work Together


When rendering scenes in HDR, the luminance values can be very high, representing a wide range of brightness levels. However, most display devices cannot reproduce this full range. This is where tone mapping comes in. Tone mapping compresses the dynamic range of the HDR image to fit within the displayable range of the device.


Exposure is used in conjunction with tone mapping to control the overall brightness of the scene. Increasing exposure makes the image brighter, bringing out details in darker areas but potentially causing very bright areas to become overexposed. Decreasing exposure makes the image darker, preserving details in bright areas but potentially causing dark areas to lose detail.


A relatively simple tone mapping algorithm with exposure looks like this:

vec3 srdColor = 1.0 - exp(-hdrColor * exposure);

The higher the exposure value, the brighter the image will appear. The exp function is used to apply an exponential tone mapping curve, which helps to compress the dynamic range of the HDR image.


You can experiment with given tone mapping function and exposure value interactively on Desmos. This will allow you to visualize the compressing curve.