Cubemaps: Difference between revisions
No edit summary |
|||
Line 9: | Line 9: | ||
[[File:Default_cubemap.png|192px|thumb|right|This default cubemap texture will appear if you skip building blank cubemaps during VBSP process.]] | [[File:Default_cubemap.png|192px|thumb|right|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 {{mapbase|in|addtext-front=''Except''{{nbsp}}}} 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: | '''Building cubemaps''' is the process of generating textures to use as reflections. For technical reasons, this process isn't automated {{mapbase|in|addtext-front=''Except''{{nbsp}}}} 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: | ||
* | *A blank (black) texture (which basically make it look the same as {{code|mat_specular}}/reflections being disabled) | ||
** During compilation, VBSP will | ** During compilation, VBSP will generate blank cubemap textures. | ||
** If you skip VBSP blank cubemap generation (either by using Mapbase VBSP without adding {{code|-autocubemap}}, using {{slamminsrc|name}} VBSP with {{code|-nodefaultcubemap}}, or if you [[ | ** If you skip VBSP's blank cubemap generation (either by using Mapbase's VBSP without adding {{code|-autocubemap}}, using {{slamminsrc|name}} VBSP with {{code|-nodefaultcubemap}}, or if you [[#Deleting cubemaps|deleted the cubemaps]], it will display the missing or generic texture instead, and building cubemaps for the first time (without disabling {{code|mat_specular}}) will instead generate blank textures (or partially generate the cubemaps, with some of them being blank), until building it again second time, so don't forget to disable it. {{code|mat_specular}} must be also disabled prior to loading the map, otherwise disabling them after the map have been loaded, will cause {{code|buildcubemaps}} to generate blank textures aswell. | ||
*Default cubemap textures (see image on right) | *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. | ** 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. | ||
Line 24: | Line 24: | ||
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 {{code|mat_specular 0}}, otherwise {{code|buildcubemaps}} will instead generate blank texture until you run the command again.</br>Edit 2: {{css|2}} builds cubemap correctly now without deleting cubemaps after engine update ({{tf2branch|1}}), so some steps can be skipped. -[[User:Kr0tchet|leonidakarlach]] ([[User talk:Kr0tchet|talk]]) 02:50, 25 August 2024 (PDT) - Edited 24 Feb 2025. | 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 {{code|mat_specular 0}}, otherwise {{code|buildcubemaps}} will instead generate blank texture until you run the command again.</br>Edit 2: {{css|2}} builds cubemap correctly now without deleting cubemaps after engine update ({{tf2branch|1}}), so some steps can be skipped. -[[User:Kr0tchet|leonidakarlach]] ([[User talk:Kr0tchet|talk]]) 02:50, 25 August 2024 (PDT) - Edited 24 Feb 2025. | ||
{{l4d2|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. --[[User:MrFunreal|MrFunreal]] ([[User talk:MrFunreal|talk]]) 02:23, 11 February 2025 (PST)}} | {{l4d2|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. --[[User:MrFunreal|MrFunreal]] ([[User talk:MrFunreal|talk]]) 02:23, 11 February 2025 (PST)}} | ||
{{Important|Maps for {{src13|4.1}} games (including {{tf2branch|4.1}}) and others, such as {{css|4.1}}, are known to include pre-built, blank cubemaps after being compiled (even if there are no '''env_cubemap''' entities in them). In {{mapbase|4.1}}, blank cubemaps are not automatically generated by default.</br>For {{src13sp|2}} and {{src13mp|2}} titles (including previous version of Valve games), [[ | {{Important|Maps for {{src13|4.1}} games (including {{tf2branch|4.1}}) and others, such as {{css|4.1}}, are known to include pre-built, blank cubemaps after being compiled (even if there are no '''env_cubemap''' entities in them). In {{mapbase|4.1}}, blank cubemaps are not automatically generated by default.</br>For {{src13sp|2}} and {{src13mp|2}} titles (including previous version of Valve games), [[#Deleting cubemaps|deleting cubemaps]] will be required (in order to make sure cubemaps are properly written to the BSP). | ||
{{Tip|Deleting pre-built blank cubemaps, while not required, is recommended for {{l4dbranch|2}} games or later (and [[HDR]]-only games) since [[VBSP]] generates blank LDR cubemap | {{Tip|Deleting pre-built blank cubemaps, while not required, is recommended for {{l4dbranch|2}} games or later (and [[HDR]]-only games) since [[VBSP]] generates blank LDR cubemap textures that increase BSP file size while being unused anyway in those games.}} | ||
{{Note|Deleting pre-built blank cubemaps isn't required for {{hl2|1}}, {{portal|1}} | {{Note|Deleting pre-built blank cubemaps isn't required for {{hl2|1}}, {{portal|1}} nor the {{tf2branch|2}} games ({{css}}, {{dods}}, {{hldms}}, {{hldms}} and {{tf2}}), since the updated version of those games (as of 2025) now have built and written generated cubemaps to the .BSP correctly. Deleting blank cubemaps is also not required on {{Srcsdk13mp|1}} (also on TF2 branch), but required for {{srcsdk13sp|1}}, and the legacy version of {{srcsdk13mp|1}}.}} | ||
}} | }} | ||
{{Important| | {{Important| | ||
Line 33: | Line 33: | ||
}} | }} | ||
{{warning|{{clr}} | {{warning|{{clr}} | ||
* '''EPILEPSY WARNING''': Building cubemaps on a faster systems (with high single-thread performance) will causes the top left of the screen (which display captured cubemap images) to flicker much faster. Look away from the screen while the | * '''EPILEPSY WARNING''': Building cubemaps on a faster systems (with high single-thread performance) will causes the top left of the screen (which display captured cubemap images) to flicker much faster. Look away from the screen while the cubemaps are being built. | ||
** Additionally, the screen will also flashes white when building HDR cubemaps. | ** Additionally, the screen will also flashes white when building HDR cubemaps. | ||
** This mostly doesn't applies to games on {{src06|1}} or earlier, since these branches doesn't support multi-core and building cubemaps will take little bit longer on these branches. | ** This mostly doesn't applies to games on {{src06|1}} or earlier, since these branches doesn't support multi-core and building cubemaps will take little bit longer on these branches. | ||
* If the {{Command|nav_show_ladder_bounds}} command was used before building cubemaps, the green boxes will also be baked into the cubemap. | * If the {{Command|nav_show_ladder_bounds}} command was used before building cubemaps, the green boxes will also be baked into the cubemap. | ||
* While taking damage, building cubemaps when the screen is tinted red/white will cause the red/white tints baked into the cubemap. | * While taking damage, building cubemaps when the screen is tinted red/white will cause the red/white tints baked into the cubemap. | ||
* 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 {{code|env_cubemap(s)}}, cubemap sizes, CPU usage/utilization and framerate). For successful results, don't switch away from the game until it's done.</br>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 ( | * 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 {{code|env_cubemap(s)}}, cubemap sizes, CPU usage/utilization and framerate). For successful results, don't switch away from the game until it's done.</br>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 (exclusively) fullscreen mode.</br>'''For users using Vulkan instead of Direct3D 9 (Windows only):''' Clicking on the game while building cubemaps, even in fullscreen, will also cause the game to permanently freeze. | ||
* If you are building cubemaps for {{Hl2|4.1}} (except episodes) after the '''20th Anniversary Update''', you must [[Cubemaps#Half- | * If you are building cubemaps for {{Hl2|4.1}} (except episodes) after the '''20th Anniversary Update''', you must [[Cubemaps#Half-Life 2|follow the instructions]] here. Also building cubemaps in Half-Life 2 without removing some NPCs (or switching to a non-Gravity Gun weapon) will cause sprites' light from them to be baked into cubemaps. | ||
}} | }} | ||
{{tip|{{clr}} | {{tip|{{clr}} | ||
Line 46: | Line 46: | ||
* [[Bind]] {{code|mat_hdr_level 0}}, {{code|mat_hdr_level 2}}, {{code|building_cubemaps 1}} to any numpad keys, and {{code|buildcubemaps}} to numpad {{Key|Enter}} key, so you don't have to manually type and submit most of these command on console. | * [[Bind]] {{code|mat_hdr_level 0}}, {{code|mat_hdr_level 2}}, {{code|building_cubemaps 1}} to any numpad keys, and {{code|buildcubemaps}} to numpad {{Key|Enter}} key, so you don't have to manually type and submit most of these command on console. | ||
}} | }} | ||
* If you are using {{mapbase|4.1}}, you can add {{code|-autocubemap}} to launch game ({{code|$game_exe}}) command line in {{hammer|1}}. The game will automatically build cubemaps | * If you are using {{mapbase|4.1}}, you can add {{code|-autocubemap}} to launch the game ({{code|$game_exe}}) command line in {{hammer|1}}. The game will automatically build cubemaps. | ||
* {{slamminsrc|4.1|nt=1}} VBSP features the {{code|-nodefaultcubemap}} command, which skips automatically generating skybox cubemaps on map compile. | * {{slamminsrc|4.1|nt=1}} VBSP features the {{code|-nodefaultcubemap}} command, which skips automatically generating skybox cubemaps on map compile. | ||
===LDR=== | ===LDR=== | ||
{{note|This step doesn't apply to {{l4d|4.1}} nor {{csgo|4.1}} as their maps are compiled in [[#HDR|HDR mode]] only. While {{p2|4.1}} does support LDR, the game uses HDR by default, so we recommend building cubemaps in HDR only.}} | {{note|This step doesn't apply to {{l4d|4.1}} nor {{csgo|4.1}} as their maps are compiled in [[#HDR|HDR mode]] only. While {{p2|4.1}} does support LDR, the game uses HDR by default, so we recommend building cubemaps in HDR only.}} | ||
{{Note|Cheats do not have to be enabled to build cubemaps in: {{hls|1}}, {{hl2|1}}, {{hl2dm|1}} (all three since {{hl2}} 20th Anniversary Update), {{portal|1}} (since May 20, 2025) | {{Note|Cheats do not have to be enabled to build cubemaps in: {{hls|1}}, {{hl2|1}}, {{hl2dm|1}} (all three since {{hl2}} 20th Anniversary Update), {{portal|1}} (since May 20, 2025) nor the {{tf2branch|1}} games.}} | ||
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: | 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: | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 57: | Line 57: | ||
! Command !! Description | ! Command !! Description | ||
|- | |- | ||
| {{Command|mat_specular|0}} || Turns reflections off, which is necessary if using only one iteration of buildcubemaps, and if all [[#Deleting cubemaps|cubemaps has been deleted]].<br>It also meant that disabling reflections would avoid some case where missing textures or default cubemap texture ({{code|materials/engine/defaultcubemap.vtf}}, aka a desert with orange sunset sky), might | | {{Command|mat_specular|0}} || Turns reflections off, which is necessary if using only one iteration of buildcubemaps, and if all [[#Deleting cubemaps|cubemaps has been deleted]].<br>It also meant that disabling reflections would avoid some case where missing textures or default cubemap texture ({{code|materials/engine/defaultcubemap.vtf}}, aka a desert with orange sunset sky), might end up reflected on the cubemap itself.</br>{{Note|If you let VBSP generate blank cubemaps and you build the cubemaps without this command, it will build (and written cubemaps to [[BSP]]) just fine (atleast in {{hl2}}), however, if you deleted the cubemaps and run {{code|buildcubemaps}}, without disable {{code|mat_specular}}, it will instead generate and write blank textures, until you run {{code|buildcubemaps}} a second time. {{code|mat_specular}} must be also disabled prior to loading the map, otherwise disabling them after the map have been loaded, will cause {{code|buildcubemaps}} to generate blank textures aswell.}} | ||
|- | |- | ||
| {{Command|map}} ''map_name''</code> || Loads the map; replace "''map_name''" with the map's actual name | | {{Command|map}} ''map_name''</code> || Loads the map; replace "''map_name''" with the map's actual name | ||
|- | |- | ||
| {{Command|sv_cheats|1}} || Enables the use of cheat commands; required to build cubemaps<br>{{Note|{{hl2|1}}, {{hl2dm|1}} (since 20th Anniversary), {{portal|1}} (since May 20, 2025 update) and all {{tf2branch|1}} games ({{css}}, {{dods}}, {{hl2dm}}, {{hldms}} and {{tf2}}), doesn't require cheats to build cubemaps, so this step can be skipped. In many {{src13|1}} (SP/MP) games, including previous version of {{css|1}}, {{code|buildcubemaps}} can be | | {{Command|sv_cheats|1}} || Enables the use of cheat commands; required to build cubemaps<br>{{Note|{{hl2|1}}, {{hl2dm|1}} (since 20th Anniversary), {{portal|1}} (since May 20, 2025 update) and all {{tf2branch|1}} games ({{css}}, {{dods}}, {{hl2dm}}, {{hldms}} and {{tf2}}), doesn't require cheats to build cubemaps, so this step can be skipped. In many {{src13|1}} (SP/MP) games, including previous version of {{css|1}}, {{code|buildcubemaps}} can also be built without having to enable cheats, however, {{code|mat_reloadallmaterials}} (command that requires {{code|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.}} | ||
|- | |- | ||
| {{Command|buildcubemaps}} || Begins building cubemaps. Optionally, specify the number of iterations (e.g.: <code>buildcubemaps 2</code> (default is 1)) | | {{Command|buildcubemaps}} || Begins building cubemaps. Optionally, specify the number of iterations (e.g.: <code>buildcubemaps 2</code> (default is 1)) | ||
Line 71: | Line 71: | ||
| {{Command|map}} ''map_name''</code> || Loads the map again, your cubemaps should display after doing these steps. | | {{Command|map}} ''map_name''</code> || Loads the map again, your cubemaps should display after doing these steps. | ||
|- | |- | ||
| {{code|[[mat_reloadallmaterials]]}}</br>(''requires'' {{code|sv_cheats 1}})|| In some games or branch ({{src13|1}}), 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. This command is usually not required on {{hl2|1}} (since 20th | | {{code|[[mat_reloadallmaterials]]}}</br>(''requires'' {{code|sv_cheats 1}})|| In some games or branch ({{src13|1}}), 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. This command is usually not required on {{hl2|1}} (since 20th Anniversary update), {{portal|1}} (since May 2025 update) nor the {{tf2branch|1}} games, since cubemaps should be automatically reloaded when you load the map. | ||
|} | |} | ||
Line 82: | Line 82: | ||
! Command !! Description | ! Command !! Description | ||
|- | |- | ||
| {{Command|mat_specular|0}} || Turns reflections off, which is necessary if using only one iteration of buildcubemaps, and if all [[#Deleting cubemaps|cubemaps has been deleted]].<br>It also meant that disabling reflections would avoid some case where missing textures or default cubemap texture ({{code|materials/engine/defaultcubemap.vtf}}, aka a desert with orange sunset sky), might | | {{Command|mat_specular|0}} || Turns reflections off, which is necessary if using only one iteration of buildcubemaps, and if all [[#Deleting cubemaps|cubemaps has been deleted]].<br>It also meant that disabling reflections would avoid some case where missing textures or default cubemap texture ({{code|materials/engine/defaultcubemap.vtf}}, aka a desert with orange sunset sky), might end up reflected on the cubemap itself.{{Note|This command is flagged as "launcher"-only in {{l4d|1}} and {{l4d2|1}}, you can use the following command instead: </br>{{L4d}} {{code|sm_cvar mat_specular 0}} command (with [[SourceMod]] installed) or </br>{{L4d2}} {{code|script Convars.SetValue("mat_specular", "0")}} (using [[VScript]]).}}{{Note|If you let VBSP generate blank cubemaps and you build cubemaps without this command, it will build (and written cubemaps to [[BSP]]) just fine (atleast in {{hl2}}), however, if you deleted the cubemaps and run {{code|buildcubemaps}}, without disabling {{code|mat_specular}}, it will instead generate and write blank textures, until you run {{code|buildcubemaps}} a second time. {{code|mat_specular}} must be also disabled prior to loading the map, otherwise disabling them after the map have been loaded, will cause {{code|buildcubemaps}} to generate blank textures aswell.}} | ||
|- | |- | ||
| {{Command|map}} ''map_name'' || Loads the map; replace "''map_name''" with the map's actual name | | {{Command|map}} ''map_name'' || Loads the map; replace "''map_name''" with the map's actual name | ||
Line 88: | Line 88: | ||
| {{Command|sv_cheats|1}} || Enables the use of cheat commands; required to build cubemaps<br>{{Note|{{hl2|1}}, {{hl2dm|1}} (since 20th Anniversary) and all {{tf2branch|1}} games ({{css}}, {{dods}}, {{hl2dm}}, {{hldms}} and {{tf2}}), doesn't require cheats to build cubemaps, so this step can be skipped. In many {{src13|1}} (SP/MP) games, including previous version of {{css|1}}, {{code|buildcubemaps}} can be also built without enabling cheats, however, {{code|mat_reloadallmaterials}} (command that requires {{code|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.}} | | {{Command|sv_cheats|1}} || Enables the use of cheat commands; required to build cubemaps<br>{{Note|{{hl2|1}}, {{hl2dm|1}} (since 20th Anniversary) and all {{tf2branch|1}} games ({{css}}, {{dods}}, {{hl2dm}}, {{hldms}} and {{tf2}}), doesn't require cheats to build cubemaps, so this step can be skipped. In many {{src13|1}} (SP/MP) games, including previous version of {{css|1}}, {{code|buildcubemaps}} can be also built without enabling cheats, however, {{code|mat_reloadallmaterials}} (command that requires {{code|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.}} | ||
|- | |- | ||
| {{Command| | | {{Command|building_cubemaps (console command)|alt=building_cubemaps|1}} || Sets HDR exposure to a consistent value, which will make sure that no cubemaps won't look brighter or darker than others. This will automatically reset back to 0 after cubemaps are built.{{Note|This command is flagged as "launcher"-only in {{l4d|1}} and {{l4d2|1}}, you can use the following command instead: </br>{{L4d}} {{code|sm_cvar building_cubemaps 1}} command (with [[SourceMod]] installed) or </br>{{L4d2}} {{code|script Convars.SetValue("building_cubemaps", "1")}} (using [[VScript]]).}} | ||
|- | |- | ||
| {{Command|buildcubemaps}} || Begins building cubemaps. Optionally, specify the number of iterations (e.g.: <code>buildcubemaps 2</code> (default is 1))</br>In singleplayer games, the map will be automatically reloaded after building cubemaps. | | {{Command|buildcubemaps}} || Begins building cubemaps. Optionally, specify the number of iterations (e.g.: <code>buildcubemaps 2</code> (default is 1))</br>In singleplayer games, the map will be automatically reloaded after building cubemaps. | ||
Line 112: | Line 112: | ||
| {{Command|map}} ''map_name''</code> || Loads the map again, your cubemaps should display after doing these steps. | | {{Command|map}} ''map_name''</code> || Loads the map again, your cubemaps should display after doing these steps. | ||
|- | |- | ||
| {{code|[[mat_reloadallmaterials]]}}</br>(''requires'' {{code|sv_cheats 1}})</br>or {{Key|Alt + Tab}} / Restart game|| In some games, such as {{css|1}}, 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 | | {{code|[[mat_reloadallmaterials]]}}</br>(''requires'' {{code|sv_cheats 1}})</br>or {{Key|Alt + Tab}} / Restart game|| In some games, such as {{css|1}}, 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 server cheats are already enabled.</br>If this command does not reload cubemaps in-game, you can instead try {{key|Alt}} + {{key|Tab}}'ing while in fullscreen or simply restart the game; the latter method can sometimes reload the texture (and display the new cubemap) aswell. | ||
{{Note|{{Key|Alt + Tab}} only works properly in {{src09|1}} or earlier, and {{l4dbranch|1}} or later. {{src13|1}} | {{Note|{{Key|Alt + Tab}} only works properly in {{src09|1}} or earlier, and {{l4dbranch|1}} or later. {{src13|1}} and {{csgobranch|1}} games use Direct3D 9Ex, which meant that running those games on Windows 10/11, without setting multiple displays to "Duplicate" or disable fullscreen optimization, it will not reload anything at all when you {{key|Alt + Tab}}.}} | ||
{{Note|Usually not required on {{hl2|1}} | {{Note|Usually not required on {{hl2|1}} nor the {{tf2branch|1}} games, since cubemaps should be automatically reloaded when you load the map.}} | ||
|} | |} | ||
Line 124: | Line 124: | ||
! Command !! Description | ! Command !! Description | ||
|- | |- | ||
| {{Command|mat_specular|0}} || Turns reflections off, which is necessary if using only one iteration of buildcubemaps, and if all [[#Deleting cubemaps|cubemaps | | {{Command|mat_specular|0}} || Turns reflections off, which is necessary if using only one iteration of buildcubemaps, and if all [[#Deleting cubemaps|cubemaps have been deleted]].<br>It also meant that disabling reflections would avoid some case where missing textures or default cubemap texture ({{code|materials/engine/defaultcubemap.vtf}}, aka a desert with orange sunset sky), might end up reflected on the cubemap itself.{{Note|This command is flagged as "launcher"-only in {{l4d|1}} and {{l4d2|1}}, you can use the following command instead: </br>{{L4d}} {{code|sm_cvar mat_specular 0}} command (with [[SourceMod]] installed) or </br>{{L4d2}} {{code|script Convars.SetValue("mat_specular", "0")}} (using [[VScript]]).}}{{Note|If you let VBSP generate blank cubemaps and you build cubemaps without this command, it will build (and written cubemaps to [[BSP]]) just fine (atleast in {{hl2}}), however, if you deleted the cubemaps and run {{code|buildcubemaps}}, without disabling {{code|mat_specular}} first, it will instead generate blank textures, until you run {{code|buildcubemaps}} a second time. {{code|mat_specular}} must be also disabled prior to loading the map, otherwise disabling them after the map have been loaded, will cause {{code|buildcubemaps}} to generate blank textures aswell.}} | ||
|- | |- | ||
| {{Command|map}} ''map_name'' || Loads the map; replace "''map_name''" with the map's actual name | | {{Command|map}} ''map_name'' || Loads the map; replace "''map_name''" with the map's actual name | ||
|- | |- | ||
| {{Command|sv_cheats|1}} || Enables the use of cheat commands; required to build cubemaps<br>{{Note|{{hl2|1}}, {{hl2dm|1}} (since 20th Anniversary) and all {{tf2branch|1}} games ({{css}}, {{dods}}, {{hl2dm}}, {{hldms}} and {{tf2}}), | | {{Command|sv_cheats|1}} || Enables the use of cheat commands; required to build cubemaps<br>{{Note|{{hl2|1}}, {{hl2dm|1}} (since 20th Anniversary) and all {{tf2branch|1}} games ({{css}}, {{dods}}, {{hl2dm}}, {{hldms}} and {{tf2}}), do not require cheats to build cubemaps, so this step can be skipped. In many {{src13|1}} (SP/MP) games, including previous version of {{css|1}}, {{code|buildcubemaps}} can be also built without enabling cheats, however, {{code|mat_reloadallmaterials}} (a command that requires {{code|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.}} | ||
|- | |- | ||
| {{Command| | | {{Command|building_cubemaps (console command)|alt=building_cubemaps|1}} || Sets HDR exposure to a consistent value, which will make sure that one cubemap won't look brighter or darker than others. This will automatically reset back to 0 after cubemaps are built.{{Note|This command is flagged as "launcher"-only in {{l4d|1}} and {{l4d2|1}}, you can use the following command instead: </br>{{L4d}} {{code|sm_cvar building_cubemaps 1}} command (with [[SourceMod]] installed) or </br>{{L4d2}} {{code|script Convars.SetValue("building_cubemaps", "1")}} (using [[VScript]]).}} | ||
|- | |- | ||
| {{Command|buildcubemaps}} || Begins building cubemaps. Optionally, specify the number of iterations (e.g.: <code>buildcubemaps 2</code> (default is 1))</br>In singleplayer games, the map will be automatically reloaded after building cubemaps. | | {{Command|buildcubemaps}} || Begins building cubemaps. Optionally, specify the number of iterations (e.g.: <code>buildcubemaps 2</code> (default is 1))</br>In singleplayer games, the map will be automatically reloaded after building cubemaps. | ||
Line 140: | Line 140: | ||
| {{Command|map}} ''map_name''</code> || Loads the map again, your cubemaps should display after doing these steps. | | {{Command|map}} ''map_name''</code> || Loads the map again, your cubemaps should display after doing these steps. | ||
|- | |- | ||
| {{code|[[mat_reloadallmaterials]]}}</br>(''requires'' {{code|sv_cheats 1}})</br>or {{key|Alt + Tab}} / Restart game|| In some games, such as {{css|1}}, 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 | | {{code|[[mat_reloadallmaterials]]}}</br>(''requires'' {{code|sv_cheats 1}})</br>or {{key|Alt + Tab}} / Restart game|| In some games, such as {{css|1}}, 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 server cheats are already enabled. In {{l4d|1}} (or some Source games), this command may not reload cubemaps in-game, so instead {{key|Alt}} + {{key|Tab}}'ing while in fullscreen or simply restarting the game can sometimes reload the texture (and display the new cubemap) aswell. | ||
{{Note|{{Key|Alt + Tab}} only works properly in {{src09|1}} or earlier, and {{l4dbranch|1}} or later. {{src13|1}} | {{Note|{{Key|Alt + Tab}} only works properly in {{src09|1}} or earlier, and {{l4dbranch|1}} or later. {{src13|1}} and {{csgobranch|1}} games use Direct3D 9Ex, which meant that running those games on Windows 10/11, without setting multiple displays to "Duplicate" or disable fullscreen optimization, it will not reload anything at all when you {{key|Alt + Tab}}.}} | ||
{{Note|Usually not required on {{hl2|1}} or all {{tf2branch|1}} games, since cubemaps should be automatically reloaded when you load the map.}} | {{Note|Usually not required on {{hl2|1}} or all {{tf2branch|1}} games, since cubemaps should be automatically reloaded when you load the map.}} | ||
|} | |} | ||
==Building cubemaps in specific games== | ==Building cubemaps in specific games== | ||
===Black Mesa === | ===Black Mesa=== | ||
To build cubemaps in {{bms|4.1}} maps, the game has to be launched with these parameters: <code>-oldgameui -dev -console +r_4way_use_fast_normals 0</code><br>Then, load the map, follow the instructions on [[#HDR|HDR section]]. | To build cubemaps in {{bms|4.1}} maps, the game has to be launched with these parameters: <code>-oldgameui -dev -console +r_4way_use_fast_normals 0</code><br>Then, load the map, follow the instructions on [[#HDR|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. | 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=== | ===Half-Life: Source=== | ||
Line 188: | Line 188: | ||
===Portal 2=== | ===Portal 2=== | ||
{{bug|hidetested=1|Building cubemaps in {{portal2|4.1}} will fail (and may | {{bug|hidetested=1|Building cubemaps in {{portal2|4.1}} will fail (and may crash the game) if the map file is not in the highest-numbered DLC folder ({{path|dlc2}} by default, mods installed will be {{path|dlc3}} or higher). | ||
{{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 Build Programs|Hammer's Build Programs]] options so that the map is automatically generated there.}}|only=portal2}} | {{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 Build Programs|Hammer's Build Programs]] options so that the map is automatically generated there.}}|only=portal2}} | ||
Line 213: | Line 213: | ||
=== Source 2013 MP / Team Fortress 2 === | === Source 2013 MP / Team Fortress 2 === | ||
{{warning| Building cubemaps on a [[BSPZIP#Compression|compressed .bsp]] (in {{src13mp|1}} and {{tf2branch|1}} games) will crash the game!}} | {{warning| Building cubemaps on a [[BSPZIP#Compression|compressed .bsp]] (in {{src13mp|1}} and {{tf2branch|1}} games) will crash the game!}} | ||
{{Note|For {{tf2branch|4}} games, [[# | {{Note|For {{tf2branch|4}} games, [[#Deleting cubemaps|deleting cubemaps]], and using {{code|sv_cheats}} to build cubemaps are no longer required. However if you are mapping on {{src13mp|1}} games (including previous version of Valve games running on {{src13mp|1}} branch), you will need to delete cubemaps and enable cheats to build cubemaps.}} | ||
== Improve reflections by rebuilding cubemaps == | == Improve reflections by rebuilding cubemaps == | ||
Line 225: | Line 225: | ||
| colspan = 2 | <center>Follow the same instructions as '''[[#LDR|LDR]]''', '''[[#LDR + HDR|LDR + HDR]]''' or '''[[#HDR|HDR]]''', up until the {{code|building_cubemaps}} and {{code|buildcubemaps}} command. Make sure {{code|mat_specular}} is set to "0" first.</center> | | colspan = 2 | <center>Follow the same instructions as '''[[#LDR|LDR]]''', '''[[#LDR + HDR|LDR + HDR]]''' or '''[[#HDR|HDR]]''', up until the {{code|building_cubemaps}} and {{code|buildcubemaps}} command. Make sure {{code|mat_specular}} is set to "0" first.</center> | ||
|- | |- | ||
| {{Command| | | {{Command|building_cubemaps (console command)|alt=building_cubemaps|1}} || Sets HDR exposure to a consistent value, which will make sure that one cubemap won't look brighter or darker than others. This will automatically reset back to 0 after cubemaps are built.{{note|Only use this command if the map is loaded in HDR}}{{Note|This command is flagged as "launcher"-only in {{l4d|1}} and {{l4d2|1}}, you can use the following command instead: </br>{{L4d}} {{code|sm_cvar building_cubemaps 1)}} command (with [[SourceMod]] installed) or </br>{{L4d2}} {{code|script Convars.SetValue("building_cubemaps", "1")}} (using [[VScript]]).}} | ||
|- | |- | ||
| {{Command|buildcubemaps}} || Begins building cubemaps.{{note|Running {{code|buildcubemaps}} with multiple iterations (e.g. {{code|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.}} | | {{Command|buildcubemaps}} || Begins building cubemaps.{{note|Running {{code|buildcubemaps}} with multiple iterations (e.g. {{code|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.}} | ||
Line 260: | Line 260: | ||
..\..\bin\bspzip -deletecubemaps map_name.bsp | ..\..\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.}} | ||
{{Note|Once you | {{Note|Once you delete the cubemaps, building cubemaps again will require {{code|mat_specular 0}} prior to loading the map, otherwise {{code|buildcubemaps}} will need to be run twice, since it has to generate blank textures first to avoid missing texture/generic textures on reflective surfaces being baked into cubemaps. {{code|mat_specular 0}} will prevent that from happen, so you just simply run {{code|buildcubemaps}} once. | ||
Deleting cubemaps will also display the message {{code|Failed, using default cubemap 'maps/map-name/cubemapdefault'}} once you load the map with deleted cubemaps. | Deleting cubemaps will also display the message {{code|Failed, using default cubemap 'maps/map-name/cubemapdefault'}} once you load the map with deleted cubemaps. | ||
}} | }} | ||
{{Note|If you are making maps for HDR only games, deleting unused blank LDR cubemaps is optional but recommended to reduce BSP file sizes.}} | {{Note|If you are making maps for HDR-only games, deleting unused blank LDR cubemaps is optional but recommended to reduce BSP file sizes.}} | ||
{{Important|Usually not required on {{tf2branch|1}} games ({{css}}, {{dods}}, {{hl2dm}}, {{hldms}} and {{tf2}}), since cubemaps are now properly written to the BSP. But if you still encounter the problem, try to delete cubemaps.}} | {{Important|Usually not required on {{tf2branch|1}} games ({{css}}, {{dods}}, {{hl2dm}}, {{hldms}} and {{tf2}}), since cubemaps are now properly written to the BSP. But if you still encounter the problem, try to delete cubemaps.}} | ||
{{warning|Deleting cubemaps actually deletes all the texture ("[[Valve Texture Format|.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 ("[[Valve Texture Format|.vtf]]") files currently embedded into the map, so it's recommended not to embed custom textures before deleting cubemaps.}} | ||
Line 291: | Line 291: | ||
==Renaming a map== | ==Renaming a map== | ||
Renaming the map .bsp file breaks cubemaps on non-world geometry (models, props, weapons etc.). When map is being loaded the Source engine loads the Pakfile (containing, amongst others, cubemap textures and patch materials) embedded in the map. To display cubemaps on said geometry the engine searches ''materials/<MAP BSP FILENAME>'' directory but if such directory is not found, due to the BSP file being renamed, the cubemaps are not displayed. | Renaming the map .bsp file breaks cubemaps on non-world geometry (models, props, weapons etc.). When map is being loaded the Source engine loads the Pakfile (containing, amongst others, cubemap textures and patch materials) embedded in the map. To display cubemaps on said geometry the engine searches ''materials/<MAP BSP FILENAME>'' directory but if such directory is not found, due to the BSP file being renamed, the cubemaps are not displayed. | ||
Cubemaps on world geometry however are not affected, as the internal BSP data still points to a valid materials inside the Pakfile (see [[ | Cubemaps on world geometry however are not affected, as the internal BSP data still points to a valid materials inside the Pakfile (see [[BSP (Source)#TexdataStringData and TexdataStringTable|TexdataStringData and TexdataStringTable]]). | ||
<br> | <br> | ||
{{Bspentspy|2}} allows for renaming the internal map structure and data to fix the issues with Cubemaps | {{Bspentspy|2}} allows for renaming the internal map structure and data to fix the issues with Cubemaps |
Revision as of 02:53, 30 May 2025

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" (such as default cubemap texture, see below) that don't properly depict it, appear broken (missing textures, reflections appear bright, etc...), or simply doesn't show any reflections (if the cubemap texture is black).
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:
- A blank (black) texture (which basically make it look the same as mat_specular/reflections being disabled)
- During compilation, VBSP will generate blank cubemap textures.
- If you skip VBSP's blank cubemap generation (either by using Mapbase's 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 the first time (without disabling mat_specular) will instead generate blank textures (or partially generate the cubemaps, with some of them being blank), 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.
- This also appears if you recompiled the map and overwrite the original which have cubemaps texture baked in, then Alt + Tab ⇆ back to the game (which sometime reloads the textures).
Before building

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.
Edit 2: Counter-Strike: Source builds cubemap correctly now without deleting cubemaps after engine update (Team Fortress 2 branch), so some steps can be skipped. -leonidakarlach (talk) 02:50, 25 August 2024 (PDT) - Edited 24 Feb 2025.






For












- 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) - Disable any anti-aliasing method (SGSSAA for example) forced through GPU driver and enable the in-game AA or use FXAA instead (or simply run the game in Vulkan which will disable all forced AA) 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.

- EPILEPSY WARNING: Building cubemaps on a faster systems (with high single-thread performance) will causes the top left of the screen (which display captured cubemap images) to flicker much faster. Look away from the screen while the cubemaps are being built.
- Additionally, the screen will also flashes white when building HDR cubemaps.
- This mostly doesn't applies to games on Source 2006 or earlier, since these branches doesn't support multi-core and building cubemaps will take little bit longer on these branches.
- If the nav_show_ladder_bounds command was used before building cubemaps, the green boxes will also be baked into the cubemap.
- While taking damage, building cubemaps when the screen is tinted red/white will cause the red/white tints baked into the cubemap.
- 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.
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 (exclusively) fullscreen mode.
For users using Vulkan instead of Direct3D 9 (Windows only): Clicking on the game while building cubemaps, even in fullscreen, will also cause the game to permanently freeze. - If you are building cubemaps for
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 (or switching to a non-Gravity Gun weapon) will cause sprites' light from them to be baked into cubemaps.

- 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. Higher anti-aliasing settings also makes minor differences (not easily noticable).
- 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, you can add -autocubemap to launch the game ($game_exe) command line in Hammer. The game will automatically build cubemaps.
Slammin' VBSP VBSP features the -nodefaultcubemap command, which skips automatically generating skybox cubemaps on map compile.
LDR






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 end up reflected on the cubemap itself. ![]() ![]() |
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![]() ![]() ![]() ![]() ![]() ![]() |
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 or branch (Source 2013), 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. This command is usually not required on Half-Life 2 (since 20th Anniversary update), Portal (since May 2025 update) nor the Team Fortress 2 branch games, since cubemaps should be automatically reloaded when you load the map. |
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:


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 end up reflected on the cubemap itself. ![]() ![]() ![]() ![]() ![]() |
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![]() ![]() ![]() ![]() ![]() ![]() |
building_cubemaps 1 | Sets HDR exposure to a consistent value, which will make sure that no cubemaps won't look brighter or darker than others. 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))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 server cheats are already enabled. If this command does not reload cubemaps in-game, you can instead try Alt + Tab ⇆'ing while in fullscreen or simply restart the game; the latter method can sometimes reload the texture (and display the new cubemap) aswell. ![]() ![]() |
HDR
This section is for games running on the 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 have 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 end up reflected on the cubemap itself. ![]() ![]() ![]() ![]() ![]() |
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![]() ![]() ![]() ![]() ![]() ![]() |
building_cubemaps 1 | Sets HDR exposure to a consistent value, which will make sure that one cubemap won't look brighter or darker than others. 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))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 server cheats are already enabled. In Left 4 Dead (or some Source games), this command may not reload cubemaps in-game, so instead Alt + Tab ⇆'ing while in fullscreen or simply restarting the game can sometimes reload the texture (and display the new cubemap) aswell.
![]() ![]() |
Building cubemaps in specific games
Black Mesa
To build cubemaps in 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


environment maps
folder instead. So even if you already build cubemaps, it only displays in some materials that use $envmap env_cubemap.

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


maps
folder of a game in the same engine branch (such as 
Half-Life 2
- All versions




- 20th Anniversary only




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

Left 4 Dead / Left 4 Dead 2
Left 4 Dead and
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, 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, 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



dlc2
by default, mods installed will be 
dlc3
or higher).

Source Filmmaker







maps
folder, build its cubemaps in that game, then move the file back into 
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" }



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.
Source 2013 MP / Team Fortress 2



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 |
---|---|
building_cubemaps 1 | Sets HDR exposure to a consistent value, which will make sure that one cubemap won't look brighter or darker than others. This will automatically reset back to 0 after cubemaps are built.![]() ![]() ![]() ![]() |
buildcubemaps | Begins building cubemaps.![]() |
disconnect | Unloads the map and returns to the main menu Skip both disconnect and map if the game (usually singleplayer like ![]() |
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.![]() ![]() ![]() ![]() |
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.
![]() |
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


Deleting cubemaps will also display the message Failed, using default cubemap 'maps/map-name/cubemapdefault' once you load the map with deleted 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"

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

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

Renaming a map
Renaming the map .bsp file breaks cubemaps on non-world geometry (models, props, weapons etc.). When map is being loaded the Source engine loads the Pakfile (containing, amongst others, cubemap textures and patch materials) embedded in the map. To display cubemaps on said geometry the engine searches materials/<MAP BSP FILENAME> directory but if such directory is not found, due to the BSP file being renamed, the cubemaps are not displayed.
Cubemaps on world geometry however are not affected, as the internal BSP data still points to a valid materials inside the Pakfile (see TexdataStringData and TexdataStringTable).
BSPEntSpy allows for renaming the internal map structure and data to fix the issues with Cubemaps
See also
- env_cubemap
- $envmap
- parallax_obb - For Parallax Corrected Cubemaps.