[Tutorial] Building Cubemaps

Discussion in 'Tutorials & Resources' started by Xi.Cynx, Feb 19, 2011.

  1. Xi.Cynx

    aa Xi.Cynx Former Alias: †Blade†

    Messages:
    772
    Positive Ratings:
    721
    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.
     
    • Thanks Thanks x 36
    Last edited: Nov 19, 2011
  2. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,768
    Positive Ratings:
    5,508
    I was writing one up myself. I guess I'll wait and see what you do since I have enough other things that need doing too.
     
    • Thanks Thanks x 1
  3. Attsy

    Attsy L3: Member

    Messages:
    110
    Positive Ratings:
    27
    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.
     
  4. Fr0Z3nR

    aa Fr0Z3nR Creator of blackholes & memes. Destroyer of forums

    Messages:
    6,391
    Positive Ratings:
    4,902
    Something to add, and this was what was causing my cubemap issues, when posting maps, don't use the SDK file, use the one from the maps folder in tf.

    But this is good, I can't wait to see where else this goes. This will be a handy guide for all the new mappers.
     
  5. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,213
    I believe that's what mat_reloadallmaterials is for (as recommended in the Dev Wiki).
     
  6. Archmage MC

    Archmage MC L2: Junior Member

    Messages:
    61
    Positive Ratings:
    0
    I get the error "You can't save multiplayer games" when running mat_hdr_level 0 / 2. Is this supposed to happen?
     
  7. Seba

    aa Seba DR. BIG FUCKER, PHD

    Messages:
    2,363
    Positive Ratings:
    2,365
    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.
     
  8. Archmage MC

    Archmage MC L2: Junior Member

    Messages:
    61
    Positive Ratings:
    0
    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: Jun 18, 2011
  9. Seba

    aa Seba DR. BIG FUCKER, PHD

    Messages:
    2,363
    Positive Ratings:
    2,365
    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.
     
  10. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,213
    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.
     
  11. honeymustard

    honeymustard L9: Fashionable Member

    Messages:
    698
    Positive Ratings:
    273
    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)
     
    • Thanks Thanks x 1
  12. grazr

    aa grazr Old Man Mutant Ninja Turtle

    Messages:
    5,436
    Positive Ratings:
    3,557
    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.
     
    • Thanks Thanks x 13
    Last edited by a moderator: Aug 29, 2015
  13. C:/hdata

    C:/hdata L1: Registered

    Messages:
    15
    Positive Ratings:
    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: Sep 3, 2016
  14. Heronherald

    Heronherald L2: Junior Member

    Messages:
    80
    Positive Ratings:
    17
    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?