Cubemaps

From Valve Developer Community
Jump to navigation Jump to search
English (en)Español (es)Français (fr)Português do Brasil (pt-br)Русский (ru)中文 (zh)Translate (Translate)
Env cubemap.png
An example of specular reflections on some models (exaggerated through r_showenvcubemap).

A cubemap is a texture that represents a three-dimensional rendering of an area. Source Source uses env_cubemap entities as sampling points to generate these textures, which are then integrated into the map file. Cubemaps, when built, are reflected on materials that use the $envmap parameter (surfaces such as reflective glass, tiles, water, etc.) A map without built or existing env_cubemap entities will instead use other kinds of "reflections" (such as default cubemap texture, see below) that don't properly depict it, or appear broken (missing textures, reflections appear bright, etc...).


Building cubemaps

This default cubemap texture will appear if you skip building blank cubemaps during VBSP process.

Building cubemaps is the process of generating textures to use as reflections. For technical reasons, this process isn't automated (Except in Mapbase) and is up to the user to do so; until then, existing env_cubemap entities will remain unused and the map, depending on the game, will display either:

  • Blank (black) texture (which basically make it look the same as mat_specular/reflections being disabled)
    • During compilation, VBSP will generates blank cubemap textures.
    • If you skip VBSP blank cubemap generation (either by using Mapbase VBSP without adding -autocubemap, using Slammin' Source Map Tools VBSP with -nodefaultcubemap, or if you deleted the cubemaps, it will display the missing or generic texture instead, and building cubemaps for first time (without disabling mat_specular) will instead generate blank textures, until building it again second time, so don't forget to disable it. mat_specular must be also disabled prior to loading the map, otherwise disabling them after the map have been loaded, will cause buildcubemaps to generate blank textures aswell.
  • Default cubemap textures (see image on right)
    • If the cubemap is missing, the game first tries to fall back to LDR cubemaps (and fails), so the game ended up using this texture instead.
  • Cubemaps appear bright (HDR only)
    • If HDR version of the cubemap isn't present, the game will fall back to LDR version, which will cause it to appear bright on HDR.
  • Missing textures as reflections
    • If the cubemap is missing and the game fails to use the default cubemap texture for some reasons, missing texture will show up as reflections.

Before building

Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
Modern Source games, namely Portal 2 and P2:CE, do not need all these complicated params and steps, at least in my experience -Equalizer (talk) 10:56, 22 March 2024 (PDT)

Also some Source games (such as CS:S and HL2), doesn't appear to require cheats to be enabled to build cubemaps. Deleting cubemaps is probably not needed (atleast for SP games), since this would require you to use mat_specular 0, otherwise buildcubemaps will instead generate blank texture until you run the command again. -leonidakarlach (talk) 02:50, 25 August 2024 (PDT) - Edited 16 Feb 2025.

Left 4 Dead 2 Left 4 Dead 2 also does not require anything, other than maybe turning shader quality to medium. But it's not always required. Just loading the map and running Buildcubemaps is often enough. --MrFunreal (talk) 02:23, 11 February 2025 (PST)
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
Icon-Important.pngImportant:Maps for Source 2013 Source 2013 games and others, such as Counter-Strike: Source Counter-Strike: Source, are known to include pre-built, blank cubemaps after being compiled (even if there are no env_cubemap entities in them). In Mapbase Mapbase, blank cubemaps are not automatically generated by default.
For multiplayer games and most Source 2013 (or earlier) titles, deleting cubemaps will be required (in order to make sure cubemaps are properly written to the BSP). Deleting cubemaps, while not required, is recommended for Left 4 Dead engine branch games or later (and HDR-only games) since VBSP generates blank LDR cubemap texture that increase BSP file size while being unused anyway in those games. Deleting cubemaps isn't required for Half-Life 2 or Half-Life 2: Deathmatch (both games as of 20th anniversary version) .
Icon-Important.pngImportant:(Confirmed on Half-Life 2) If you skip building blank cubemaps during map compilation (VBSP), building cubemaps for the first time (while the default cubemap texture or missing texture is being displayed), without disabling mat_specular, will cause the game to generate blank textures instead, until you run the buildcubemaps command again, which would properly show the newly built cubemaps. This is likely to avoid the default cubemap texture (see image above) from being baked into newly generated cubemaps when mat_specular is set to 1 (Enabled).
Icon-Important.pngImportant:
  • To build cubemaps, your game's screen resolution needs to be at least 4 times higher than the highest size of an existing env_cubemap, or else attempting to build them will either fail or even cause the game to crash.
    For example, if the highest env_cubemap sizes 128x128, a resolution no lower than 512x512 will be required. (128 × 4 = 512 -> 720x576 (as a valid resolution) or higher)
  • If you have other anti-aliasing methods (such as SGSSAA, OGSSAA/SSAA, etc.) forced through GPU driver, other than in-game AA and/or driver FXAA, please disable them and enable the in-game AA instead to avoid cubemaps being slowly built. This also applies to running the game at higher resolutions (such as 4K), which will cause cubemaps to be slowly built on weaker hardware. Running the game at lower resolutions (like 1080p) and/or disable AA (other than in-game AA), and disable any FPS cap, will significantly speed up building cubemaps progress.
  • The game may appear to freeze or become unresponsive during the process of building cubemaps, and the amount of time depends on various factors (amount of env_cubemap(s), cubemap sizes, CPU usage/utilization and framerate). For successful results, don't switch away from the game until it's done.
    Also, if you have the game running on windowed/borderless windowed mode, clicking on the game while building cubemaps will cause the windows to freeze with "Not Responding" on the titlebar (even through the game is still building cubemaps). To avoid this, it's highly recommended that you run the game in (exclusive) fullscreen mode.
Warning.pngWarning:
  • FOR PEOPLE WITH EPILEPSY: Building cubemaps on games running on Vulkan, such as Left 4 Dead 2 Left 4 Dead 2, causes the screen to flash black and white violently. Also on systems with faster CPU/GPU (while running the game on lower resolutions such as 1080p instead of 4K), building HDR cubemaps even with Direct3D 9/DX9, will also flash the screen black and white repeatedly much faster.
  • If the nav_show_ladder_bounds command was used before building cubemaps, the green boxes will also be baked into the cubemap.
  • If you are building cubemaps for Half-Life 2 Half-Life 2 (except episodes) after the 20th Anniversary Update, you must follow the instructions here. Also building cubemaps in Half-Life 2 without removing some NPCs will cause sprites light from them to be baked into cubemaps.
Tip.pngTip:
  • env_cubemap entities allow for generating higher- or lower-quality reflections, though the game's texture quality also comes into play; consider maxing out your game's visual settings (set texture, models, shaders, shadow details to High/Very High) before building cubemaps.
  • Running the game at lower resolution (while making sure your screen resolutions are 4 times larger) and disabling FPS cap (both in game, graphics driver and software like RTSS) can speed up building cubemaps progress.
  • Bind mat_hdr_level 0, mat_hdr_level 2, building_cubemaps 1 to any numpad keys, and buildcubemaps to numpad Enter key, so you don't have to manually type and submit most of these command on console.
  • If you are using Mapbase Mapbase, you can add -autocubemap to launch game ($game_exe) command line in Hammer. The game will automatically build cubemaps
  • Slammin' Source Map Tools Slammin' VBSP VBSP features the -nodefaultcubemap command, which skips automatically generating skybox cubemaps on map compile.

LDR

Note.pngNote:This step doesn't apply to Left 4 Dead Left 4 Dead nor Counter-Strike: Global Offensive Counter-Strike: Global Offensive as their maps are compiled in HDR mode only. While Portal 2 Portal 2 does support LDR, the game uses HDR by default, so we recommend building cubemaps in HDR only.

Building cubemaps in a map compiled in LDR (Low Dynamic Range) mode will generate textures only for that mode, regardless of your game's High Dynamic Range video setting. To build the cubemaps, submit the following commands into the game's console:

Command Description
mat_specular 0 Turns reflections off, which is necessary if using only one iteration of buildcubemaps, and if all cubemaps has been deleted.
It also meant that disabling reflections would avoid some case where missing textures or default cubemap texture (materials/engine/defaultcubemap.vtf, aka a desert with orange sunset sky), might ended up reflected on the cubemap itself.
Note.pngNote:If you let VBSP generate blank cubemap and you build cubemap without this command, it will build (and written cubemaps to BSP) just fine (atleast in Half-Life 2), however, if you deleted the cubemaps and run buildcubemaps, without disable mat_specular, it will instead generate and write blank texture, until you run buildcubemaps second time. mat_specular must be also disabled prior to loading the map, otherwise disabling them after the map have been loaded, will cause buildcubemaps to generate blank textures aswell.
map map_name Loads the map; replace "map_name" with the map's actual name
sv_cheats 1 Enables the use of cheat commands; required to build cubemaps
Note.pngNote:Half-Life 2 and Half-Life 2: Deathmatch (since 20th anniversary), doesn't require cheats to build cubemaps, so this step can be skipped. In Counter-Strike: Source, buildcubemaps can be also built without enabling cheats, however, mat_reloadallmaterials (command that requires sv_cheats 1) must be run once in order to display the newly built-cubemaps, since cubemap textures may not be automatically loaded when you load up the map manually. Confirm if other games also require cheats to build cubemaps.
buildcubemaps Begins building cubemaps. Optionally, specify the number of iterations (e.g.: buildcubemaps 2 (default is 1))
disconnect Unloads the map and returns to the main menu
mat_specular 1 Turns reflections on, then follow the step below, or optionally you can repeat the process again by following instructions on Improve reflections by rebuilding cubemaps.
map map_name Loads the map again, your cubemaps should display after doing these steps.
mat_reloadallmaterials
(requires sv_cheats 1)
In some games, such as Counter-Strike: Source, if it doesn't display new cubemap textures after loading the map, run this command to display the newly-built cubemaps. This command may run automatically when you load up the map while cheats is already enabled.

LDR + HDR

Building cubemaps in Source 2006 - Source 2013 game, with a map compiled with HDR support needs to be performed twice - once for each mode (HDR and LDR). As opposed to an LDR map's case, your game's High Dynamic Range video setting has to be set to "Full" to build HDR cubemaps, and to "None" to build LDR ones (or using the mat_hdr_level command. To build the cubemaps for both LDR + HDR, submit the following commands into the game's console:

Note.pngNote:Maps built on Left 4 Dead, or later (and some third-party Source games), does not requires building cubemaps on LDR. See #HDR
Command Description
mat_specular 0 Turns reflections off, which is necessary if using only one iteration of buildcubemaps, and if all cubemaps has been deleted.
It also meant that disabling reflections would avoid some case where missing textures or default cubemap texture (materials/engine/defaultcubemap.vtf, aka a desert with orange sunset sky), might ended up reflected on the cubemap itself.
Note.pngNote:This command is flagged as "launcher"-only in Left 4 Dead and Left 4 Dead 2, you can use the following command instead:
Left 4 Dead sm_cvar mat_specular 0 command (with SourceMod installed) or
Left 4 Dead 2 script Convars.SetValue("mat_specular", "0") (using VScript).
Note.pngNote:If you let VBSP generate blank cubemap and you build cubemap without this command, it will build (and written cubemaps to BSP) just fine (atleast in Half-Life 2), however, if you deleted the cubemaps and run buildcubemaps, without disable mat_specular, it will instead generate and write blank texture, until you run buildcubemaps second time. mat_specular must be also disabled prior to loading the map, otherwise disabling them after the map have been loaded, will cause buildcubemaps to generate blank textures aswell.
map map_name Loads the map; replace "map_name" with the map's actual name
sv_cheats 1 Enables the use of cheat commands; required to build cubemaps
Note.pngNote:Half-Life 2 and Half-Life 2: Deathmatch (since 20th anniversary), doesn't require cheats to build cubemaps, so this step can be skipped. In Counter-Strike: Source, buildcubemaps can be also built without enabling cheats, however, mat_reloadallmaterials (command that requires sv_cheats 1) must be run once in order to display the newly built-cubemaps, since cubemap textures may not be automatically loaded when you load up the map manually. Confirm if other games also require cheats to build cubemaps.
building_cubemaps 1 Sets HDR exposure to a consistent value, which will make sure that one cubemap won't look as bright or darker than others. This will automatically reset back to 0 after cubemaps are built.
Note.pngNote:This command is flagged as "launcher"-only in Left 4 Dead and Left 4 Dead 2, you can use the following command instead:
Left 4 Dead sm_cvar building_cubemaps 1 command (with SourceMod installed) or
Left 4 Dead 2 script Convars.SetValue("building_cubemaps", "1") (using VScript).
buildcubemaps Begins building cubemaps. Optionally, specify the number of iterations (e.g.: buildcubemaps 2 (default is 1))
In singleplayer games, the map will be automatically reloaded after building cubemaps.
disconnect Unloads the map and returns to the main menu
sv_cheats 0 Disables cheat commands; prevents command mat_reloadallmaterials from unnecessarily self-executing (which briefly freezes the game)
mat_hdr_level 0 Switches to LDR mode (from HDR); submit mat_hdr_level 2 instead if LDR cubemaps were built first
map map_name Loads the map again to build cubemaps for the new mode
sv_cheats 1
buildcubemaps Begins building cubemaps for the new mode
disconnect
mat_specular 1 Turns reflections on, then follow the step below, or optionally you can repeat the process again by following instructions on Improve reflections by rebuilding cubemaps.
mat_hdr_level 0/1/2 If necessary, switches back to the mode it was before having submitted mat_hdr_level 0/2
map map_name Loads the map again, your cubemaps should display after doing these steps.
mat_reloadallmaterials
(requires sv_cheats 1)
or Alt + Tab / Restart game
In some games, such as Counter-Strike: Source, if it doesn't display new cubemap textures after loading the map, run this command to display the newly-built cubemaps. This command may run automatically when you load up the map while cheats is already enabled.
If this command does not reload cubemaps in-game, you can instead Alt + Tab while in fullscreen or simply restart the game can sometime reload the texture (and display the new cubemap) aswell.

HDR

This section is for games running on the Left 4 Dead engine branch Left 4 Dead engine branch and later, or engine branches that only support HDR (such as Xengine). To build cubemaps in HDR only, submit the following commands into the game's console:

Command Description
mat_specular 0 Turns reflections off, which is necessary if using only one iteration of buildcubemaps, and if all cubemaps has been deleted.
It also meant that disabling reflections would avoid some case where missing textures or default cubemap texture (materials/engine/defaultcubemap.vtf, aka a desert with orange sunset sky), might ended up reflected on the cubemap itself.
Note.pngNote:This command is flagged as "launcher"-only in Left 4 Dead and Left 4 Dead 2, you can use the following command instead:
Left 4 Dead sm_cvar mat_specular 0 command (with SourceMod installed) or
Left 4 Dead 2 script Convars.SetValue("mat_specular", "0") (using VScript).
Note.pngNote:If you let VBSP generate blank cubemap and you build cubemap without this command, it will build (and written cubemaps to BSP) just fine (atleast in Half-Life 2), however, if you deleted the cubemaps and run buildcubemaps, without disable mat_specular, it will instead generate blank texture, until you run buildcubemaps second time. mat_specular must be also disabled prior to loading the map, otherwise disabling them after the map have been loaded, will cause buildcubemaps to generate blank textures aswell.
map map_name Loads the map; replace "map_name" with the map's actual name
sv_cheats 1 Enables the use of cheat commands; required to build cubemaps
Note.pngNote:Half-Life 2 and Half-Life 2: Deathmatch (since 20th anniversary), doesn't require cheats to build cubemaps, so this step can be skipped. In Counter-Strike: Source, buildcubemaps can be also built without enabling cheats, however, mat_reloadallmaterials (command that requires sv_cheats 1) must be run once in order to display the newly built-cubemaps, since cubemap textures may not be automatically loaded when you load up the map manually. Confirm if other games also require cheats to build cubemaps.
building_cubemaps 1 Sets HDR exposure to a consistent value, which will make sure that one cubemap won't look as bright or darker than others. This will automatically reset back to 0 after cubemaps are built.
Note.pngNote:This command is flagged as "launcher"-only in Left 4 Dead and Left 4 Dead 2, you can use the following command instead:
Left 4 Dead sm_cvar building_cubemaps 1 command (with SourceMod installed) or
Left 4 Dead 2 script Convars.SetValue("building_cubemaps", "1") (using VScript).
buildcubemaps Begins building cubemaps. Optionally, specify the number of iterations (e.g.: buildcubemaps 2 (default is 1))
In singleplayer games, the map will be automatically reloaded after building cubemaps.
disconnect Unloads the map and returns to the main menu
mat_specular 1 Turns reflections on, then follow the step below, or optionally you can repeat the process again by following instructions on Improve reflections by rebuilding cubemaps.
map map_name Loads the map again, your cubemaps should display after doing these steps.
mat_reloadallmaterials
(requires sv_cheats 1)
or Alt + Tab / Restart game
In some games, such as Counter-Strike: Source, if it doesn't display new cubemap textures after loading the map, run this command to display the newly-built cubemaps. This command may run automatically when you load up the map while cheats is already enabled. In Left 4 Dead (or some Source games), this command may not reload cubemaps in-game, so instead Alt + Tab while in fullscreen or simply restart the game can sometime reload the texture (and display the new cubemap) aswell.

Building cubemaps in specific games

Black Mesa

To build cubemaps in Black Mesa Black Mesa maps, the game has to be launched with these parameters: -oldgameui -dev -console +r_4way_use_fast_normals 0
Then, load the map, follow the instructions on HDR section.

After building cubemaps, you can proceed to #Improve reflections by rebuilding cubemaps or simply quit the game, then launch the game again without the command line argument.

Half-Life: Source

Note.pngNote:Some materials/textures in HL:S will use reflections located on 🖿environment maps folder instead. So even if you already build cubemaps, it only displays in some materials that use $envmap env_cubemap.
Icon-Bug.pngBug:Building cubemaps in older version of Half-Life: Source Half-Life: Source is currently not possible as their textures, despite being generated, aren't embedded into the map file afterward.

This is fixed with the Half-Life 2 20th anniversary update, which also applies to HL:S. Issue is not affected on Half-Life Deathmatch: Source.

PlacementTip.pngWorkaround:Move the map file into the 🖿maps folder of a game in the same engine branch (such as Half-Life 2 Half-Life 2), build its cubemaps in that game, then move the file back into Half-Life: Source's folder.
  [todo tested in ?]

Half-Life 2

All versions
Icon-Bug.pngBug:NPCs such as npc_combine_camera and npc_turret_ceiling, while completely invisible when building cubemaps, will have it's sprite lights baked into cubemaps.
PlacementTip.pngWorkaround:Enable sv_cheats 1 then remove the NPCs above using ent_remove_all npc_combine_camera;ent_remove_all npc_turret_ceiling command before running buildcubemaps.
20th anniversary only
Icon-Bug.pngBug:Building cubemaps in Half-Life 2 Half-Life 2, Half-Life 2: Episode One Half-Life 2: Episode One and Half-Life 2: Episode Two Half-Life 2: Episode Two, after 20th anniversary update, might fail. In Half-Life 2's case, the game may access the wrong directory (example: episodic/maps), instead of hl2/maps, preventing the cubemaps from embedded into the map file.

You may also see this error message generated on the console: vtex failed to compile cubemap! Unable to remove \steamapps\common\half-life 2\episodic\materials\maps\<map name>\<cubemap location>.vtf

PlacementTip.pngWorkaround:Launch Half-Life 2 with -game hl2 command line argument (or go to steamapps\common\Half-Life 2 and run hl2.exe directly). For Episodes, launch the game through Steam > Tools (or using -game episodic or -game ep2).

Left 4 Dead / Left 4 Dead 2

Left 4 Dead Left 4 Dead and Left 4 Dead 2 Left 4 Dead 2 restrict certain console commands, such as mat_specular and building_cubemaps. While it seems to be optional, the latter command is recommended to make HDR cubemap have consistent exposure.

For Left 4 Dead Left 4 Dead, you must use SourceMod in order to use these commands (since VScript wasn't introduced until L4D2)
sm_cvar mat_specular 0
sm_cvar building_cubemaps 1
For Left 4 Dead 2 Left 4 Dead 2, you can either use SourceMod or run these VScript command
script Convars.SetValue("mat_specular", "0")
script Convars.SetValue("building_cubemaps", "1")

Additionally, unlike Counter-Strike: Source or other Source branches, mat_reloadallmaterials does not reload the cubemap texture, so after you built the cubemap, you will need to restart the game, or alternatively, while in fullscreen mode, Alt + Tab to desktop then back to the game (while the map is already loaded) will reload the cubemap texture in-game.

Portal 2

Icon-Bug.pngBug:Building cubemaps in Portal 2 Portal 2 will fail (and may crashes the game) if the map file is not in the highest-numbered DLC folder (🖿dlc2 by default, mods installed will be 🖿dlc3 or higher).
PlacementTip.pngWorkaround:Move the map to that folder before building cubemaps and, if necessary, edit the "Place compiled maps in this directory before running the game" path in Hammer's Build Programs options so that the map is automatically generated there.
  [todo tested in ?]

Source Filmmaker

Improper rendering of an HDR cubemap's face in Source Filmmaker.
Icon-Bug.pngBug:HDR cubemaps sizing lower than 128x128 built-in Team Fortress 2 Team Fortress 2 and some other games usually display graphical artifacts on reflections due to the last face of each cubemap not rendering properly in Source Filmmaker Source Filmmaker. While rebuilding cubemaps in it would normally fix the issue, it is currently not possible to do so as Source Filmmaker Source Filmmaker generates blank textures.
PlacementTip.pngWorkaround:If recompiling a special version of an affected map with env_cubemap's now sizing 128x128 (or higher) is not an option, move the map file into Alien Swarm Alien Swarm's 🖿maps folder, build its cubemaps in that game, then move the file back into Source Filmmaker Source Filmmaker's folder.
  [todo tested in ?]
Note.pngNote:Alien Swarm's "gameinfo.txt" file needs to be modified for this procedure so that the game can have access to assets used by other games' maps not to build cubemaps with missing textures or models. The file's "SearchPaths" section should look like this:
"SearchPaths"
{
	"Game"	"|gameinfo_path|."
	"Game"	"swarm_base"
	"Game"	"platform"
	"Game" "..\SourceFilmmaker\game\usermod"
	"Game" "..\SourceFilmmaker\game\tf_movies"
	"Game" "..\SourceFilmmaker\game\tf"
	"Game" "..\SourceFilmmaker\game\hl2"
}
Note.pngNote:Team Fortress 2 Team Fortress 2 configurations were used for the example; consider replacing game subfolders (only those within Source Filmmaker Source Filmmaker paths) with the ones needed.
PlacementTip.pngWorkaround:Another option is to manually remove the sphere map (face #7) from the existing HDR cubemap textures. See Creating a custom static cubemap texture for more info.
Alternatively, deleting the affected HDR cubemap texture files will cause the LDR versions to be used, which do not suffer from this bug.

Source 2013 MP / Team Fortress 2

Warning.pngWarning: Building cubemaps on a compressed .bsp (in Source 2013 Multiplayer and Team Fortress 2 branch games) will crash the game!

Improve reflections by rebuilding cubemaps

This step is optional but after building cubemaps once and enable reflections (mat_specular 1), you can build cubemaps again to improve reflections. The improvement it makes is only noticeable if the env_cubemap size was increased to higher resolutions and/or there are two reflective surfaces near each other.

To improve reflections, run the following commands:

Command Description
Follow the same instructions as LDR, LDR + HDR or HDR, up until the building_cubemaps and buildcubemaps command. Make sure mat_specular is set to "0" first.
building_cubemaps 1 Sets HDR exposure to a consistent value, which will make sure that one cubemap won't look as bright or darker than others. This will automatically reset back to 0 after cubemaps are built.
Note.pngNote:Only use this command if the map is loaded in HDR
Note.pngNote:This command is flagged as "launcher"-only in Left 4 Dead and Left 4 Dead 2, you can use the following command instead:
Left 4 Dead sm_cvar building_cubemaps 1) command (with SourceMod installed) or
Left 4 Dead 2 script Convars.SetValue("building_cubemaps", "1") (using VScript).
buildcubemaps Begins building cubemaps.
Note.pngNote:Running buildcubemaps with multiple iterations (e.g. buildcubemaps 2-4 or etc..), does not appear to actually improve reflections, it only repeats the buildcubemaps process. To actually improve reflections, you have to disconnect and reload the map before building cubemaps again, this will make sure the map would display the newly built cubemaps.
disconnect Unloads the map and returns to the main menu
Skip both disconnect and map if the game (usually singleplayer like Half-Life 2) reloads map automatically.
map map_name Loads the map again
mat_specular 1 Turns reflections on.
building_cubemaps 1 Sets HDR exposure to a consistent value again. This will automatically reset back to 0 after cubemaps are built.
Note.pngNote:Only use this command if the map is loaded in HDR
Note.pngNote:This command is flagged as "launcher"-only in Left 4 Dead and Left 4 Dead 2, you can use the following command instead:
Left 4 Dead sm_cvar building_cubemaps 1) command (with SourceMod installed) or
Left 4 Dead 2 script Convars.SetValue("building_cubemaps", "1") (using VScript).
buildcubemaps Building cubemaps the second time.
disconnect Once you are done, unloads the map.
Alternatively, you can switch to LDR or HDR mode using mat_hdr_level 0/2, then repeat the steps starting from the first buildcubemaps command. You can also optionally repeat the process again multiple times to further improve reflections, but 2 iterations should be enough.
map map_name Loads the map again, it should display the new cubemap textures after doing these steps.
mat_reloadallmaterials
or Alt + Tab / Restart game
In some games, such as Counter-Strike: Source, if it doesn't display new cubemap textures after loading the map, run this command to display the newly-built cubemaps. This command may run automatically when you load up the map while cheats is already enabled. In Left 4 Dead (or some Source games), this command may not reload cubemaps in-game, so instead Alt + Tab while in fullscreen or simply restart the game can sometime reload the texture (and display the new cubemap) aswell.
1st iteration
2nd iteration
4-8th iteration

Deleting cubemaps

Several tools make it possible to delete unnecessary or outdated cubemaps; BSPZIP is one official, command-line tool which is usually the preferred option for this procedure, allowing for an usage unlikely of corrupting the map file due to misuse. To delete cubemaps, execute the following command within the 🖿maps folder:

..\..\bin\bspzip -deletecubemaps map_name.bsp
Note.pngNote:Replace "map_name" with the map's actual name.
Note.pngNote:Once you deleted the cubemaps, building cubemaps again will require running buildcubemaps twice, since it has to generate blank textures first to avoid missing texture/generic texture on reflective surface being baked into cubemaps.

Deleting cubemaps will also display the message Failed, using default cubemap 'maps/map-name/cubemapdefault' once you load the map with deleted cubemaps.

Note.pngNote:If you are making maps for HDR only games, deleting unused blank LDR cubemaps is optional but recommended to reduce BSP file sizes.
Warning.pngWarning:Deleting cubemaps actually deletes all the texture (".vtf") files currently embedded into the map, so it's recommended not to embed custom textures before deleting cubemaps.

Extracting cubemaps

In cases where a map has to be recompiled with minor changes (and its built cubemaps vanish as a result), extracting them beforehand will make it not necessary to go through the whole cubemap-building process again. To extract cubemaps with BSPZIP, create a folder that will contain the extracted cubemaps inside the 🖿maps one, then execute the following command:

..\..\bin\bspzip -extractcubemaps map_name.bsp "foldername"
Note.pngNote:Replace "map_name" with the map's actual name, and "foldername" with the actual name of the folder to extract cubemaps into.

Embedding cubemaps

For BSPZIP to make a map use extracted cubemaps, create a text file inside the 🖿maps folder. The file's content should look like this:

materials/maps/map_name/c-128_384_64.hdr.vtf
foldername\materials\maps\map_name\c-128_384_64.hdr.vtf
materials/maps/map_name/c-128_384_64.vtf
foldername\materials\maps\map_name\c-128_384_64.vtf
materials/maps/map_name/c448_-256_64.hdr.vtf
foldername\materials\maps\map_name\c448_-256_64.hdr.vtf
materials/maps/map_name/c448_-256_64.vtf
foldername\materials\maps\map_name\c448_-256_64.vtf
materials/maps/map_name/cubemapdefault.vtf
foldername\materials\maps\map_name\cubemapdefault.vtf
Note.pngNote:Replace "map_name" with the map's actual name, the cubemaps' filenames with correct ones, and "foldername" with the actual name of the folder that contains the extracted cubemaps.

A file requires two dedicated lines (paths): the first line represents the path it will use within the map file, whereas the second one is the actual location of the file to embed into the map file. Relative location paths were used for the example, but they can also be Absolute. Once the text file is ready, execute the following command:

..\..\bin\bspzip -addlist map_name.bsp textfile.txt newmap_name.bsp
Note.pngNote:Replace "map_name" with the map's actual name, "textfile" with the text file's actual name, and "newmap_name" with either the map's actual name, or a new name not to overwrite the original file (and instead create a separate one).

Renaming a map

For built cubemaps to work, they must be located in a folder that is named after the map; this folder is automatically created within the map file during the building process. Renaming the map file will not also rename said folder, and therefore cubemaps will not be accessed. Some third-party apps allow renaming the folder, though it is not advisable to do so as it may corrupt the file. Instead, either delete and then rebuild the cubemaps, or revert the map to its original name.

See also