[Tutorial] Building Cubemaps

RavenStryker

Former Alias: †Blade†/Xi.Cynx
aa
Nov 25, 2008
782
849
For the years I have been on here, there are posts and posts of people helping other people with the dreaded "purple checkerboard" issue. Letting them know to properly build their cubemaps, which made me think, can people easily find on here how to build them? So I did a quick search in the tutorials section and couldn't find a flat bold tutorial that said "How to Build Cubemaps" or "Building Cubemaps". Thus why this thread right here has been created. Grant it there aren't any fun pictures to look at(yet) but the needed information is now set right here in front of you without having to scavenge through random posts trying to find out how to properly build your cubemaps. This will get more updated over time including more and more fine details so don't blow your hat off if it seems bland at first. /rant

----- ----- ----- -----

Now for the fun stuff, I'm guessing everyone has a basic knowledge of using the console(that could come back to bite me later). But once you start up TF2 you just simply enter in the following commands in your 'console' without the -'s and you will successfully and properly build cubemaps for your map which will give you proper reflections on windows, water and anything else shiny. AS WELL AS getting rid of all the purple checkerboards! Enjoy


Building cubemaps for LDR
-mat_specular 0
-map <mapname>(Load your map)
-buildcubemaps
-mat_specular 1
-disconnect
-map <mapname>(Load a different level; clears texture cache)
-map <mapname>(Load you map again


Building cubemaps for LDR & HDR(recommended)
-mat_specular 0
-map <mapname>(Load your map)
-buildcubemaps
-disconnect
-mat_hdr_level 0
-map <mapname>
-buildcubemaps
-disconnect
-mat_specular 1
-mat_hdr_level 2
-map <mapname>(Load different level; clears texture cache)
-map <mapname>(Load your map again)

----- ----- ----- -----

Whats to come:
  • Pictures
  • Detailed Explainations
  • Artwork

Note: If, after completing these steps you still have a purple checkerboard you may want to check you map for a leak as these steps are full proof and will work everytime.
 
Last edited:

Attsy

L3: Member
Jan 31, 2010
110
29
What ever happened to the one by CameronD? He delete it or something?

Aw well, great tutorial, will be nice to link someone to this rather than type out the steps.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,699
2,581
-map <mapname>(Load a different level; clears texture cache)

I believe that's what mat_reloadallmaterials is for (as recommended in the Dev Wiki).
 

Archmage MC

L2: Junior Member
Jun 17, 2011
61
1
I get the error "You can't save multiplayer games" when running mat_hdr_level 0 / 2. Is this supposed to happen?
 

Seba

DR. BIG FUCKER, PHD
aa
Jun 9, 2009
2,364
2,728
To switch HDR levels through the console, you have to disconnect (be in the main menu, not on a server). However, I am not 100% sure about this and I am probably wrong, but disconnect before switching HDR levels anyway.
 

Archmage MC

L2: Junior Member
Jun 17, 2011
61
1
I get a message saying "You are not in a local game" when swapping HDR levels in the main menu, no idea if it actually swapped the levels or not.

Also getting an error when building cubemapes "mod is not in subdirectory "game" " even though the map is under tf/maps. Is that normal?
 
Last edited:

Seba

DR. BIG FUCKER, PHD
aa
Jun 9, 2009
2,364
2,728
Yep, both of those messages are normal. The former means that you are not playing a singleplayer game and the latter means...I don't know, but it's something silly that Valve probably broke on accident a long time ago.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,699
2,581
I get a message saying "You are not in a local game" when swapping HDR levels in the main menu, no idea if it actually swapped the levels or not.

Also getting an error when building cubemapes "mod is not in subdirectory "game" " even though the map is under tf/maps. Is that normal?

The console says a lot of things. Does it build them anyway? If so, then just ignore it. The cubemaps flashing on your screen is all the feedback you need.
 

honeymustard

L9: Fashionable Member
Oct 26, 2009
698
575
The method in the OP isn't the best, I would recommend doing the following, which bypasses the long load time of turning off mat_specular whilst in a game/on a map and also avoids the black bits on your overlays (usually on roads):

-mat_specular 0
-map <mapname>(Load your map)
-buildcubemaps
-disconnect
-mat_hdr_level 0
-mat_reloadallmaterials; map cp_badlands; map <mapname> (Clears texture cache)(Load different level; ensures clear texture cache)(Load your map again)
-map <mapname>
-buildcubemaps
-disconnect
-mat_specular 1
-mat_hdr_level 2
-map <mapname>(Load your map again)
 

grazr

Old Man Mutant Ninja Turtle
aa
Mar 4, 2008
5,441
3,814
There's no need to disconnect at all, loading a new map disconnects you automatically. Also mat_reloadallmaterials isn't necassery and usually doesn't work.

Assuming you have HDR on:

Console Command | Affect
mat_specular 0|Turns off reflections so purple checkers aren't baked into your new cubemaps
map prefix_yourmap_suffix|Loads your map
buildcubemaps|Builds HDR cubemaps
map cp_badlands|Loading a new map clears your memory cache
mat_hdr_level 0|Turns off HDR ready for LDR cubemaps to be baked
map prefix_yourmap_suffix|Loads a fresh version of your map in LDR
buildcubemaps|Builds LDR cubemaps
map cp_badlands|Clears your memory cache again
mat_hdr_level 2|Turns HDR back on
mat_specular 1|Turns reflections back on
map prefix_yourmap_suffix|To view end results

This is the most efficient and precise way to do it.

FAQ:

Why do we have to turn off reflections when creating our cubemaps?
We turn off reflections so that the purple checkers that appear on default/missing cubemaps don't get baked onto our new reflections from other reflective sources. However you can leave reflections on for a second cubemap bake to get reflections of reflections; your original cubemaps will be over written so you wont increase the file size (but most surfaces aren't reflective enough to show a quality reflection of other reflective surfaces).
Why do we clear our memory cache?
In practical terms we refresh the cache because running specular or hdr level commands corrupts the rendering of overlays and we don't want to record this in our reflections. This is also why we run the specular command before loading the map.
Why change the map to badlands?
Any map will do but i've found the badlands loads the quickest, so you can get this process out of the way faster by using it over other options.
 
Last edited by a moderator:

C:/hdata

L1: Registered
Dec 21, 2015
15
6
Can you please note something about how the buildcubemaps command will actually edit the map file and that it's the map maker who's meant to be doing this?

I've had map makers tell me multiple times to use buildcubemaps myself, but I'm not sure if they realize that it'll only edit the map for that one client. Which is fine and all if you're a server owner like me and will change the map name to a new version and reupload it to the server but...

If the client's version of the map differs from the server, the client will be unable to join the server until they delete it and redownload the version on the server.

And reploading a copy to one's own server isn't viable for workshop maps because then we lose autoupdating from the workshop if the map maker is updating the map.
 
Last edited:

Cincomma

bonk sploosh
aa
Aug 2, 2017
429
413
I have a question, do you tick the HDR box in the hammer compile window? because I applied the commands to my map and everything was insanely bright and reflective. Any remedy for this problem?