How to Make A 2D Skybox Texture from Scratch

Jul 26, 2015
694
819
Today I’m going to teach you one of the methods I used to make a custom skybox from scratch, without just changing the brightness or saturation of an existing skybox texture. In order to do this, you’ll need to know a bit of the basics about using a 3d modeling program. I use Blender, but the process should be applicable to any program.

What we will be doing is basically making a texture and mapping it to a sphere, then capturing the view of each side from within the sphere and saving it as a set of 6 images. This will provide us with the correct perspective for our skybox, so it doesn’t look like an obvious cube like this:

ac021a4b6614c896fd6dea521ce2897085be3c6d77bf727969b006da29bc16fc6g.jpg


You will need:
  • A 3D modeling program (like Blender)
  • VTFedit
  • Your favorite image editor

Setting up the Texture

First we have to get a texture to map to our sphere. You can either find one online (look for sphere mapped panoramas) or draw your own. There are a few things to keep in mind:
  • The horizon will be in the middle of the image, so you can leave the lower half blank if you want (unless you’re making some sort of outer space skybox).
  • The texture needs to tile horizontally, or else there will be a very obvious seam in your skybox.
  • Don’t draw anything too close to the top or bottom of the image, or else it will become distorted when we map it to the sphere (I’ll go into other ways to do this later).
PLr3cP5.jpg


Save your image as something like “sky_yoursky_spheremap”.

Setting up the Scene in Blender

If you’ve never used Blender before, here is a list of some basic controls.

Blender will give you a default scene with a cube, a camera, and a light source. Press A to select everything and delete it. Then go to Add > Mesh > UV Sphere.

5N7FFRv.jpg


With the sphere selected, press tab to go into edit mode. Then select Mesh > Normals > Flip Normals. This will make sure our texture is rendered on the inside of the sphere, and not the outside.

gP649jX.jpg


On the panel on the right, click on the Material tab (the checkered sphere) and press the “+ New” button to add a new material.

GIgoW6P.png


Scroll down to the Shading section and check “Shadeless”. This will make sure there will not be shadows cast on the inside of the sphere.

fPA6QkH.png


Then click on the Texture tab (the checkered square) and press “+ New”. Scroll down to the Image section and press “Open” to load your image.

iRTPSd4.png


Navigate to where you saved your image and select it. You should now see your image in the preview window. If you click on Viewport Shading in the bottom toolbar and select “Material”, you should be able to see the texture on the sphere.

ow3oyqq.jpg


However, the texture probably isn’t mapped correctly. With the sphere selected, go into edit mode (you can toggle between edit mode and object mode by pressing tab). Then, on the numpad, press 5 then 1 to change to 2D view. The screen should now look like this:

EgzK9rb.png

Press U, and select “Sphere Projection”. Things should now look a lot better.

uTuhvyF.png


If the texture still seems a bit stretched or misaligned, you may need to tweak the UV map. Click on the cube icon in the bottom left corner and select “UV / Image editor”.

ZhPEo4X.jpg


Press “Open” on the bottom toolbar next to the folder icon, and find your image just like before. You should now see something like this:

tNXYSNF.png


You can now adjust the map so it fits cleanly over the image. In this case I pressed G to slide it over a bit to the left. Make sure the vertices line up so the UV map tiles and there are no seams on the sphere.

Note: If you want to have complex elements like clouds or planets in your skybox, I recommend making them separate meshes inside the sphere instead of drawing them as part of the sphere's texture. For example, if you want a layer of clouds directly overhead, create a flat plane inside the sphere and texture it with clouds. This will prevent them from becoming distorted when the texture is "pinched" at the top and bottom of the sphere. For the simple gradient in this example, however, it doesn't matter.

Getting the Images

Next we need to capture the view of each side. To do this, we’ll use a camera. In object mode, go to Add > Camera. In the panel on the right, change “Millimeters” to “Field of View”, set the field of view to 90, and set the size to 0.5.

ywkzZQ5.png


Next, go to this tab and make sure the resolution is set to 1024 x 1024.

nzpVEOX.png


Press N to open up an extra panel. At the top you will see a section that says Rotation. Make sure X is set to 90, Y is 0, and Z is 0 (While you're at it, make sure the Location values are all set to 0).

QC45fBi.png


Then press F12 and like magic, Blender will show you what the camera sees. Press F3 to save the image somewhere. Name it “sky_yoursky_01ft” (where "yoursky" is the sky name). The "ft" in this case means front.

Mutkg0F.jpg


Click the icon in the bottom left to return to the 3D view. Repeat this process 3 more times, with the Z value set to 90, 180, and 270. Name these images with the suffixes “lf”, “bk”, and “rt”. For the top image, set X to 180 and Z to 270. Name this one ending in “up”. For the bottom image, set X to 0 and Z to 270, ending the name with “dn”. (For most skyboxes, the bottom face won't be visable, so it can really be anything.)

Now we should have a nice set of 6 images like this:

qgCOewH.png


Making the Textures Usable

Now we need to convert these images into vtfs and create vmts for them.

IMPORTANT: Ingame, the textures will get flipped around (for whatever reason). Therefore, you must mirror each of them in an image editor before you convert them to vtfs.

Open VTFedit and choose File > Import to open an image. Save it as a .vtf with the same name.

oMFHy4B.png


Now go to Tools > Create VMT file. Change the entry for "Base Texture 1" to "skybox/(your texture)" and click create.

Open up the new vmt and change the parameters to this:

Code:
"UnlitGeneric"
{
    "$basetexture" "skybox/(your texture)"
    "$nofog" 1
    "$ignorez" 1
}

mdPSZMs.png


Repeat this for the other 5 textures, the only difference being the appropriate texture name in the "$basetexture" parameter.

Now take all the vtfs and vmts and drop them in your tf/materials/skybox folder (or wherever you keep your skybox textures).

And there you go! Your skybox should be ready to use in hammer and should show up ingame (as long as you packed your bsp correctly).

StsRZxb.jpg
 
Last edited:
Jul 26, 2015
694
819
I take it clouds/ other complex parts are added through a program like skypaint

The issue with clouds is that the top of the skybox texture will get distorted as it is "pinched" at the top of the sphere. I would recommend creating a bunch of flat plane meshes, placing them inside the sphere, and mapping a separate cloud texture to those.
 

The Letter Before A

Cool Idiot
Jul 15, 2016
292
196
yeah I figured it out, this is a very good tutorial.
I'm still having some problems with cameras.
Every time I render it doesn't properly represent its view.
It has this weird effect over it making it all wavy.
 
Last edited:

The Letter Before A

Cool Idiot
Jul 15, 2016
292
196
The image on the side is the full rendered image. I can send you the .blend and the textures with it.
 
Jul 26, 2015
694
819
For me it looks like it almost renders perfectly fine, but somehow at the last second it changes to this. I can see you have a lot of settings that are different from mine, and I don't quite know what all of them are or if some of them might be affecting the render. But try selecting "Load factory settings" then copy and paste the objects into there and see if it works.

Also I realize I should probably put something in the OP about setting the correct resolution.
 

The Letter Before A

Cool Idiot
Jul 15, 2016
292
196
no luck
I'm honestly really confused, can you repeat the render, this time go to the tabs below the new window and under and find the one that when you click on has "render view" as an option.
Just so we first rule that its not just something with the camera.
 
Jul 26, 2015
694
819
I'm really confused as well. When I go to render It starts loading what looks like the image you have

454dea522c.jpg


But as soon as it finishes it turns into this

f3f260cf7b.jpg


This is very strange to me, I have no idea why this is happening. Is this what you are experiencing?