[TUTORIAL] The Complete Guide To Implementing Custom Skybox Textures And Env Lighting

Discussion in 'Tutorials & Resources' started by Rexy, Feb 8, 2009.

  1. Rexy

    aa Rexy The Kwisatz Haderach

    Messages:
    1,795
    Positive Ratings:
    2,366
    [TUTORIAL] The Complete Guide To Implementing Custom Skybox Textures And Env Lighting

    This tutorial will take you through the complete process for creating custom skybox textures, using them in your map, configuring the correct light_environment, implementing accurate shadows with shadow_control, and (optional depending on your choice of skybox texture) env_sun settings.

    Please keep in mind this tutorial assumes the following:

    • You understand the basics of map creation and compiling.
    • You understand how to create custom materials and understand the basics of .vtf and .vmt files.
    • You understand the concept of 2-D vs. 3-D skybox.
    • You understand how to extract stock skybox textures using gcfscape (optional)
    • You understand how to use Terragen (optional)

    Conception:

    The first thing to plan out is your map’s conception. What do you want your map to look like? The skybox texture will have a massive impact on the appearance of your map. Setting the light_environment will change the whole color of your map, and that includes visibility.

    Take a look at the following screenshots of a map in early development. The first two screenshots use a goldrush skybox and light_environment settings; the second two use the Alpine theme and skybox texture. Notice how the visibility differs between the two:

    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]

    The color choices drastically affect the mood and feel of the map. Also note the positioning of shadows as a result of differentiated light_environment settings.

    Take a look at this next example:

    pl_cashworks:
    [​IMG]
    [​IMG]
    [​IMG]

    See how the use of the alpine theme with the chosen texture choices affect the mood of the map? A second shameless example:

    pl_zig:
    [​IMG]
    [​IMG]
    [​IMG]

    The choices in your light_environment are severely going to affect the saturation of colors in your map, at least in the outside sections.

    As well, take a look at this map in development that is taking this issue to heart:
    cp_furnace:

    1st pass
    [​IMG]
    2nd pass
    [​IMG]

    Youme and Nineaxis are concerned with the overall lighting in cp_furnace. A light_environment setting that is too saturated or bright in one color will cause confusion, darkness and overall irritability amongst players. The idea is to make players want to play your map—not drive them away. Making your map adequately lit will encourage fair play and a pleasant atmosphere. It’s a constant struggle to balance design and functionality all at once.

    Getting Started:

    After you have either picked a TF2 theme to work with, or conceptualized your own, it’s time to get down to business. You’ll need one of the following ways to get your hands on raw materials:

    A.) Images to create your own skybox texture with. You can take your own, and put them together seamlessly in a photo editor, or you can find some online. There are some great one here: http://www.cgtextures.com/

    B.) A premade custom skybox texture set. There are LOTS around on the internet, and in particular FPSBanana.com.

    C.) Extracted stock skybox materials from Valve using GCF Scape. These can then be altered in terms of color, contrast and brightness (and any other way you’d like to do it!) Youme and Nineaxis have done this for cp_furnace:

    [​IMG]

    [​IMG]

    As you can see, they’ve used the Goldrush skybox and changed the color considerably to make the image appear as they wanted it to look. Be creative!

    D.) Terragen. Terragen is a 3-D tool that can generate a 360 landscape by set parameters from the user. It’s a very powerful tool, however requires knowledge to use the software, and generates photorealistic images—images that wouldn’t fit the TF2 theme. We’ll cover some work arounds later for this problem. You can get Terragen here: http://www.planetside.co.uk/terragen/

    The Layout:

    However you acquire your images, you’ll have to deal with strict formatting and naming issues that will tell the engine how to place each of the 6 images you’ll use for your skybox texture. You’ll have to edit your photos to make sure they combine seamlessly.

    If you were to take each of your 6 images and lay them out in a manner that the engine understands, it would look like this:

    [​IMG]

    Note the use the two letter abbreviation for each. This is how the engine interprets your 6 images so that they can be placed inside the map. For this tutorial, I’ll make a very simple skybox setup using gradients. Know that in actuality this is much too plain; you’ll want to work out your own setup that works for your map, and for the style of TF2.

    Here are the individual .vtf for each part of the skybox:

    [​IMG]

    And here they are in the layout cross-box, seamless (or not so well, as you can see I haven’t done the best job in the world):

    [​IMG]

    After I’ve saved these 6 images to 6 different .vtf files (I’m using the photoshop .vtf plugin, makes life great!), you can see our results:

    [​IMG]

    You can see the naming scheme for each file. As discussed earlier, the RexyBoxft.vtf and .vmt correspond to the image that will appear in the front of the skybox. The same are true for the rest of the files. You’ll have to name your files with the abbreviated letters at the end of each of your new .vtf files if you are making your own skybox texture.

    Now let’s set our .vmt parameters. Create a new .vmt (textpad) and examine the following:

    [​IMG]

    The “$nofog” 1 and “$ignorez”1 are typical of skybox textures because they should be immune to fog and resolution settings (meaning they should scale to fit the environment parnoramically, 360). Also note the “skybox/RexyBoxup” directory setting. The engine will ONLY grab custom skybox textures that are in team fortress 2\tf\materials\skybox. Add the corresponding parameters for your skybox texture files, save those files up for each .vmt, and place them in that team fortress 2\tf\materials\skybox directory.
     
    • Thanks Thanks x 35
    Last edited: Feb 8, 2009
  2. Rexy

    aa Rexy The Kwisatz Haderach

    Messages:
    1,795
    Positive Ratings:
    2,366
    Implementing The Custom Skybox In Hammer:

    Assuming you’ve made your textures correctly, and you’ve placed them in the correct directory, it’s time to move on to business. Open up hammer and create a basic hollow room. This is for testing purposes. I am making mine 1024 units X by 1024 units Y and 512 units Z. You can make yours whatever size you’d like.Make the floor some happy texture and then give the walls and ceiling the skybox texture.

    [​IMG]

    Now to set our skybox texture to be used, we’ll need to go to Map, Map Properties, then set the SkyBox Texture Name to our skybox texture name, in this case RexyBox. Notice that the abbreviated letters are not included.

    [​IMG]

    Next, add in a light_environment entity, and a env_cubemap (‘cause every good mapper should have one, even in test chambers!).We’ll want to pick some colors for the Brightness setting, since that’s major testicles of the lighting. I’ll open up my skybox image RexyBox in Photoshop to and pick two colors with the eyedropper tool. The first color I’ll pick is the brightest color, and is usually where the sun is located. The second color is the darkest color—but in this case I pick the darkest color of the sky. We’ll ignore what’s on the ground, since the ground color is usually the ground’s local color (art term there) and the addition of whatever light is hitting it.

    [​IMG]

    Pay attention here to the RGB values of the colors we’ve picked with the eyedropper tool . These will go directly into the light_environment’s properties. You want the Brightness value to be your brightest value, and the Ambient value to be your darkest.

    [​IMG]

    For ambient, the alpha (amount in brightness) is set to 20 by default and for Brightness the alpha is set to 200 by default. We’ll leave these be for now.
    Now you should be able to compile your map and see the use of these custom skybox textures. The brightness alpha settings, and pitch yaw roll for the sun’s angle aren’t correct—but we’ll fix that in the next section.

    [​IMG]

    Modifying Light_Environment, Env_Sun And Shadow_Control Settings

    The most important part about this next section is to stress the importance of patience. Since we aren’t provided with the parameters for our light_environment like we are on the source sdk documents sky list page, we’ll have to do some ‘hit and miss’ strategies. We won’t get things perfect the first time—in fact it may take you many compiles before you do hit it right on the spot.

    It’s for this reason that we build a test room that’s small to incorporate and test the correct settings—then you can import them directly into your final product (pl_rexybox!). Compiling and recompiling on a full map is a waste of time—you’ll spend hours before you get it correct instead of a few minutes. We’ll get the settings right and there’s less time wasted and everyone gets what they want.

    I’ll place some brushes as pillars to measure the Pitch Angle of my cast shadows for brush based entities. I’ll guess my sun’s angle by looking at the rexybox layout image. If the middle of the image was directly over head, and I was looking directly at the horizon, then angle between the distance is 90 degrees. I’m guessing for the first time that my sun is at about 30 degrees. I’ll set the Pitch to -30 (because the acceptable value is between 0 and -90) and compile.

    [​IMG]

    As you can see, the Pitch Yaw Roll isn’t correct for us to tell if the Pitch is correct, so we’ll need to fix that before moving onward. In RexyBox the sun is located on the FRONT of the skybox—which just so happens to be located at 90 degrees Z. By estimating again the angle from the picture, I am assuming that the sun is about at 120 degrees Z. I’ll set it and compile.

    [​IMG]

    By positioning myself at the very edge of the shadow and the ground, I can see that the Pitch Angle of the sun is just about right…I may adjust by a degree or two. But clearly, the Pitch Yaw Roll Angle is off. The sun, pillar and shadow should all line up in a vertical line. I’ll need to move the Yaw (Z) by about 8 to 10 degrees to get it into the right spot. Also, the shadow is REALLY dark. Right now the ambient is set to 20 for the alpha brightness, so I’ll crank it up to about 75 and see what happens.

    [​IMG]

    Yes! We are right on the money! And that shadow color has lightened up a bit, but it’s not enough. I’ll change it from 75 to 150. That way, when players are in it, they don’t become dark figures that no one can see. You may wish to set your ambient even higher. Youme Recommends setting the ambient at least to 300.

    [​IMG]

    After adjusting these settings, you can see the comparison shots of being in light and shadow. I think these are good settings to stick with. Lamps, reflections, and whatever else you chose to light your map with will make the shadows less dark. Remember that slight adjustments can be made later for your tastes, and you can always compile a second pass with color correction to get things just right.

    But there’s a few things left before we finish! Look at that heavy’s shadow! Terrible! Time to fix it. Place in a shadow_control entity. The good news for us, is that by spending all the time finding the correct values for the light_environment, they can plug directly into the shadow_control.

    [​IMG]

    The diagram shows a few things! The settings are so similar you can use the same values! The Shadow color is the Ambient lighting in the light_environment entity, pitch is the same value without the negative in front of it, and Yaw is exactly the same. And that’s it for the shadow_control entity. I’ll compile and test.

    [​IMG]

    No problems there! Now to take care of the env_sun. Again, our work has already been done for us! Check out the diagram:

    [​IMG]

    Again the same values are used, including Pitch Yaw Roll, and Pitch. In this case, the Sun’s color is our Brightness value in our light_environment entity. Perfect. Make sure you set the ‘Use Angles’ to yes. Depending on your skybox texture, you may want to change the color slightly for a warmer color, and increase the size of the sun.

    And that’s it! May you create custom skyboxe textures to your heart’s delight! Go forth and create!

    Feel free to PM to ask questions if you need to, or ask em here!

    Thanks!
     
    • Thanks Thanks x 33
    Last edited: Feb 8, 2009
  3. cornontheCoD

    cornontheCoD L7: Fancy Member

    Messages:
    437
    Positive Ratings:
    70
    Thanks, this will come in handy
     
  4. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,739
    Noooo dont tell people this!!! :p

    I prefer to use an env_sun for the actual sun effect, this makes it 1000% easier to match up the sun, light and shadows since they all use angles and you can just copy/paste the values from one entity to another. This also negates the need for an HDR skybox since the env_sun is dynamic already. Without the HDR effects of the skybox or an env_sun your skybox's sun will look flat.
     
  5. Rexy

    aa Rexy The Kwisatz Haderach

    Messages:
    1,795
    Positive Ratings:
    2,366
    Yeah, I noticed since goldrush doesn't have a sun in it normally, it's a good and crafty use of the env_sun--especially since the actual direction of the sun in that skybox is so vague. You can get a lot of mileage out of one skybox.
     
  6. eerieone

    aa eerieone

    Messages:
    1,009
    Positive Ratings:
    569
    Big thanks for that, it´s bookmarked and will be used in my next map :D
     
  7. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,739
    Exactly, I think cp_furnace's sun is about 20 degrees away from where goldrush's is, (combination of pitch and roll)

    You'll also want to note that the ambient you picked for your example is incdefibly dark, I've found that for large areas of shadow (caused by the usual, buildings, cliffs etc) will only be bright enough with a 300+ ambient.
     
    • Thanks Thanks x 1
  8. Nineaxis

    aa Nineaxis Quack Doctor

    Messages:
    1,767
    Positive Ratings:
    1,403
    In those first screens, that's not the dustbowl skybox, it's the goldrush.

    Lots of info in there to digest, I'll finish reading it now.
     
    • Thanks Thanks x 1
  9. Fearlezz

    Fearlezz L10: Glamorous Member

    Messages:
    787
    Positive Ratings:
    240
  10. DJive

    aa DJive Cake or Death?

    Messages:
    1,466
    Positive Ratings:
    736
    how did i over look this. Excellent right up
     
  11. III_Demon

    III_Demon L2: Junior Member

    Messages:
    57
    Positive Ratings:
    29
  12. The Political Gamer

    aa The Political Gamer

    Messages:
    4,468
    Positive Ratings:
    1,682
    Now I just need to get good at Photoshop. <_<
     
    Last edited: Aug 9, 2010
  13. God of Rock

    God of Rock L2: Junior Member

    Messages:
    54
    Positive Ratings:
    8
    My materials folder doesnt have a /skybox folder. Do i just make one?
     
  14. Boylee

    aa Boylee pew pew pew

    Messages:
    1,068
    Positive Ratings:
    630
    Yes.
     
  15. TheKieranator

    TheKieranator L6: Sharp Member

    Messages:
    282
    Positive Ratings:
    169
    Threadomancy

    ZOMBIE THREAD! Grab your pills!

    I am being pestered by an error in my custom skybox. :mellow:
    What I did was copy the sky_stormfront files from the GCF, modify the vtfs under a different name (sky_nightsnow_01), and modify the vmts to match the new name. I can view the textures in Hammer, and set the skybox to sky_nightsnow_01. When I compile and load up the map however, it decides to give an error and the hall of mirrors. The console says that it can't find skybox/sky_nightsnow_01rt.vtf (wrong directory), even though the vmt says to find sky_nightsnow/skynightsnow_01rt. In the next line it says that it can't find skybox/sky_urb01, and I have no idea why it says that. I have checked the vmts numerous times and found no problems. Assistance please!
     
  16. Skittelz Pie

    Skittelz Pie L6: Sharp Member

    Messages:
    356
    Positive Ratings:
    151
    Wait, aren't you supposed to put your custom skyboxes in ---tf\materials\skybox\ (your skybox files here)
    And also, the pictures of your skybox need to be seperate, like for example the down and up.
     
  17. zahndah

    aa zahndah professional letter

    Messages:
    715
    Positive Ratings:
    618
    The last post was almost 5 years ago and that member hasn't been online for almost 4 years.
     
  18. Skittelz Pie

    Skittelz Pie L6: Sharp Member

    Messages:
    356
    Positive Ratings:
    151
    omg
     
  19. Pocket

    aa Pocket func_croc

    Messages:
    4,476
    Positive Ratings:
    2,204
    I'm impressed that all the images still work though. And lol at that Payload version of what would become Zinkenite; I totally forgot that started out as a joke map.
     
  20. Skittelz Pie

    Skittelz Pie L6: Sharp Member

    Messages:
    356
    Positive Ratings:
    151
    i'm really embarrassed. i should take a look at dates now.

    dates - The Day on the Calendar. Not when you hangout with a girl.