|
High Dynamic Range Environment Mapping On Mainstream Graphics Hardware
ImplementationDemoIncluded with this article is an implementation of HDR file loading into half-precision floating point textures and image key calculations utilizing the HDRFormats demo from the Microsoft DirectX* SDK [10]. The demo also allows interactive adjustment of the midzone_luminance (referred to as MIDDLE_GREY in the demo) from Equation 5 to allow the reader to better understand how adjustments to the midzone luminance value affect the resulting image. Additionally, we noticed that a pure implementation of the mathematics of tone mapping for each image could result in images that changed tone too dramatically from frame to frame. Therefore, we limit the amount the image_key can vary from frame to frame to prevent the image from changing too drastically, allowing the image to 'settle' to the correct value after a few iterations. The result was much more aesthetically pleasing, and is a more accurate depiction of what the light does in situations where the light does vary dramatically. RGBE FormatThe RGBE format is suitable for storage of high dynamic imagery for real-time graphics and was used for our implementation. RGBE was originally created by Greg Ward for his Radiance software package [15]. The format consists of an 8-bit mantissa for each Red, Green, and Blue channel along with an 8-bit exponent for 32 bits per pixel as seen in Figure 4-1. They share the exponent thus reducing the storage required significantly when comparing to a 32 bit per channel format. (32 bits per float * 3 = 92 bits per pixel vs. 32 bits per pixel). A downside is a lack of dynamic resolution between color channels since you are sharing the exponent for all of the color channels. ![]() Figure 4-1. 32-Bit RGBE Format Figure 4-1 depicts the 8 bytes per channel for Red, Green, Blue and a shared exponent value that is used to represent the HDR images in our examples. The shared exponent is in the channel typically reserved for the alpha channel in an image. Encoding and decoding using the RGBE format is easy as the method High Dynamic Range Image Key CalculationTo avoid having to transfer the image over the bus to compute an image key we calculate this on the CPU using an image_key calculation included in the example based on [17]’s luminance tone reproduction operator. Deciding whether to calculate the image key on the CPU or the GPU is application, graphics card, and graphics bus dependent. Pixel Shader for Integrated GraphicsWe have also written a pixel shader in HLSL that supports using HDR images for environment mapping on Intel 965 Express Chipset and Mobile Intel 965 Express Chipset family Integrated Graphics. This chipset family is optimized for DirectX 9.0c support and uses DirectX's Intel-architecture-optimized Platform Specific Graphics Processing (PSGP) Vertex Shader 3.0 and Pixel Shader 2.0. The tone mapping described earlier in the pixel shader translates RGBE images into floating-point textures. The complete shader source code is provided in the effects file in the demo. HDR Samples in the Microsoft DirectX 9.0 SDKMicrosoft has provided examples in the DirectX SDK that demonstrate some of the above techniques [10]. They provide examples that show HDR in several different scenarios. HDRCubemap is a demonstration of HDR lighting and cubic environment mapping that uses floating-point cube textures to store values where the total amount of light illuminating a surface is greater than 1.0. HDRFormats shows a technique for displaying HDR images on hardware that is not capable of using floating-point textures. The most notable difference apart from our usage of floating-point texture support, is that this sample is not tied to the DDS file format, therefore any HDR image that is encoded by HDRShop can be used. HDRLighting demonstrates blue shift under low light and bloom under intense lighting conditions as well as under and overexposing the camera.
|