Template:Archived Page History/Cubemaps/en: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Multipage removal)
(Replaced content with "{{APH|Cubemaps}}")
Tag: Replaced
Line 1: Line 1:
 
{{APH|Cubemaps}}
[[Category:TODO Finish Multipage Removal Manually]]
{{LanguageBar}}
{{Todo|Needs info about Source 2 cube maps, or can be it's own article}}
 
[[File:Env_cubemap.png|left]]
[[File:Specular.jpg|thumb|right|300px|An example of specular reflections on some models (exaggerated through {{cmd|r_showenvcubemap}}).]]
A '''cubemap''' is a texture that represents a three-dimensional rendering of an area. {{source|4.1}} uses {{ent|env_cubemap}} entities as sampling points to generate these textures, which are then integrated into the [[BSP|map file]]. Cubemaps, when [[#Building cubemaps|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 {{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 generic or [[Missing content|"missing" textures]] as reflections due to nonexistent cubemaps.
{{warning|{{clr}}
* For people with epilepsy: Building cubemaps on games running on Vulkan, such as {{l4d2|4.1}}, causes the screen to flash black and white violently.
* If the {{Command|nav_show_ladder_bounds}} command was used before building cubemaps, the green boxes will also be baked into the cubemap.}}
 
===Before building===
{{Cleanup|Modern Source games, namely {{portal2|1}} and {{p2ce|1|nt=1}}, do not need all these complicated params and steps, at least in my experience -[[User:Equalizer5118|Equalizer]] ([[User talk:Equalizer5118|talk]]) 10:56, 22 March 2024 (PDT)}}
{{classicImportant|Maps for {{src13|4.1}} games 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); these should be deleted before building new ones, as detailed [[#Deleting cubemaps|here]]. This is fixed in {{mapbase|4}}}}
{{tip|{{clr}}
* {{ent|env_cubemap}} entities [[Env cubemap#Keyvalues|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 [[Env cubemap#Keyvalues|size]] of an existing '''env_cubemap''', or else attempting to build them will either fail or even cause the game to crash.<br>For example, if the highest '''env_cubemap''' sizes 128x128, a resolution no lower than 512x512 will be required. (''128 &times; 4 &#61; '''512''' -&gt; 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.}}
* If you are using {{mapbase|4.1}}, you can add <code>-autocubemap</code> to your command line in {{hammer|4}}. The game will automatically build cubemaps
* {{slamminsrc|4.1|nt=1}} features the {{code|-nodefaultcubemap}} command, which skips automatically generating skybox cubemaps on map compile.}}
 
===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.}}
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"
|-
! Command !! Description
|-
| {{Command|mat_specular|0}} || Turns reflections Off; required to properly build cubemaps
|-
| {{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
|-
| {{Command|buildcubemaps}} || Begins building cubemaps. Optionally, specify the number of iterations (e.g.: <code>buildcubemaps 2</code> (default is 1))
|-
| {{Command|disconnect}} || Unloads the map and returns to the main menu
|-
| {{Command|mat_specular|1}} || Turns reflections On
|-
| {{Command|quit}} || (optional) Exits the game. Relaunching it is required to display newly-built cubemaps
|}
 
===HDR===
Building cubemaps in a map compiled with [[HDR]] support needs to be performed twice - once for each mode ('''HDR''' and '''LDR'''), depending on the game (games after {{L4d|1}} does not requires building cubemaps in 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. To build the cubemaps, submit the following commands into the game's console:
{| class="wikitable"
|-
! Command !! Description
|-
| {{Command|mat_specular|0}} || Turns reflections off, which is necessary if using only one iteration of buildcubemaps.
|-
| {{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
|-
| {{Command|buildingcubemaps|1}} || Sets HDR exposure to a consistent value. This will automatically reset back to 0 after cubemaps are built.
|-
| {{Command|buildcubemaps}} || Begins building cubemaps. Optionally, specify the number of iterations (e.g.: <code>buildcubemaps 2</code> (default is 1))
|-
| {{Command|disconnect}} || Unloads the map and returns to the main menu
|-
| {{Command|sv_cheats|0}} || Disables cheat commands; prevents command <code>''mat_reloadallmaterials''</code> from unnecessarily self-executing (which briefly freezes the game)
|-
| {{Command|mat_hdr_level|0}} || Switches to '''LDR''' mode (from '''HDR'''); submit <code>''mat_hdr_level 2''</code> instead if '''LDR''' cubemaps were built first
|-
| {{Command|map}} ''map_name'' || Loads the map again to build cubemaps for the new mode
|-
| {{Command|sv_cheats|1}} ||
|-
| {{Command|buildcubemaps}} || Begins building cubemaps for the new mode
|-
| {{Command|disconnect}} ||
|-
| {{Command|mat_specular|1}} || Turns reflections On
|-
| {{Command|mat_hdr_level|0/1/2}} || If necessary, switches back to the mode it was before having submitted <code>''mat_hdr_level 0/2''</code>
|-
| {{Command|quit}} || (optional) Exits the game. Relaunching it is required to display newly-built cubemaps
|}
 
==Building cubemaps in specific games==
===Black Mesa: Source===
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 +mat_specular 0</code><br>Then, load the map and submit the <code>buildcubemaps</code> command into the console.
 
===Half-Life: Source===
{{bug|Building cubemaps in {{hls|4.1}} 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 {{path|maps}} folder of a game in the same engine branch (such as {{hl2|4.1}}), build its cubemaps in that game, then move the file back into '''Half-Life: Source'''<nowiki>'</nowiki>s folder.}}{{modernConfirm|Fixed in {{hldms}}?}}}}
 
===Portal 2===
{{bug|Building cubemaps in {{portal2|4.1}} will fail if the map file is not in the highest-numbered DLC folder ({{path|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 Build Programs|Hammer's Build Programs]] options so that the map is automatically generated there.}}}}
 
===Portal 2: Community Edition===
{{bug|Amount of iterations (e.g.: {{command|buildcubemaps|2}}) doesn't currently work in {{p2ce|4.1}}.
{{workaround|Run the {{command|buildcubemaps}} command, reload the map, then run the command again. Successively repeat these steps if necessary.}}}}
 
 
===Source Filmmaker===
[[File:Cubemap_bug_sfm.jpg|thumb|right|300px|Improper rendering of an HDR cubemap's face in Source Filmmaker.]]
{{bug|'''HDR''' cubemaps sizing lower than 64x64 built-in {{tf2|4.1}} and some other games usually display graphical artifacts on reflections due to the last face of each cubemap not rendering properly in {{sfm|4.1}}. While rebuilding cubemaps in it would normally fix the issue, it is currently not possible to do so as {{sfm|4.1}} generates blank textures.
{{workaround|If recompiling a special version of an affected map with {{ent|env_cubemap}}'s now sizing 64x64 (or higher) is not an option, move the map file into {{as|4.1}}<nowiki>'</nowiki>s {{path|maps}} folder, build its cubemaps in that game, then move the file back into {{sfm|4.1}}<nowiki>'</nowiki>s folder.}}}}
 
:{{note|'''Alien Swarm'''<nowiki>'</nowiki>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|{{tf2|4.1}} configurations were used for the example; consider replacing game subfolders (only those within {{sfm|4.1}} paths) with the ones needed.
:{{workaround|Another option is to manually remove the [[$envmapsphere|sphere map]] (face #7) from the existing HDR cubemap textures. See [[$envmap#Creating a custom static cubemap texture|Creating a custom static cubemap texture]] for more info.<br>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 {{path|maps}} folder:
..\..\bin\bspzip -deletecubemaps map_name.bsp
{{note|Replace "''map_name''" with the map's actual name.}}
{{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.}}
 
==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 {{path|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.}}
 
 
===Embedding cubemaps===
For '''BSPZIP''' to make a map use extracted cubemaps, create a text file inside the {{path|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.}}
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).}}
 
==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.
 
[[Category:Level Design]]

Revision as of 23:44, 12 July 2024

Note.pngNote:Archived rest of page history of page Cubemaps
Icon-Important.pngImportant:These pages are linked often from page history logs so Special:WhatLinksHere will not show anything.