Cubemaps
 
  r_showenvcubemap).A cubemap is a texture that represents a three-dimensional rendering of an area.  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" that don't properly depict it.
 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" that don't properly depict it.
Building cubemaps
Building cubemaps is the process of generating textures to use as reflections. For technical reasons, this process isn't automated (Except in  ) 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 generic, black texture or "missing" textures as reflections due to nonexistent cubemaps.
) 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 generic, black texture or "missing" textures as reflections due to nonexistent cubemaps.
 Warning:
Warning:
- For people with epilepsy: Building cubemaps on games running on Vulkan, such as  Left 4 Dead 2, causes the screen to flash black and white violently. Also on systems with faster CPU/GPU , building HDR cubemaps in pre-L4D branch games, such as Left 4 Dead 2, causes the screen to flash black and white violently. Also on systems with faster CPU/GPU , building HDR cubemaps in pre-L4D branch games, such as Counter-Strike: Source, even with Direct3D 9/DX9, will also flash the screen black and white repeatedly. Counter-Strike: Source, even with Direct3D 9/DX9, will also flash the screen black and white repeatedly.
- If the nav_show_ladder_boundscommand was used before building cubemaps, the green boxes will also be baked into the cubemap.
Before building

Also some Source games (such as CS:S), doesn't appear to require cheats to be enabled to build cubemaps. -leonidakarlach (talk) 02:50, 25 August 2024 (PDT)
 Important:Maps for
Important:Maps for  Source 2013 games and others, such as
 Source 2013 games and others, such as  Counter-Strike: Source, are known to include pre-built, blank cubemaps after being compiled (even if there are no env_cubemap entities in them); these should be deleted before building new ones, as detailed here. This is fixed in
 Counter-Strike: Source, are known to include pre-built, blank cubemaps after being compiled (even if there are no env_cubemap entities in them); these should be deleted before building new ones, as detailed here. This is fixed in  Mapbase
 Mapbase Tip:
Tip:
- 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 before building cubemaps.
- 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) Note:The game may appear to freeze or become unresponsive during the process, and the amount of time depends on various factors. For successful results, don't switch away from the game until it's done. Note:The game may appear to freeze or become unresponsive during the process, and the amount of time depends on various factors. For successful results, don't switch away from the game until it's done.
- If you are using  Mapbase, you can add Mapbase, you can add-autocubemapto your command line in Hammer. The game will automatically build cubemaps
 Slammin' VBSP features the Slammin' VBSP features the- -nodefaultcubemapcommand, which skips automatically generating skybox cubemaps on map compile.
LDR
 Note:This step doesn't apply to
Note:This step doesn't apply to  Left 4 Dead nor
 Left 4 Dead nor  Counter-Strike: Global Offensive as their maps are compiled in HDR mode only. While
 Counter-Strike: Global Offensive as their maps are compiled in HDR mode only. While  Portal 2 does support LDR, the game uses HDR by default, so we recommend building cubemaps in HDR only.
 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; required to properly build cubemaps | 
| mapmap_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 | 
| 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 | 
| quit | (optional) Exits the game. Relaunching it is required to display newly-built cubemaps | 
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:Maps built on Left 4 Dead, or later (and some third-party Source games), does not requires building cubemaps on LDR. See #HDR
Note: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. | 
| mapmap_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 | 
| building_cubemaps 1 | Sets HDR exposure to a consistent value. This will automatically reset back to 0 after cubemaps are built. | 
| 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 | 
| sv_cheats 0 | Disables cheat commands; prevents command mat_reloadallmaterialsfrom unnecessarily self-executing (which briefly freezes the game) | 
| mat_hdr_level 0 | Switches to LDR mode (from HDR); submit mat_hdr_level 2instead if LDR cubemaps were built first | 
| mapmap_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 | 
| mat_hdr_level 0/1/2 | If necessary, switches back to the mode it was before having submitted mat_hdr_level 0/2 | 
| quit | (optional) Exits the game. On some games, relaunching is required to display newly-built cubemaps | 
HDR
This section is for games running  Left 4 Dead engine branch and later engine branch, or engine branch that only support's HDR (Xengine). To build cubemaps in HDR only, submit the following commands into the game's console:
 Left 4 Dead engine branch and later engine branch, or engine branch that only support's HDR (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. | 
| mapmap_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 | 
| building_cubemaps 1 | Sets HDR exposure to a consistent value. This will automatically reset back to 0 after cubemaps are built. | 
| 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 | 
| quit | (optional) Exits the game. On some games, relaunching is required to display newly-built cubemaps | 
Building cubemaps in specific games
Black Mesa: Source
To build cubemaps in  Black Mesa maps, the game has to be launched with these parameters:
 Black Mesa maps, the game has to be launched with these parameters: -oldgameui -dev -console +r_4way_use_fast_normals 0 +mat_specular 0
Then, load the map and submit the buildcubemaps command into the console.
Half-Life: Source
 Bug:Building cubemaps in
Bug:Building cubemaps in  Half-Life: Source is currently not possible as their textures, despite being generated, aren't embedded into the map file afterward.
 Half-Life: Source is currently not possible as their textures, despite being generated, aren't embedded into the map file afterward.
 Workaround:Move the map file into the
Workaround:Move the map file into the 
maps folder of a game in the same engine branch (such as  Half-Life 2), build its cubemaps in that game, then move the file back into Half-Life: Source's folder.
 Half-Life 2), build its cubemaps in that game, then move the file back into Half-Life: Source's folder.Portal 2
 Bug:Building cubemaps in
Bug:Building cubemaps in  Portal 2 will fail if the map file is not in the highest-numbered DLC folder (
 Portal 2 will fail if the map file is not in the highest-numbered DLC folder (
dlc2 by default).
 Workaround: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.
Workaround: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.Portal 2: Community Edition
 Bug:Amount of iterations (e.g.:
Bug:Amount of iterations (e.g.: buildcubemaps 2) doesn't currently work in  Portal 2: Community Edition.
 Portal 2: Community Edition.
 Workaround:Run the
Workaround:Run the buildcubemaps command, reload the map, then run the command again. Successively repeat these steps if necessary.
Source Filmmaker
 Bug:HDR cubemaps sizing lower than 64x64 built-in
Bug:HDR cubemaps sizing lower than 64x64 built-in  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
 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. While rebuilding cubemaps in it would normally fix the issue, it is currently not possible to do so as
 Source Filmmaker. While rebuilding cubemaps in it would normally fix the issue, it is currently not possible to do so as  Source Filmmaker generates blank textures.
 Source Filmmaker generates blank textures.
 Workaround:If recompiling a special version of an affected map with env_cubemap's now sizing 64x64 (or higher) is not an option, move the map file into
Workaround:If recompiling a special version of an affected map with env_cubemap's now sizing 64x64 (or higher) is not an option, move the map file into  Alien Swarm's
 Alien Swarm's 
maps folder, build its cubemaps in that game, then move the file back into  Source Filmmaker's folder.
 Source Filmmaker's folder. Note: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: Note: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:
Note: Team Fortress 2 configurations were used for the example; consider replacing game subfolders (only those within
 Team Fortress 2 configurations were used for the example; consider replacing game subfolders (only those within  Source Filmmaker paths) with the ones needed.
 Source Filmmaker paths) with the ones needed.
 Workaround: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. Workaround: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.
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:Replace "map_name" with the map's actual name.
Note:Replace "map_name" with the map's actual name. Warning: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.
Warning: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:Replace "map_name" with the map's actual name, and "foldername" with the actual name of the folder to extract cubemaps into.
Note: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: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.
Note: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: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).
Note: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
- env_cubemap
- $envmap
- parallax_obb - For Parallax Corrected Cubemaps.



























 Confirm:
 Confirm:
