Creating a Quake 3 skybox using Terragen




Skywhat?!


This article explains how to create a skybox for your map. This involves creating a scene in the free (as in free beer) Windows software Terragen. You can also use other programs to achieve the same task of course, that is not described here though. This article should apply to all id Tech3 based games but I tested it with Quake 3 Arena and Quake2World.

This article uses a Terragen script and some Windows shell scripts I wrote to make the creation of the skybox very easy. Once you've got your scene ready in Terragen, basically all you have to do is run the scripts. :)

I'd like to add here that the terragen script is based on an article over at the C4 engine wiki. The camera rotation commands were taken from the Valve Developer Wiki. More info on both Terragen and Q3A shaders was taken from the Terragen tutorial by lloydm, hosted by Bill Brooks.



Preparations


Ok, let's install all the stuff (skip things you already have).



Creating the skybox from your Terragen scene




1. Start Terragen and create the scene you want to use as a skybox


I'll assume that you've already created a Terragen scene you want to make a skybox from. This tutorial doesn't explain how to use Terragen (google for Terrage tutorials, check the Terragen website or just try it, it's easy.)

  • Adapt all the other stuff on the left menus to your needs (Water, Cloudscape, Atmosphere, Lighting Conditions) or leave them the way they are if your scene is already done.

  • Save the terrain file to "skybox.ter".

    * [Landscape Window] => Save ...

  • Save the world file to "skybox.tgw".

    * [Menu] => World File => Sav World ...


2. Set high detail mode and choose maximum image size


  • At the left side of the "Rendering Control" window there is a scroll bar next to the word "Detail". Set detail to maximum (far right).

  • In the "Rendering Control" window, click on the "Render Settings" button and select the "Quality" tab. Change both "Atmosphere" and "Cloud shading" to high accuracy. Close the "Render Settings" window.

  • In the "Rendering Control" window, click on the "Render Settings" button and set the image "Width" and "Height" to the maximum of 512x512 pixels for the free edition of Terragen. (If you registered Terragen, you can choose higher values like 1024x1024.)

    The images must be square and in powers of two (i.e., 128x128, 256x256, 512x512, 1024x1024, ...).


3. Setup the camera


  • Note that I am NOT setting the camera position in the script (that would be useless because it could be inside a mountain for your terrain!), so you'll have to do that. It's very easy though, just left-click somewhere near the center of the grey-scale image in the lower right part of the "Rendering Control" window.

    Now make sure that the camera is above terrain level (the value in "Camera Position - Fixed Height above Surface" must be positive, just change it if it is negative). Done.

    The camera orientation doesn't really matter 'cause the script cares for that, but you can set "head", "pitch" and "bank" to 0 if you want to render a proper preview. You can ignore all the "Target Position" values, they are also handled by the script. The Zoom value ("Rendering Conttrol" => "Camera Settings" => "Zoom / Magnification")is also controlled by the script (must be 1 for skyboxes).


4. Save modifications


  • It's now time to save the world file again so it contains all the settings you just adapted. You may want to save to a different file name if you want to keep the old scene / settings.


5. Adapt a line in the 'create_skybox.tgs' script to your needs (or create the folder 'C:\skybox\')


  • In the script, find the line that starts with the word 'initanim'. It should look like this by default:

    initanim "C:\skybox\skybox", 1

    Make sure the folder listed in that line exists! ("C:\skybox\" in this example).



    Simply create the folder or use another folder and adapt that line accordingly.


6. Run the 'create_skybox' script from Terragen


  • Doublecheck that everything is setup correctly, then run this script from Terragen:
    * [Menu] => Terragen => Execute Script ...

    It should take a while and render 6 images. They are stored in the directory you defined in step 5.


7. Post-processing


  • This is not handled by this script or Terragen. I wrote some win32 shell scripts to make this easier though. ;)

    You need to rename the images to use them as a skybox:
    skybox0001.bmp --> skybox_ft.bmp
    skybox0002.bmp --> skybox_lf.bmp
    skybox0003.bmp --> skybox_up.bmp
    skybox0004.bmp --> skybox_bk.bmp
    skybox0005.bmp --> skybox_rt.bmp
    skybox0006.bmp --> skybox_dn.bmp


    The 'rename_skybox_files.cmd' script does this for you. Copy it to where your output files are ("C:\skybox" if you followed the example) and adapt the name of your skybox in the script (unless you used the default "skybox" like I did in the example), then run it (just double-click it).

    (Alternatively, you may run it from a shell prompt and supply the name of your skybox as a parameter on the command line.)

  • You need to convert the images to tga (or jpg) format. Use the gimp, imagemagick or whatever you like to do this.

    The 'convert_to_tga.cmd' and convert_to_jpg.cmd' scripts can do this for you if you have imagemagick installed. Copy them to where your output files are ("C:\skybox" if you followed the example) and adapt the name of your skybox in the scripts (unless you used the default "skybox" like I did in the example), then run them (just double-click them).

    (Alternatively, you may run them from a shell prompt and supply the name of your skybox as a parameter on the command line.)

  • You need to add the shader files for Quake 3 Arena. Have a look at the original scripts by id software or read the tutorial by lloydm on how do that (at the bottom of the page).

    You can also download one of my skyboxes and have a look at the directory structure. Just copy it and replace the tga files in the 'env/mymap/' directory with your files.