HDR Lighting Basics
The Source Engine supports two independent sets of light maps in the .BSP, one for HDR (High Dynamic Range) and one for LDR (Low Dynamic Range). LDR lighting is the same lighting from HL2. With LDR lighting, we often had to supplement dark areas with additional point and texture lights to help make these areas visible. Now, with HDR, we can simply use auto-exposure to enhance most of these dark areas without the "fake" lights. The one drawback to having two sets of lightmaps is the increased .BSP size, which in some cases may be more than double.
Basic compiling of a HDR map
The simplest thing to get HDR working immediately is to recompile your existing map with the latest Vrad.
If you're using the compiler built-in to Hammer, compiling your map with HDR is very simple:
- Open the .VMF file in the Hammer editor.
- Choose Run Map from the File Menu.
- Set BSP, VIS, and RAD options to Normal.
- Under the RAD section, check the HDR check box.
- Click OK to start the map compiling.
- Note: You will notice in the compile log window that VRAD will run twice when HDR is enabled. This is correct. VRAD needs to build separate lighting for LDR and HDR modes.
VRAD command-line arguments for HDR
If you don't use the Hammer built-in compiler, you can use the following commands with VRAD for use on the command-line:
-final. Now a .BSP file can contain two sets of lightmaps for both LDR and HDR. To compile both add the command
-both to VRAD. If you want to compile just the LDR version add
-ldr, and for HDR only add
-hdr. Another new command that was added for this release is
-final which is used to increase the quality of skylight and indirect light by spending more CPU time firing rays.
-finalcan dramatically increase the compile time for VRAD, and so it is mainly intended for final map compiles. The biggest quality impact of this option is the reduction of lighting artifacts that are commonly found in indoor spaces lit primarily from
Running HDR in the Source Engine
The Source engine can be run in both HDR and LDR modes. If a map has been compiled with HDR lightmaps, and HDR is enabled in the Video Settings for the game, HDR will be automatically enabled when the map is loaded. Due to the separate lightmaps that are created for HDR and LDR, cubemaps must be built for both HDR and LDR modes.
HDR can also be enabled or disabled via the command-line when launching the game with the following command:
- Set to 0 for LDR, 1 for LDR and bloom on HDR maps, 2 for full HDR and bloom on HDR maps, and 3 for float backbuffer (The floattoscreen shader is not properly writed, so you will see screen turns green if you are using 3). The lightmaps for the level will be reloaded if the value is changed while a map is loaded.
Launching the game with HDR enabled
To force HDR and blooming to be enabled when running the game, add
+mat_hdr_level 2 via one of the following methods:
- In the Hammer Run Map dialog, adding the command to the Additional game parameters.
- Right-clicking the game in the Steam Games window and choosing Properties, click Set launch options... and entering the command into the dialog.
- Creating a shortcut to the game on your desktop, then adding the command in the Windows Properties dialog.
- If you use a .BAT batch file to run the engine, add the command to your batch file.
Building HDR and LDR cubemaps
For an HDR map, you need to run
buildcubemaps in both HDR and LDR modes to build proper cubemaps:
- Compile your level with the Vrad HDR option enabled.
- Load the level in the game. The engine should default to the HDR version of the map. If you have HDR disabled, type
mat_hdr_level 2at the console to enable HDR.
buildcubemapsin the console to build the HDR cubemaps.
mat_hdr_level 0to switch to LDR mode (it will take a moment to reload the lightmaps).
buildcubemapsto build the LDR cubemaps.
You must do this every time you compile the map or the cubemaps will not appear correctly.
Selecting an HDR skybox
Another thing you can do easily to improve the quality of the HDR effects is to select an HDR skybox.
To select an HDR skybox in Hammer:
- Select Map properties from the Map menu.
- Enter the name of an HDR skybox in the Skybox Texture Name field (e.g.
sky_example_hdr). See Sky List for a list of available skyboxes.
- Recompile the map with the new skybox.
The sample map
sdk_hdr_example.vmf in the SDK samples includes the entities for this demonstration.
For a description on how to create new HDR skyboxes, see HDR Skybox Creation.
HDR Lighting Settings - for more information on how to customize HDR settings.