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.

Index Test Setup
Comments Locked

47 Comments

View All Comments

  • eastvillager - Monday, October 3, 2005 - link

    Screenshots don't do it justice, nor does 'trying' it for 5 minutes, deciding you don't like it and then going back to your old config. It adds considerably to the experience, for me at least.
  • Marsumane - Sunday, October 2, 2005 - link

    Im not so sure I agree that the NV cards are not as good at implementing this engine's HDR effects due to the fact that the NV cards are all one of two extremes. They are either the highest end cards which crush the entire ati lineup and dont provide a good comparison, or they are the lowest-tier card in the roundup with no real direct competition. I mean just look at the memory bandwidth of the 6600gt as well as the pixel pipelines and ull find that it has no real comparison to the ati cards benched. Furthermore, I dont see how the ATI cards have anything to compare to either. It seems as if the top NV card had the least impact from implementing HDR and it just scaled down the list fairly evenly. Maybe the conclusion was made based upon the numbers of cards not posted, but from my perception, based on reading the numbers on here, I'm not seeing any real reason to state that NV cards do worse than ATI cards in this comparison. Furthermore, look at the x800 from bloom to full HDR. The 6600gt had less of a percentage hit as compared to the x800. Maybe I missed something, but does anyone else see this? Please correct me if im wrong.
  • gamara - Tuesday, October 4, 2005 - link

    I caught that too. The GTX dropped 2.5 FPS from none to full. The x850 XT dropped 15.8. For those that like percentages, the NVidia dropped 3.5% while the ATI dropped 22.3%. How exactly is that better? I like how the GT went from second to last with no HDR to second best with full. I will concede the 6600 GT dropped over 50% with the full effect, but when FSAA first hit the scene the thought of running a low-mid range with AA was OBSURD.
  • islandtechengineers - Sunday, October 2, 2005 - link

    i know why... factors factors factors..... anyway its still not nice to only release if with DOD and the lost coast..... to bad if couldnt be released for all :-{ even as a update which I'm sure will arrive..
  • Busithoth - Saturday, October 1, 2005 - link

    well, I'm running a 2405 with an x800xt, and HDR made the difference between smooth as butter and less than that. I liked the effect, but the fast pace of things in DoD made it really annoying to me more than anything else. Given time, I can get used to it, of course, but I'd rather be in single-player doing so (come on lost coast), then I can try my hand at MP again.

    I can't understand the argument that it's an aid to players, though.
    More realistic, I'll grant that. but how exactly does it help anyone but campers, I don't know. Besides the fact that people can just turn it off, it's an act of faith to assume that someone's gonna be blinded coming around a corner. (as I was multiple times when it was still enabled)

    altogether though, HDR on, I thought this game was bliss for the eyes.
  • Frackal - Friday, September 30, 2005 - link

    Why do computer users bitch so much

    I love the HDR, it does look more realistic and moreover BF2 looks crappy after playing DOD-S. BF2 was my fav. game until DOD-S, now its a tough call because BF2's gameplay is better but it doesn't look that great anymore.

    HDR is the future
  • OvErHeAtInG - Saturday, October 1, 2005 - link

    Yes. Most of the people complaining about HDR haven't even tried it, it seems. See Wilson's post above, you have to see it in motion. Frankly the screenshots don't look anything like the game in motion. Has anyone here played GT4 for the PS2? They implemented some sort of advanced light thingies like this to great effect. The whole point is how something (wet road surface at sunrise) would look totally different depending on the angle you're looking at it from; blinding white one second, black the next, just like in real life.


    Has anyone else tried HL2 after they added HDR to some of the maps? Looks good. And like they said *if you read up on it*, this is really a partial implementation of HDR, worked into the source engine. Of course it's really only worth it if you have a high-end videocard, otherwise you'll have to disable AA in order to get playable frames. In a very-aliased game like HL2, it's a tough call which I'd rather have :)
  • coomar - Saturday, October 1, 2005 - link

    with a 6800gt, i was playing everything high at 1280x1024 with 2x aa/8af i think with hdr on
  • gravy - Friday, September 30, 2005 - link

    the 6600GT is obviously going to be limited, but why put a 6600GT up with X800's and the likes of 7800's ??!!

    might as well have thrown in a 9800XT to compare with the 6600GT, and then a 6800GT to compare with the X800's

    i hope to see a follow up to this with these cards as well as the upcoming X1800's and X1600's, a nice well rounded comparison to see how both players are fairing with the new technology

    perhaps a Lost Coast review will be just that as it will likely be more demanding than DOD:S ??

    thanks for a nice read
  • ViperV990 - Friday, September 30, 2005 - link

    What is the point of all these fancy lights if there are no shadows? I am talking about the boat and the tank traps in the screenshots.

Log in

Don't have an account? Sign up now