Original Link: https://www.anandtech.com/show/1803

Valve's High Dynamic Range Explored

by Josh Venning on September 30, 2005 12:05 AM EST


Introduction

Now is an interesting time for PC gaming. With the release of NVIDIA's 7800 series as well as the upcoming ATI x1000 series graphics cards, the potential for graphics in games is only just starting to be realized. Games like F.E.A.R, Call of Duty 2, and Age of Empires 3 promise to take PC gaming to a new level graphically, and frankly, we couldn't be happier about it. We seem to have a similar situation right now of when ATI's RADEON 9700 series launched, and the new hardware allowed game developers the freedom to experiment with new ideas; therefore, creating a new generation of games. One particular graphics engine that has had an important impact for developers lately is Half life 2's Source engine, and though it has been around for a while now, the developers have recently decided to give the engine a bit of a face-lift, metaphorically speaking.

That's right, Valve has updated their source engine to enable something called High Dynamic Range, and the first two applications to implement this are Day of Defeat (a popular Half life 2 mod) and the upcoming new level for Half life 2: the Lost Coast. High dynamic range is basically a more realistic way to implement lighting in a three-dimensional world. With HDR, light sources will appear brighter, and other effects like blooming are possible. HDR, along with other things like auto-exposure, take lighting to a new level, further enhancing the realism of a virtual world. To give you a better idea of the concept behind HDR, here is a quote from Paul Debevec:
"The 'dynamic range' of a scene is the contrast ratio between its brightest and darkest parts. A plate of evenly-lit mashed potatoes outside on a cloudy day is low-dynamic range. The interior of an ornate cathedral with light streaming in through its stained-glass windows is high dynamic range. In fact, any scene in which the light sources can be seen directly is high dynamic range."
Obviously, one of the first things that we were concerned about regarding this upgrade was how this would affect performance. We weren't sure quite what to expect, but we did some testing on multiple ATI and NVIDIA graphics cards, and we'll take a look at the results later on. First, let's go a bit more in-depth into the technology.



Valve’s HDR Source Implementation

We recently had the opportunity to head up to Washington to visit with Valve and talk about the new additions to the Source engine. After the issues and delays getting Half-Life 2 out the door, Valve's philosophy on game development has shifted. Rather than setting a long term goal to take one project from start to finish, Gabe and the team will be setting shorter term release goals. The idea is that five one-year projects on the road to a five-year destination can help keep them on track. We can also look forward to incremental updates to the Source engine allowing other game developers to benefit constantly from new technology, bringing us nice little treats like HDR.

As a result of the past year of development, Valve has met their goal to incorporate HDR into their Source engine and now we get to reap the benefits. But before we look at performance numbers and image quality, we will take a look behind the scenes to find out what is going on. At first glance, it is clear that Valve has added the usual blooming features that we would expect from HDR rendering, but there are a couple of new features that Valve has added to keep it interesting.

As we have said, HDR generally speaks to representable contrast in a scene. The way that developers handle this is to represent brightness data beyond the capabilities of the display (for instance, the sun is much brighter than a light bulb, but both could be the same color with traditional rendering). That isn't to say that a game or other HDR applications can make your monitor brighter than possible, but rather that internal light sources and objects in an application can be represented by more brightness than can be displayed. The final rendered image is then (in current incarnations) tonemapped down to a standard 8-bit display colorspace.

This allows objects that are only partially reflective to still reflect enough light to be as bright as what the monitor can display. For instance, a rock in a game may be 20% reflective. Normally rendered, even if a bright light source is perfectly reflected to the camera, the rock can only be 20% as bright as what the monitor can display. If the light source shining on a rock is 5 times brighter than the display, the rock will still be able to reflect a light that shines at 100% of the monitor's brightness.

In addition to this feature, very bright lights also make it more difficult for our eyes to clearly see objects occluding (or nearly occluding) the light source. The effect that game developers use to portray this "bloom" is to blur the light onto the foreground object. The high dynamic range allows light sources to be identified and properly handled.

One of the easiest ways to implement HDR from scratch is to use a floating point format with all art assets designed around HDR. Unfortunately, current hardware isn't able to handle full floating point data as fast as other methods, and no hardware (that is currently out) can allow MSAA to run on a floating point render target. The size of the artwork needed to make this work is also huge and floating point assets cannot be compressed currently using built-in hardware texture compression techniques. On top of this, Valve is working with an existing engine designed around Half-Life 2, so this method would also require a redesign of art assets and how they worked. These problems and others add up to make it difficult to incorporate this technology in the Source engine.

So, rather than carry HDR data through the entire pipeline and all art assets, Valve made a different choice that gives a good balance of performance and HDR characteristics. Data is represented in fp16 or integer 4.12 linear space through in light sources cube maps and static lighting data. This method is unable to store overbright information directly, but Valve is still able to add a blooming shader. Our understanding is that this method eliminates the possibility for transmissive or refracted overbright data (we won't be able to see a bloom inside a stained glass window or from sand under water through which light has passed). But blooming light sources and direct light reflection is still possible and well used in the Source engine.

But on top of blooming, Source also allows for dynamic tonemapping that works something like an auto exposure or a human pupil. This helps maintain a high dynamic range effect without overbright data by allowing the natural lighting of a scene to dictate the exposure of the rendered image. This means that in a dark room, the tonemapping scale will adjust to (essentially) make the brightest parts of the darkness bright enough to see with the natural light. The mapping isn't linear so that very dark pixels are brightened less than lighter pixels. In a bright room, the opposite is true, but in both cases, the definition of HDR is fulfilled: the contrast ratio between bright and dark areas on the same image is greatly increased.

To handle the tonemapping, Valve artists design three different images for the skybox at three different exposures. HDR light maps are built from the environment using a global illumination model and radiosity that uses 8 bounces. The process of generating HDR light maps takes a while, but (together with the HDR cube maps built from the HDR light maps and the skybox) this also allows Valve to represent correctly the lighting of the world. Entire maps can be lit with only the sun as a light source. Normally, to brighten hallways or dark areas away from static lights, small point lights are used. This is no longer necessary and can actually make the scene look bad. Not to worry though, level designers can build HDR lighting information into the same BSP as non-HDR lighting data and the engine will select the right ones to use depending on the mode in which the game is running.

The HDR SDK for source will ship when the Lost Coast level is released. This will allow modders to implement HDR levels in their games by adding the three exposure sky maps, building HDR and non-HDR lighting into levels, and setting bloom and exposure ranges per area if desired. While bloom and exposure can be handled automatically, it is nice to give the developer control over this.

And now that we've seen how it's done, let's take a look at the end result in performance and image quality.



Test Setup

While Call of Duty and the impressive-looking Call of Duty 2 are our current WW2 games of choice, Day of Defeat is a great Half life 2 mod, and with the recent release of Day of Defeat: Source by Valve, it's looking even better. Just in case you didn't already know, Day of Defeat is a multiplayer-only mod of the original Half life game, which has been out for quite a while. As with Counter Strike, Valve updated the mod to run on the Half life 2 engine, keeping the gameplay intact, but adding new physics and graphical elements, resulting in a much higher quality game.

The gameplay of Day of Defeat is much like counterstrike; fast-paced, first-person shooter action, only set in WW2 instead of present day. There are currently only four maps available and they are generally all close-quarter and set in urban areas. With the maximum limit of 16 players on each team combined with the small maps, the action can get very intense, and because of the realism factor (as with Counterstrike), you'll find yourself dying very quickly after just a couple of hits if you aren't careful. Fortunately though, unlike Counterstrike, you won't have to wait until the end of the round to respawn, which keeps the action going.

After we managed to record a demo of the game, we ran some benchmarks to see of the achieved framerates between different cards with different HDR settings. There are basically 3 different HDR settings: all HDR effects enabled, bloom only enabled (when available), and none. We tested all three of these settings on a total of six cards: 3 ATI and 3 NVIDIA cards. For ATI's, we chose the X850 XT, the X800 XT, and the X800. The NVIDIA parts that we used were the 7800 GTX, 7800 GT, and the 6600 GT. All of the tests were run at a resolution of 1600x1200 with no AA or AF.

Now, let's take a look at the performance tests.



Day of Defeat Performance Tests

Half life 2 is one of those games that usually gives us pretty good framerates on a wide variety of cards. It's interesting to see how Day of Defeat: Source seems to up the ante (so to speak) in the graphics department, giving our cards a work-out even without the HDR effects enabled. The fact that the fps of all the cards without HDR enabled is similar suggests that there is some CPU limitation to the game. It's also safe to say that turning on the full HDR mode causes quite a significant performance hit, especially in the 6600 GT, the only 128 MB card that we tested.

In the past, we've noticed that ATI performs a little better than NVIDIA in Half life 2, and not surprisingly, we see the same thing here with Day of Defeat. While it's true that the 7800 GTX gets higher framerates than any of the ATI cards, keep in mind that NVIDIA's 7800 series is in a class above even the fastest ATI cards out now (although not for very long), and the fact that the framerates on the ATI cards aren't far behind says something here.

Day of Defeat

You can see that without HDR enabled, the ATI cards get better framerates than all of the NVIDIA cards except the 7800 GTX. This illustrates how well ATI handles this game engine, and the fact that all the framerates are fairly close together here imply some CPU limitation for this game.

Day of Defeat

Here, we see how the bloom effect starts to put a strain on the lower memory cards. The X800 and, in particular, the 6600 GT are the most memory-limited of these cards, but ATI's X800 does significantly better than the 6600 GT.

Day of Defeat

The only card that doesn't see a large drop in framerate with full HDR enabled is the 7800 GTX, followed closely by the 7800 GT. This shows that the newer architectures are able to handle Valve's HDR implimentation a little better than earlier hardware. There is also evidence that HDR uses up a lot of memory and/or bandwidth. Some sacrifices in quality/resolution will have to be made on 128-bit/128MB cards such as the 6600 GT in order to run this mode successfully.



Image Comparison

For those used to the look of Half life 2 and Counterstrike: Source, the new HDR effects in Day of Defeat probably won't blow your socks off. The enhancements are subtle, but you can definitely tell that they are there. Most noticeable is the auto exposure effect, which simulates the way that the eye can be blinded slightly by stepping into the sun from a dark area. While some might complain that this is annoying, it seems to us that annoying or not, it adds another dimension to the gameplay. In other words, in a real battle, the sun in your eyes will affect your aim, thus adding to the realism of the game. The bloom effect is noticeable as well, and it is very effective at making light in the game seem brighter than it really is.

Below are some images that compare the different modes. The top-most image is with no HDR enabled, the middle image is with bloom only enabled, and the bottom is full HDR enabled.


Click to enlarge.


Click to enlarge.


Click to enlarge.

At a glance, it's easy to tell that the image with full HDR enabled is brighter than the one with no HDR enabled, but the differences between the images are subtle. Pay special attention to the glare of the sun on the rifle, as this gives you a sense of the different levels of lighting. Notice how in the middle image (with bloom only enabled), the lighter colors in the distance on the buildings and sand are much brighter and create more contrast to the scene. And with the bottom-most image (full HDR enabled), you can see how the combination of the bloom and auto-exposure brighten the scene even more. This may seem very bright, but keep in mind that this is one of the widest spaces in any of the four maps. The game smoothly brightens or darkens the screen depending on where you are in the map, and the highest contrast ratios are observed when looking out of a dark area into a bright one (or vice versa).



Final Words

Performance-wise, we've seen how the HDR effects have a significant impact on performance in Day of Defeat, and in some cases, the impact was surprising. On cards like the X800 and the 6600 GT, it's interesting to see how HDR requires the kind of resources that would effectively cut your framerate in half, especially given the general subtlety of the lighting effects.

We've also shown that ATI seems to handle Valve's implementation of HDR better than NVIDIA, and if we could have tested with one of the next-gen ATI cards, the 7800 GTX would have assuredly been beaten out for the highest fps. But most of the cards that we tested were able to handle the performance hit from the HDR settings. Unfortunately, if you have a less-powerful card than these that we've tested, you will probably have to either turn down your resolution or forego the HDR.

While the HDR effects in the game are subtle, we should mention that after a bit of play testing, we found that our eyes tended to adapt to the auto-exposure and bloom effects and everything seemed to blend together in a way which added a lot to the gameplay. In fact, when playing the game with the HDR settings turned off, the game looks surprisingly flat by comparison. We are impressed at how Valve was able to enhance the source engine in such a major way, while keeping everything subtle enough to sometimes forget that it's there. Much like the Matrix, it's hard to understand until you experience it for yourself.

If you played much Day of Defeat before the upgrade, the source version will no doubt make you very happy, just as Counterstrike: Source did when it first came out. However, by now, the Halflife 2 engine isn't quite as new and exciting as it was when CS Source came out, and in spite of the new HDR effects, the "wow" factor isn't quite as pronounced. Still, there is no denying that the new lighting effects add a kind of sparkle to the HL2 graphics, which, while still excellent, had seemed to have lost a bit of luster with time. These graphical enhancements are certainly a step forward, and it will be very interesting to see how these new effects will be used in games of the near future.

We will also be excited to see if Valve is able to stick to their guns and continue to enhance Source on the way to their next major project. This new method certainly seems to make more sense to us as Valve's engine customers will have access to a better quality engine and gamers will reap the benefits of new technology faster. We look forward to the surprises Valve has in store for us in the future.

Log in

Don't have an account? Sign up now