Template:en

From Valve Developer Community
< Template:Archived Page History
Revision as of 04:20, 19 May 2023 by Kr0tchet (talk | contribs) (Created page with "{{langsp}} left thumb|right|300px|Specular reflections on props. A '''cubemap''' is a texture that represents a three-dimensiona...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Flag-white.pngEnglish (en)
Env cubemap.png
Specular reflections on props.

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 to then use them as reflections. 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 nonexistent cubemaps. Template:ModernWarning Template:ModernNote Template:ModernNote Template:ModernTip Template:ModernTip Template:ModernWarning

Before building

Template:ModernTip

LDR

Template:ModernNote Building cubemaps on 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 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. Optionally, specify the number of iterations (default is 1)
disconnect Unloads the map, returning you to the main menu
mat_specular 1 Enables reflections
quit (optional) Closes the game. Relaunching it is required to display newly-built cubemaps


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. Optionally, specify the number of iterations (default is 1)
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. Optionally, specify the number of iterations (default is 1)
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. Relaunching it is required to display newly-built cubemaps


Half-Life: Source

Template:ModernBug

Portal 2

Template:ModernBug

Source Filmmaker

Improper rendering of an HDR cubemap's face in Source Filmmaker.

Template:ModernBug Template:ModernNote

"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"
}

Template:ModernNote

Deleting cubemaps

Several tools make it possible to delete unnecessary or outdated cubemaps; of them all, BSPZIP not only is an official one, but is 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

Template:ModernNote Template:ModernWarning

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 that will contain the extracted cubemaps inside the "maps" one, then execute the following command:

..\..\bin\bspzip -extractcubemaps mapname.bsp "foldername"

Template:ModernNote


Embedding cubemaps

To make a map use extracted cubemaps, create a text file that will be used by BSPZIP - the file should be created inside the "maps" folder, and will contain paths to the files to embed into the map file. 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

Template:ModernNote 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 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 mapname.bsp textfile.txt newmapname.bsp

Template:ModernNote

Renaming a map

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

See also