Cubemaps: Difference between revisions
m (Minor improvements) |
m (More improvements) |
||
Line 1: | Line 1: | ||
{{lang|Cubemaps}} | {{lang|Cubemaps}} | ||
[[Image:Env_cubemap.png|left]][[Image:Specular.jpg|thumb|300px | [[Image:Env_cubemap.png|left]] | ||
A '''cubemap''' is a texture that represents a three-dimensional rendering of an area. The [[Source|Source Engine]] uses [[env_cubemap]] entities as sampling points | [[Image:Specular.jpg|thumb|right|300px|Models with specular reflections.]] | ||
A '''cubemap''' is a texture that represents a three-dimensional rendering of an area. The [[Source|Source Engine]] uses [[env_cubemap]] entities as sampling points to generate these textures, which are then automatically embedded into the [[BSP|map]] file. Cubemaps, when [[#Building cubemaps|built]], are reflected on surfaces that use the [[$envmap]] parameter with ''env_cubemap'' as its value. | |||
== Building cubemaps == | == Building cubemaps == | ||
Building cubemaps is the process of generating their textures for reflective | Building cubemaps is the process of generating their textures for reflective purposes. For technical reasons, this process is not automated and is up to the user to do so; until then, existing '''env_cubemaps''' will remain unused and the map, depending on the game, will display either generic or "missing" textures as reflections due to non-existing cubemaps. | ||
{{warning| | {{warning|To build cubemaps, your game's screen resolution needs to be at least 4 times higher than the highest [[env cubemap#Keyvalues|size]] of an '''env_cubemap''' in a map, 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 of 512x512 will be needed. (''128 × 4 = '''512''' -> 720x576 or higher)}} | ||
{{note| | {{note|Your game needs to be relaunched in order to display cubemaps after building them.}} | ||
{{tip|Maxing out your game's visual settings prior to building cubemaps will generate their textures in the best-possible quality | {{tip|Maxing out your game's visual settings prior to building cubemaps will generate their textures in the best-possible quality for the cubemaps' size.}} | ||
=== Before building === | === Before building === | ||
{{css}} '''Counter-Strike: Source''' maps are | {{tip|{{css}}'''Counter-Strike: Source''' maps, among other games', are known for including pre-built, blank cubemaps after compiling them. Their textures are generated even if there are no '''env_cubemaps''' in the map, and it is recommended to delete them prior to building cubemaps as explained [[#Deleting cubemaps|here]].}} | ||
=== LDR === | === LDR === | ||
{{note|This step | {{note|This step does not apply to {{csgo}}'''Counter-Strike: Global Offensive''' as its maps are compiled in [[#HDR|HDR]] mode only.}} | ||
Building cubemaps on a map compiled in '''LDR''' (''Low Dynamic Range'') mode will generate textures only for said 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" | ||
|- | |||
! Command !! Description | ! Command !! Description | ||
|- | |- | ||
| <code>mat_specular 0</code> || Disables | | <code>mat_specular 0</code> || Disables reflections. Required to properly build cubemaps | ||
|- | |- | ||
| <code>map</code> | | <code>map ''cs_mymap''</code> || Loads a map; replace "''cs_mymap''" with the map's actual name | ||
|- | |- | ||
| <code>sv_cheats 1</code> || Enables the use of cheat commands. Required to build cubemaps | | <code>sv_cheats 1</code> || Enables the use of cheat commands. Required to build cubemaps | ||
Line 31: | Line 33: | ||
| <code>disconnect</code> || Unloads the map, returning you to the main menu | | <code>disconnect</code> || Unloads the map, returning you to the main menu | ||
|- | |- | ||
| <code>mat_specular 1</code> || Enables | | <code>mat_specular 1</code> || Enables reflections | ||
|- | |- | ||
| <code>quit</code> || (optional) Closes the game. Required to | | <code>quit</code> || (optional) Closes the game. Required to display newly-built cubemaps (after relaunching it) | ||
|} | |} | ||
=== HDR === | === HDR === | ||
Building cubemaps on a map compiled with [[HDR]] support needs to be done twice - once for each mode ('''HDR''' and '''LDR'''). As opposed to a '''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. To build the cubemaps, submit the following commands into the game's console: | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! Command !! Description | ! Command !! Description | ||
|- | |- | ||
| <code>mat_specular 0</code> || Disables | | <code>mat_specular 0</code> || Disables reflections. Required to properly build cubemaps | ||
|- | |- | ||
| <code>map</code> | | <code>map ''cs_mymap''</code> || Loads a map; replace "''cs_mymap''" with the map's actual name | ||
|- | |- | ||
| <code>sv_cheats 1</code> || Enables the use of cheat commands. Required to build cubemaps | | <code>sv_cheats 1</code> || Enables the use of cheat commands. Required to build cubemaps | ||
Line 51: | Line 53: | ||
| <code>buildcubemaps</code> || Starts building cubemaps | | <code>buildcubemaps</code> || Starts building cubemaps | ||
|- | |- | ||
| <code> | | <code>disconnect</code> || Unloads the map, returning you to the main menu | ||
|- | |- | ||
| <code> | | <code>sv_cheats 0</code> || Disables cheat commands. Prevents command <code>''mat_reloadallmaterials''</code> from unnecessarily self-executing and briefly freezing the game | ||
|- | |- | ||
| <code>mat_hdr_level 0</code> || Switches to '''LDR''' mode (from '''HDR''') | | <code>mat_hdr_level 0</code> || Switches to '''LDR''' mode (from '''HDR'''); submit <code>''mat_hdr_level 2''</code> instead if '''LDR''' cubemaps were built first | ||
|- | |- | ||
| <code>map</code> | | <code>map ''cs_mymap''</code> || Loads the map again to build cubemaps for the new mode | ||
|- | |- | ||
| <code>sv_cheats 1</code> || | | <code>sv_cheats 1</code> || | ||
Line 65: | Line 67: | ||
| <code>disconnect</code> || | | <code>disconnect</code> || | ||
|- | |- | ||
| <code>mat_specular 1</code> || Enables | | <code>mat_specular 1</code> || Enables reflections | ||
|- | |- | ||
| <code>mat_hdr_level ''0/1/2''</code> || If necessary, switches back to the mode it was before having submitted <code>''mat_hdr_level 0/2''</code> | | <code>mat_hdr_level ''0/1/2''</code> || If necessary, switches back to the mode it was before having submitted <code>''mat_hdr_level ''0/2''</code> | ||
|- | |- | ||
| <code>quit</code> || (optional) Closes the game. Required to | | <code>quit</code> || (optional) Closes the game. Required to display newly-built cubemaps (after relaunching it) | ||
|} | |} | ||
=== Half-Life: Source === | === Half-Life: Source === | ||
{{bug| | {{bug|Building cubemaps in {{hls}}'''Half-Life: Source''' isn't currently possible as the textures, despite being generated, aren't embedded into the map file afterward.}} | ||
:{{workaround|Move the | :{{workaround|Move the map file into the "maps" folder of a game of the same engine branch (such as {{hl2}}'''Half-Life 2'''), build its cubemaps in that game, then move the file back into '''Half-Life: Source'''<nowiki>'</nowiki>s.}} | ||
=== Source Filmmaker === | === Source Filmmaker === | ||
{{bug| | {{bug|Cubemaps built in other games will display weird artifacts on reflections due to a sixth cubemap face that {{sfm}}'''Source Filmmaker''' doesn't seem to recognize (it uses only five of them). While rebuilding cubemaps in it would fix the issue, it is currently not possible to do so as '''Source Filmmaker''' generates blank textures.}} | ||
:{{workaround|Move the | :{{workaround|Move the map file into {{as}}'''Alien Swarm'''<nowiki>'</nowiki>s "maps" folder, build its cubemaps in that game, then move the file back into '''Source Filmmaker'''<nowiki>'</nowiki>s.}} | ||
::{{note| | ::{{note|'''Alien Swarm'''<nowiki>'</nowiki>s "gameinfo.txt" file needs to be edited for this procedure so that the game can have access to missing map assets not to build cubemaps with missing textures/models. The file's "SearchPaths" section should be like this:}} | ||
"SearchPaths" | "SearchPaths" | ||
{ | { | ||
Line 87: | Line 89: | ||
"Game" "swarm_base" | "Game" "swarm_base" | ||
"Game" "platform" | "Game" "platform" | ||
"Game" "..\SourceFilmmaker\game\hl2" | '''"Game" "..\SourceFilmmaker\game\hl2"''' | ||
"Game" "..\SourceFilmmaker\game\tf" | '''"Game" "..\SourceFilmmaker\game\tf"''' | ||
"Game" "..\SourceFilmmaker\game\tf_movies" | '''"Game" "..\SourceFilmmaker\game\tf_movies"''' | ||
"Game" "..\SourceFilmmaker\game\usermod" | '''"Game" "..\SourceFilmmaker\game\usermod"''' | ||
} | } | ||
{{note|{{tf2}}'''Team Fortress 2''' configurations were used for this example; consider replacing game subfolders (only those within '''Source Filmmaker''' paths) with the needed ones.}} | |||
== Deleting cubemaps == | == Deleting cubemaps == | ||
Delete unnecessary or outdated cubemaps is made possible with the use of several tools; of them all, [[BSPZIP]] not only is an official one, but also the easiest and safest option for this procedure without potentially corrupting the map. To delete the cubemaps, execute the following command within the "maps" folder: | |||
..\..\bin\bspzip -deletecubemaps mapname.bsp | ..\..\bin\bspzip -deletecubemaps mapname.bsp | ||
{{note|Replace "''mapname''" with the map's actual | {{note|Replace "''mapname''" with the map's actual name.}} | ||
{{warning| | {{warning|Deleting cubemaps actually deletes all the texture ("[[Valve Texture Format|.vtf]]") files embedded into the map, so it's recommended not to embed custom textures prior to deleting cubemaps.}} | ||
== Extracting cubemaps == | == Extracting cubemaps == | ||
In cases where a map | 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 until it actually becomes so. To extract its cubemaps with '''BSPZIP''', create a folder inside the "maps" one that will contain the extracted cubemaps, and execute the following command: | ||
..\..\bin\bspzip -extractcubemaps mapname.bsp "foldername" | ..\..\bin\bspzip -extractcubemaps mapname.bsp "foldername" | ||
{{note|Replace "''mapname''" with the map's actual | {{note|Replace "''mapname''" with the map's actual name, and "''foldername''" with the actual name of the folder to extract cubemaps into.}} | ||
=== Embedding cubemaps === | === Embedding cubemaps === | ||
To make a map use extracted cubemaps, create a text file | To make a map use extracted cubemaps, create a text file that will be used with '''BSPZIP''' - the file should be created inside the "maps" folder and will contain paths to the files to embed into the map. The file's content should be like this: | ||
materials/maps/mapname/ | materials/maps/mapname/c-128_384_64.hdr.vtf | ||
'''foldername\materials\maps\mapname\ | '''foldername\materials\maps\mapname\c-128_384_64.hdr.vtf''' | ||
materials/maps/mapname/ | materials/maps/mapname/c-128_384_64.vtf | ||
'''foldername\materials\maps\mapname\ | '''foldername\materials\maps\mapname\c-128_384_64.vtf''' | ||
materials/maps/mapname/ | materials/maps/mapname/c448_-256_64.hdr.vtf | ||
'''foldername\materials\maps\mapname\c448_-256_64.hdr.vtf''' | |||
materials/maps/mapname/c448_-256_64.vtf | |||
'''foldername\materials\maps\mapname\ | '''foldername\materials\maps\mapname\c448_-256_64.vtf''' | ||
materials/maps/mapname/ | |||
'''foldername\materials\maps\mapname\ | |||
materials/maps/mapname/cubemapdefault.vtf | materials/maps/mapname/cubemapdefault.vtf | ||
'''foldername\materials\maps\mapname\cubemapdefault.vtf''' | '''foldername\materials\maps\mapname\cubemapdefault.vtf''' | ||
{{note|Replace "''mapname''" with the map's actual | {{note|Replace "''mapname''" with the map's actual name, the cubemaps' names with appropriate 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, while the second one is the actual location of the file to embed into the map. 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 mapname.bsp textfile.txt newmapname.bsp | ..\..\bin\bspzip -addlist mapname.bsp textfile.txt newmapname.bsp | ||
{{note|Replace "''mapname''" with the map's actual | {{note|Replace "''mapname''" with the map's actual name, "''textfile''" with the text file's actual name, and "''newmapname''" 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 == | == Renaming a map == | ||
Built cubemaps are saved into a directory that uses the map's name; renaming it will cause its cubemaps not to load alongside the map, and therefore it will act as if there were none. To correct that, either delete then rebuild the cubemaps, or extract then embed them back, with their directory's name matching that of the map. | |||
== See also == | == See also == | ||
* [[env_cubemap]] | * [[env_cubemap]] | ||
* [[$envmap]] | * [[$envmap]] | ||
[[Category:Level Design]] | [[Category:Level Design]] |
Revision as of 11:27, 25 November 2020
A cubemap is a texture that represents a three-dimensional rendering of an area. The Source Engine uses env_cubemap entities as sampling points to generate these textures, which are then automatically embedded into the map file. Cubemaps, when built, are reflected on surfaces that use the $envmap parameter with env_cubemap as its value.
Building cubemaps
Building cubemaps is the process of generating their textures for reflective purposes. For technical reasons, this process is not automated and is up to the user to do so; until then, existing env_cubemaps will remain unused and the map, depending on the game, will display either generic or "missing" textures as reflections due to non-existing cubemaps.



Before building


LDR


Building cubemaps on a map compiled in LDR (Low Dynamic Range) mode will generate textures only for said 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 |
Disables reflections. Required to properly build cubemaps |
map cs_mymap |
Loads a map; replace "cs_mymap" with the map's actual name |
sv_cheats 1 |
Enables the use of cheat commands. Required to build cubemaps |
buildcubemaps |
Starts building cubemaps |
disconnect |
Unloads the map, returning you to the main menu |
mat_specular 1 |
Enables reflections |
quit |
(optional) Closes the game. Required to display newly-built cubemaps (after relaunching it) |
HDR
Building cubemaps on a map compiled with HDR support needs to be done twice - once for each mode (HDR and LDR). As opposed to a 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. To build the cubemaps, submit the following commands into the game's console:
Command | Description |
---|---|
mat_specular 0 |
Disables reflections. Required to properly build cubemaps |
map cs_mymap |
Loads a map; replace "cs_mymap" with the map's actual name |
sv_cheats 1 |
Enables the use of cheat commands. Required to build cubemaps |
buildcubemaps |
Starts building cubemaps |
disconnect |
Unloads the map, returning you to the main menu |
sv_cheats 0 |
Disables cheat commands. Prevents command mat_reloadallmaterials from unnecessarily self-executing and briefly freezing 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 cs_mymap |
Loads the map again to build cubemaps for the new mode |
sv_cheats 1 |
|
buildcubemaps |
Starts building cubemaps for the new mode |
disconnect |
|
mat_specular 1 |
Enables reflections |
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) Closes the game. Required to display newly-built cubemaps (after relaunching it) |
Half-Life: Source


Source Filmmaker


Workaround:Move the map file into
Alien Swarm's "maps" folder, build its cubemaps in that game, then move the file back into Source Filmmaker's.
Note:Alien Swarm's "gameinfo.txt" file needs to be edited for this procedure so that the game can have access to missing map assets not to build cubemaps with missing textures/models. The file's "SearchPaths" section should be like this:
"SearchPaths" { "Game" "|gameinfo_path|." "Game" "swarm_base" "Game" "platform" "Game" "..\SourceFilmmaker\game\hl2" "Game" "..\SourceFilmmaker\game\tf" "Game" "..\SourceFilmmaker\game\tf_movies" "Game" "..\SourceFilmmaker\game\usermod" }


Deleting cubemaps
Delete unnecessary or outdated cubemaps is made possible with the use of several tools; of them all, BSPZIP not only is an official one, but also the easiest and safest option for this procedure without potentially corrupting the map. To delete the cubemaps, execute the following command within the "maps" folder:
..\..\bin\bspzip -deletecubemaps mapname.bsp


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 until it actually becomes so. To extract its cubemaps with BSPZIP, create a folder inside the "maps" one that will contain the extracted cubemaps, and execute the following command:
..\..\bin\bspzip -extractcubemaps mapname.bsp "foldername"

Embedding cubemaps
To make a map use extracted cubemaps, create a text file that will be used with BSPZIP - the file should be created inside the "maps" folder and will contain paths to the files to embed into the map. The file's content should be like this:
materials/maps/mapname/c-128_384_64.hdr.vtf foldername\materials\maps\mapname\c-128_384_64.hdr.vtf materials/maps/mapname/c-128_384_64.vtf foldername\materials\maps\mapname\c-128_384_64.vtf materials/maps/mapname/c448_-256_64.hdr.vtf foldername\materials\maps\mapname\c448_-256_64.hdr.vtf materials/maps/mapname/c448_-256_64.vtf foldername\materials\maps\mapname\c448_-256_64.vtf materials/maps/mapname/cubemapdefault.vtf foldername\materials\maps\mapname\cubemapdefault.vtf

A file requires two dedicated lines (paths): the first line represents the path it will use within the map file, while the second one is the actual location of the file to embed into the map. 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 mapname.bsp textfile.txt newmapname.bsp

Renaming a map
Built cubemaps are saved into a directory that uses the map's name; renaming it will cause its cubemaps not to load alongside the map, and therefore it will act as if there were none. To correct that, either delete then rebuild the cubemaps, or extract then embed them back, with their directory's name matching that of the map.