[Tutorial] Creating Custom 2D Skyboxes for Team Fortress 2 using Blender

adam2

(no affiliation with adam1)
aa
Jan 2, 2020
20
38

Introduction

Welcome to my guide on how to create skyboxes for Team Fortress 2 (and other source games) using Blender as our method of creating the skybox!

With this guide you can expect a step-by-step walkthrough on how to create both HDR and non-HDR skyboxes. The method used may be used for other source titles but this guide will focus exclusively on how to create a skybox for Team Fortress 2.

This guide originally came with an HDR section on each step. However, I need to re-do the HDR sections as the functionality of the HDR process turned out to be less than idea. Please bear with me!

Please note:

This guide is provided for a technical overview of how to create skyboxes within Blender and successfully import them into Team Fortress 2. The artistic aspects of creating a skybox in the artstyle of Team Fortress 2 is beyond the scope of this guide.
Please also consider:
Though this guide is designed around the use of Blender, if you wish to use a different software to create your skyboxes, following this guide whilst excluding sections pertaining to blender will yield satisfactory results.

If you encounter any errors with this guide or if you have any recommendations on how the guide can be improved upon please comment or contact me directly.


Prerequisties​

This guide makes use of the following software. It assumes that you have the most up-to-date version of the software as of when this guide was created. This guide may work with earlier versions of this software but functionality is only tested on the following versions:
The specifics of how to use each software for our purposes will be showcased later within the guide.


Setting Up Blender

Setting our Resolution​

By navigating to the Output tab we can change the output resolution of our scene. For our purposes, the output resolution has to be of a 1:1 scale that is a power of 2 (1024x1024, 2048x2048, etc).

For reference, the highest resolution for a skybox currently in-game is 2048x2048. For this guide we will set the output resolution to the same. Keep in mind however, you may set the output resolution to much higher than this and downscale to the desired size you want using the % slider.

The scene will be rendered at the desired resolution and you may find more pleasing results to render at a higher resolution with a 50% scale. (Rendering at 4096x4096 with a 25% scale will produce a 1024x1024 skybox). However keep in mind that doing this will increase render times.

blender_scene_format.png




Creating our Cameras​

Starting with a blank scene create a camera. Position it at the centre of the 3D space.

With your camera positioned you want to give the camera the following rotation: [X: 90, Y: 0, Z: 90]. This rotation is that of our forward camera so be sure to rename the camera 'cameraFT' in the scene outliner.

Onto the options for the camera, you want to navigate to the Data tab within the camera object.
You want to set the settings to the following:

Type: Perspective​
Lens Unit: Field of VIew​
Field of View: 90​
Assuming the camera is set up you want to copy the camera until you have six camera objects in total. To prevent having to input the above information each time you can have each camera use the first cameras settings. This can be accomplished by clicking the dropdown button that looks like a camera and selecting the first camera data property which should be named 'Camera' by default. If each camera uses the same property then changes to the camera will be copied over each camera in the scene.

blender_camera_lens.png



Exporting the Skybox

The following steps will guide you through exporting your skybox in blender for both HDR and non-HDR skyboxes. HDR Skyboxes require exporting in openEXR and then they must be converted to pfm.

I am using photoshop for this conversion but there may be alternative software for this purpose. If you know of any I'd love to be made aware so I can update the guide. I want to provide a way to follow this guide without purchasing software such as photoshop.



Before exporting our skyboxes we must change our scene to accept multi-camera exporting. To do this navigate to the Scene tab and find the Stereoscopy dropdown. Select Stereoscopy to enable it and highlight multi-view. You will notice two entries in the list here for "left" and "right". Disable these.

Within Stereoscopy click the plus icon to add an item. Here we want to change the Camera Suffix to be the same as each of our cameras. Therefore we want to have an entry with a Camera Suffix for BK, DN, FT, LF, RT, and UP.

What this now allows us to do is to export each camera's image in a single render instead of having to render six times. They will be created as seperate images in our output folder with the camera suffix appended to the filename.

blender_stereoscopy.png



non-HDR Skyboxes

To export our skybox in a standard format navigate to the Compositing panel.

Here we simply want to set our file output type to be Targa with an RGB color space. Be sure that Views Format is set to Individual. Click the Add Input button and name the file subpath as what you want your skybox to be called without the face suffix. (sky_guide_ for example).

Note: Your exported images will have your camera suffix appended but they will also have the sequence number which will need to be manually removed from the filename.

Clicking F12 at this moment, assuming everything has been set up correctly, your scene should begin rendering. Depending on your settings and your system hardware this may take some time.

blender_render_composite.png


Importing the Skybox

The process by which we import our skyboxes into source is fairly simple.

non-HDR Skyboxes

In our export folder we want to be sure that our filenames are correct. Assuming you followed the steps previously your filenames may read as "sky_guide_0001BK", "sky_guide_0001DN", etc. Trim the sequence number from this filename so they read "sky_guide_01BK", "sky_guide_01DN", etc.

Source appears to like skyboxe names to be formatted like this. If you were to simply name your files "sky_guide_bk", for instance, when setting the skybox in the map properies of your map you would have to input "sky_guide_", which feels clumsy. This appears to be convention for skybox names in source so its good to keep to it.

We will be using VTEX to convert our skyboxes into the .vtf format. This is relatively simple to use. For non-HDR skyboxes you may be able to use VTFEdit instead but for consistency I will be using VTEX.

Simply create a text file per image for our skybox. Within these text files copy the following:

nonice 1 dxt5 1 skybox 1 // Used for compiling skyboxes. This assures the edges match between each face clamps 1 clampt 1 nolod 1 // Do not use lower resolution versions of this texture regardless of texture quality settings nomip 1 // Do not use mipmapping for this texture. This is bugged and mips will still be generated. pointsample 1 // Do not filter this texture in-game.

We want to drag these text files and our image files into our materialsrc folder. This will be found in the tf folder (...\Steam\steamapps\common\Team Fortress 2\tf\materialsrc). Within the materialsrc folder create a new folder named skybox.

Now navigate to VTEX. This may be found in your game's bin folder (...\Steam\steamapps\common\Team Fortress 2\bin). Once you find vtex.exe highlight your text files in your materialsrc\skybox folder and drag and drop them onto the application in the explorer window. Only drag and drop your .txt files, not your image files.

You will notice VTEX processing each image.

Once VTEX is finished you will find your new image files in your skybox folder. (...\materials\skybox). You will notice that VTEX did not create .vmt files. We will have to do this manually.

Inside of your .vmt files you will want to have the following:

"sky" { $basetexture "skybox/sky_guide_01DN" $hdrcompressedtexture "skybox/sky_guide_01DN" // this must be here otherwise hdr will have missing textures $nofog 1 $nomip 1 $ignorez 1 }

Change the filename in $basetexture to be your filename. Create a .vmt file for each face so that you have six of them all sharing a filename with their corresponding .vtf file and with the $basetexture path changed accordingly.

With your new .vmt files made open up Hammer (or Hammer++ if you are hip and cool like me). With a map open navigate to the Map Properties tab. In the skybox field type the name of your skybox (without the face suffix). Given everything has worked you will be able to see your skybox in the preview window!

skybox_example.png



Trimming the Mips

Whilst Skyboxes in Team Fortress 2 do not utilise mipmaps and the no mipmap flags are set within the textures, the mipmap data is still there. This is because of a bug in VTEX. Using VTFEdit to import your texture files will avoid this. However, since I showed the steps for how to import the files using VTEX we will have to manually delete the mips.

Luckily there is a handy tool available that will accomplish this task for us.

VTFTools comes with "vtfzapmips.exe". This will delete all mipmaps within our .vtf files, leaving the file with only one texture.

To install VTFTools simply drag the contents of the downloaded .7z file to the folder where your VTFEdit application is located.

Now individually drag each .vtf file you want to zap the mips from into vtfzapmips.exe. This should automatically trim the file's mipmaps. You should notice the file size decrease. The decrease will be much more substantial for higher resolution skyboxes. Keep in mind that these gains are multiplied by six times since you will be trimming mipmap data from each face. For my non-HDR skyboxes I managed to save 6MB overall.

Conclusion​

I hope this guide provides a straight-forward way to create 2D skybox textures for your projects!

Remember that the method of importing will work regardless of which software you use to make your skyboxes. Just be sure that your textures are seamless.

If there is anything left out in this guide or any areas that would require greater explaination please let me know.

Thank you! Wishing you some happy skies!
 
Last edited:

Pdan4

Still trying to add
aa
Nov 25, 2013
104
246
Thanks! This is very helpful and much more convenient than wrangling each render separately.

A few notes: you wrote Scenes tab but actually it should be the Output tab. Also, each camera has to be named like this: "Camera_SUFFIX", so like "Camera_UP". Weirdly rigid for Blender but it can give you an error, "<Cameraname> not multi-view Camera!" and not render.

Also, for me, it doesn't automatically save the images (I probably didn't check "Use Compositor" if that's still in this version I use, 3.6.0). Instead, the render window pops up, showing the last view, but when you save it has you save all the files at the same time by setting their name, and only appends the suffix so you don't even need to rename anything. I find this preferable, myself. See for yourself:

1693271506015.png


Oh yeah, one more thing: it'll be more convenient in Hammer (and better for future editions or versions of skies) to end your sky name with, like, 001a, without the trailing "_".

OH YEAH! One final thing. DXT5 SUCKS for detailed things like skies. Puts in horrid banding. I highly recommend uncompressed (BGR888, at least for non-HDR, I don't know what the right choice is for HDR). It does inflate the map size but I think it's worth it for something you can see pretty much all the time from any angle.
 
Last edited:

adam2

(no affiliation with adam1)
aa
Jan 2, 2020
20
38
I'll give the guide a reworking when I have time!

Thank you a lot for your comment its very insightful and means a lot. Cheers!
 

Lacry

L6: Sharp Member
Feb 25, 2019
341
256
I am using photoshop for this conversion but there may be alternative software for this purpose. If you know of any I'd love to be made aware so I can update the guide. I want to provide a way to follow this guide without purchasing software such as photoshop.
Actually there is a website that is exactly like Photoshop, its's called Photopea, I wish they release it as software or something (cause I dont like relying in websites for this kind of things), but its a really good alternative to Photoshop, and hey it's free.

Also I think it would be nice if you included a zip with the blender and vmt files, cause its something you only to do once and reuse it over and over again (yea, im lazy).
 

adam2

(no affiliation with adam1)
aa
Jan 2, 2020
20
38
Actually there is a website that is exactly like Photoshop, its's called Photopea, I wish they release it as software or something (cause I dont like relying in websites for this kind of things), but its a really good alternative to Photoshop, and hey it's free.

Also I think it would be nice if you included a zip with the blender and vmt files, cause its something you only to do once and reuse it over and over again (yea, im lazy).
Hi!

Thanks for the information, I wasn't aware of Photopea.

I'll try to get together a zip file with the .blend and .vmt files eventually. Currently busy writing an article about material proxies and also I have quite a bit of university work, so I have a lot to do!

If I find time within the week I'll get that set up. If I appear to have forgotten feel free to nudge me on the matter sometime in the future.

Cheers!