HDR Lighting Basics: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Updated information. Half-Life 2 supports HDR since 2010. The mat_hdr_enabled command now returns if HDR is enabled rather then setting it.)
(→‎Running HDR in the Source Engine: - actually forgot that Black Mesa has mat_hdr_level 3.)
 
(21 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{otherlang2
{{LanguageBar}}
|jp = HDR_Lighting_Basics:jp
[[Category:HDR]][[Category:Level Design]]
|ru = HDR_Lighting_Basics:ru
|zh-cn= HDR_Lighting_Basics:zh-cn
}}
[[Category:Level Design]]
== Overview ==
== Overview ==


The Source Engine supports two independent sets of light maps in the .BSP, one for '''[[HDR|HDR]]''' (High Dynamic Range) and one for '''[http://en.wikipedia.org/wiki/Low_dynamic_range_rendering 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 more than double.
The Source Engine supports two independent sets of light maps in one compiled map: one for '''[[HDR|HDR]]''' (High Dynamic Range) and one for '''[[w:Low dynamic range rendering|LDR]]''' (Low Dynamic Range). With LDR lighting, mappers have to supplement dark areas with additional point and texture lights to help make these areas visible. HDR light maps alleviate this with auto-exposure calculations, removing the need for "fake" lights. Having both LDR and HDR lighting can more than double the size of the light map data in the final '''[[.bsp_(Source)|BSP]]''' file.
 
{{note|Mods made using the pre-August 2006 SDK code or pre-{{src06|4}} don't support HDR. Some [[Skybox|skyboxes]] on Source 2006, such as Half-Life 2, does not support HDR until {{src07|1}} or later.
LDR has been dropped with the release of {{l4dbranch|1}} and above. While {{portal2|1}} does unofficially support LDR lighting, the game defaults to HDR.


{{note|Mods made using the pre-August 2006 SDK code don't support HDR}}
Some games or mods, such as {{bms|1}}, only support HDR lighting.
}}


== Basic compiling of a HDR map ==
== Basic compiling of a HDR map ==


The simplest thing to get HDR working immediately is to recompile your existing map with the latest [[Vrad|Vrad]].
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:
If you're using the compiler built-in to Hammer, compiling your map with HDR is very simple:
Line 22: Line 22:
# Click '''OK''' to start the map compiling.
# Click '''OK''' to start the map compiling.


:{{Note|You will notice in the compile log window that [[Vrad|VRAD]] will run ''twice'' when HDR is enabled. This is correct. VRAD needs to build separate lighting for LDR and HDR modes.}}
:{{Note|You will notice in the compile log window that [[Vrad|VRAD]] will run ''twice'' when HDR is enabled. This is correct. VRAD needs to build separate lighting for LDR and HDR modes, except on games running {{l4dbranch|1}} or later.}}


== VRAD command-line arguments for HDR ==
== VRAD command-line arguments for HDR ==
Line 32: Line 32:
== Running HDR in the Source Engine ==
== Running HDR in the Source Engine ==


[[Image:hdr engine shortcut.png|thumb|250px|Set the engine HDR mode in the shortcut. Click to enlarge.]]
[[File:hdr engine shortcut.png|thumb|250px|Set the engine HDR mode in the shortcut. Click to enlarge.]]


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.
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 (set to "Full") 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:
HDR can also be enabled or disabled via the command-line when launching the game with the following command:


<code>+mat_hdr_level 0/1/2</code>
<code>+mat_hdr_level 0/1/2</code>
* Set to 0 for LDR, 1 for LDR and bloom on HDR maps, and 2 for full HDR and bloom on HDR maps. The lightmaps for the level will be reloaded if the value is changed while a map is loaded.
* Set to 0 for LDR, 1 for LDR with bloom on HDR maps and 2 for full HDR and bloom on HDR maps. The lightmaps for the level will be reloaded if the value is changed while a map is loaded.
 
{{Note|In multiplayer games and/or if the background map (e.g. {{code|background01}}) is loaded, the map will not be reloaded.}}
{{Note|{{Bms|2}} has a third option, called "'''HDR Expanded'''", which set the {{code|mat_hdr_level}} value to "3". The "HDR Expanded" option can be only selected through the old game UI (VGUI, using {{code|-oldgameui}} [[Launch options|launch option]]) or said console command.}}
{{Note|In Source 2006 games, after run the command above, you may also need to set {{code|mat_hdr_enable}} to {{code|1}} to enable HDR, and {{code|0}} to disable HDR.}}


=== Launching the game with HDR enabled ===
=== Launching the game with HDR enabled ===
Line 45: Line 49:
To force HDR and blooming to be enabled when running the game, add <code>+mat_hdr_level 2</code> via one of the following methods:
To force HDR and blooming to be enabled when running the game, add <code>+mat_hdr_level 2</code> via one of the following methods:
* In the Hammer '''Run Map''' dialog, adding the command to the '''Additional game parameters'''.
* 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.
* Right-clicking the game in the Steam Library and choosing '''Properties...''', and entering the command into the Launch Options.
* Creating a shortcut to the game on your desktop, then adding the command in the Windows Properties 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.
* If you use a .BAT batch file to run the engine, add the command to your batch file.
Line 53: Line 57:
== Building HDR and LDR cubemaps ==
== Building HDR and LDR cubemaps ==


For an HDR map, you need to run <code>buildcubemaps</code> in both HDR and LDR modes to build proper [[cubemaps]]:
;To build cubemaps for both LDR + HDR, see [[Cubemaps#Building cubemaps|Cubemaps - Building cubemaps section]].
# 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 <code>mat_hdr_level 2</code> at the console to enable HDR.
# Type <code>buildcubemaps</code> in the [[console|console]] to build the HDR cubemaps.
# Type <code>mat_hdr_level 0</code> to switch to LDR mode (it will take a moment to reload the lightmaps).
# Type <code>buildcubemaps</code> to build the LDR cubemaps.


You must do this every time you compile the map or the cubemaps will not appear correctly.
You must do this every time you compile the map or the cubemaps will not appear correctly.
Line 64: Line 63:
== Selecting an HDR skybox ==
== Selecting an HDR skybox ==


[[Image:hdr_map_properties.png|thumb|250px|Select a HDR skybox using Map Properties. Click to enlarge.]]
[[File:hdr_map_properties.png|thumb|250px|Select a HDR skybox using Map Properties. Click to enlarge.]]


Another thing you can do easily to improve the quality of the HDR effects is to select an ''HDR skybox''.
Another thing you can do easily to improve the quality of the HDR effects is to select an ''HDR skybox''.
Line 70: Line 69:
To select an HDR skybox in Hammer:
To select an HDR skybox in Hammer:
# Select '''Map properties''' from the [[Hammer_Map_Menu|Map menu]].
# Select '''Map properties''' from the [[Hammer_Map_Menu|Map menu]].
# Enter the name of an HDR skybox in the '''Skybox Texture Name''' field (e.g. <code>sky_example_hdr</code>). See [[Sky List|Sky List]] for a list of available skyboxes.
# Enter the name of an HDR skybox in the '''Skybox Texture Name''' field (e.g. <code>sky_example_hdr</code>). See [[List of skies]] for a list of available skyboxes.
# Recompile the map with the new skybox.
# Recompile the map with the new skybox.


Line 77: Line 76:




For a description on how to create new HDR skyboxes, see [[HDR Skybox Creation]].<br style="clear:both">
For a description on how to create new HDR skyboxes, see [[HDR Skybox Creation]].{{clr}}


== See also ==
== See also ==


[[HDR Lighting Settings]] - for more information on how to customize HDR settings.
* [[HDR Lighting Settings]] - for more information on how to customize HDR settings.
 
* [[HDR Skybox Creation]]
[[HDR Skybox Creation]]
* {{ent|env_tonemap_controller}}
 
* [[Advanced HDR]]
[[env_tonemap_controller|env_tonemap_controller]]
 
[[Advanced HDR]]

Latest revision as of 07:03, 4 January 2025

English (en)日本語 (ja)Русский (ru)中文 (zh)Translate (Translate)

Overview

The Source Engine supports two independent sets of light maps in one compiled map: one for HDR (High Dynamic Range) and one for LDR (Low Dynamic Range). With LDR lighting, mappers have to supplement dark areas with additional point and texture lights to help make these areas visible. HDR light maps alleviate this with auto-exposure calculations, removing the need for "fake" lights. Having both LDR and HDR lighting can more than double the size of the light map data in the final BSP file.

Note.pngNote:Mods made using the pre-August 2006 SDK code or pre-Source 2006 Source 2006 don't support HDR. Some skyboxes on Source 2006, such as Half-Life 2, does not support HDR until Source 2007 or later.

LDR has been dropped with the release of Left 4 Dead engine branch and above. While Portal 2 does unofficially support LDR lighting, the game defaults to HDR.

Some games or mods, such as Black Mesa, only support HDR lighting.

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:

  1. Open the .VMF file in the Hammer editor.
  2. Choose Run Map from the File Menu.
  3. Set BSP, VIS, and RAD options to Normal.
  4. Under the RAD section, check the HDR check box.
  5. Click OK to start the map compiling.
Note.pngNote: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, except on games running Left 4 Dead engine branch or later.

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: -both, -ldr, -hdr, and -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.

Warning.pngWarning:the use of -final can 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 light_environment.

Running HDR in the Source Engine

Set the engine HDR mode in the shortcut. Click to enlarge.

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 (set to "Full") 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:

+mat_hdr_level 0/1/2

  • Set to 0 for LDR, 1 for LDR with bloom on HDR maps and 2 for full HDR and bloom on HDR maps. The lightmaps for the level will be reloaded if the value is changed while a map is loaded.
Note.pngNote:In multiplayer games and/or if the background map (e.g. background01) is loaded, the map will not be reloaded.
Note.pngNote:Black Mesa Black Mesa has a third option, called "HDR Expanded", which set the mat_hdr_level value to "3". The "HDR Expanded" option can be only selected through the old game UI (VGUI, using -oldgameui launch option) or said console command.
Note.pngNote:In Source 2006 games, after run the command above, you may also need to set mat_hdr_enable to 1 to enable HDR, and 0 to disable HDR.

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 Library and choosing Properties..., and entering the command into the Launch Options.
  • 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.
Note.pngNote:This will not enable HDR rendering on video cards that cannot support HDR features.

Building HDR and LDR cubemaps

To build cubemaps for both LDR + HDR, see Cubemaps - Building cubemaps section.

You must do this every time you compile the map or the cubemaps will not appear correctly.

Selecting an HDR skybox

Select a HDR skybox using Map Properties. Click to enlarge.

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:

  1. Select Map properties from the Map menu.
  2. Enter the name of an HDR skybox in the Skybox Texture Name field (e.g. sky_example_hdr). See List of skies for a list of available skyboxes.
  3. Recompile the map with the new skybox.

The sample map sdk_hdr_example.vmf in the SDK samples includes the entities for this demonstration.

Note.pngNote:The file is located in the 'dod' map folder under sourcesdk_content.


For a description on how to create new HDR skyboxes, see HDR Skybox Creation.

See also