Making a Skybox Using Terragen

From C4 Engine Wiki

Jump to: navigation, search

Contents

Download and Install Terragen

Terragen can be downloaded here.

Terragen takes a little bit of practice to get the hang of. There are many websites that can teach you the basics. Here are some good ones:

The official guide
Terragen tutorial by E. DeGiuli
Terragen tutorial by C. Brooksbank - Recommended

Setting Up The Script

The skybox requires six images to be rendered. This script will automate the creation of all six so you do not have to repeatedly come back to your computer and readjust the camera after each render.

Use Notepad to save the following script as C4skybox.tgs. It can be saved anywhere. This script was updated on December 11th 2006, thanks to Fletcher.

; 1. Uncheck "Fixed Height Above Surface"
; In the horizontal plane, the "z" value will be the same as the
; camera automatically (unless you override the value). However,
; we are also going to be taking pictures of the UP (and possibly
; DOWN) directions relative to the camera position so we don't want
; the target fixed.
;
; 2. Set cloud/sunlight parameters
;
; 3. To the left side of the Rendering Control window there is a
; scroll bar next to the word "Detail". Set Detail to Maximum (far
; right). Also, click on the SETTINGS button to view the RENDER
; SETTINGS window. In the QUALITY section, scroll "Atmosphere" and
; "Cloud shading" to high accuracy. In the OPTIONS section uncheck
; the "Render Lanscape" option.
;
; 4. Below the SETTINGS button is a section to control the IMAGE SIZE.
; Set the Image Size width and height to the maximum 512x512 pixels
; for the best results. If you want to go lower in size, the images
; must be square and in powers of two (i.e., 128x128, 256x256). You
; will of course have less detail as well by going lower in size.
;
; 5. Make sure the folder listed in the function below exists  

initanim "C:\C4\Import\tga\skybox\skyRender", 1

; InitAnim  BaseImageFileName,StartFrameNumber
; The InitAnim command tells Terragen that an animation is to be
; rendered, and initialises the appropriate variables. It is
; necessary to have this command before any calls to FRend.
;
; We don't want clouds moving for skybox renderings, but I've put
; the comments below for information---
; CloudVel is used to automatically scroll the clouds across the
; sky. It will position the clouds correctly for each frame, no
; matter what frame number the script starts at. CloudPos tells
; Terragen where the clouds would be if it were rendering frame 0.
; CloudPos  x,y         ;the cloud position at frame 0
; CloudVel  speed, heading   ;cloud scroll speed per frame
;               (for entire animation)
;
; CamState      xpos,ypos,zpos,head,pitch,bank,zoom,exposure
;               (set zoom or exposure to a negative value to ignore)
; CamPos        x,y,z
; TarPos        x,y,z
; The x,y,z units are in Terragen terrain units; they could also be
; entered as meters
;
; CamOri        head,pitch,bank
; CamH          head
; CamP          pitch
; CamB          bank
;
; Zoom          zoom
; The FOV (field-of-view) formula in Terragen is 2 * tan-1( 1 / zoom ).
; If zoom = 1, then the FOV is 90
;
; Exp           exposure
; ShadowLight   lightness (must be in the range 0 to 100)
; WaterLevel    z
; SunDir        head,alt
;
; FRend ;(frame render, only works after using InitAnim)
;
;
; Terragen sun headings are calculated from north (0 degrees). If the
; angle is from the east they are positive angles down the right side
; to south (+180 degrees); if the sun is bearing from the west, the
; angles are negative from north (0) to south (-180).
;
;This should give us a mid-morning sun

sundir 120,50

;_rt 1 PosX  --->rotate east
Zoom 1.0
CamPos 128 128 0
TarPos 256 128 0
CamH 90
CamP 0
CamB 0
FRend

;_lf 2 NegX  --->rotate west
Zoom 1.0
CamPos 128 128 0
TarPos 0 128 0
CamH -90
CamP 0
CamB 0
FRend

;_ft 3 PosY  --->rotate north
Zoom 1.0
CamPos 128 128 0
TarPos 128 256 0
CamH 0
CamP 0
CamB 0
FRend

;_bk 4 NegY  --->rotate south
Zoom 1.0
CamPos 128 128 0
TarPos 128 0 0
CamH 180
CamP 0
CamB 0
FRend

;_up 5 PosZ --->rotate to south and pitch up 
Zoom 1.0
CamPos 128 128 0
TarPos 128 128 128
CamH 180
CamP 90
CamB 0
FRend

;_dn 6 NegZ --->rotate to north and pitch down
Zoom 1.0
CamPos 128 128 0
TarPos 128 128 -128
CamH 0
CamP -90
CamB 0
FRend

; Post-processing
; 1. Convert to tga format and move to Import/tga folder (if different from
;    Terragen export folder)
; 2. Import into C4 (setting S and T clamped; no mipmap) in sequence; the order
;    will name the images in the same sequence as C4 (1-6)

Adjust the output path accordingly. Note that the output path must already exist, Terragen will not create folders for you.

Rendering The Skybox

1. When you open Terragen you will be presented with two windows, Rendering Control and Landscape. Close the Landscape window, we will not be using it in this tutorial.

2. Uncheck the Land box. Set the detail all the way up in the Rendering Control window. Set the width and height both to 512. This is the best you can do with the freeware version. If you have registered Terragen, set them both to 1024. Adjust the camera settings as highlighted in the image below.



3. Click on the Camera Settings button and adjust the zoom to 1. This is already done by the script above however we're changing it here to give us an accurate preview.



4. Now open the CloudScape window and adjust the Sky size to 16384. This will, to an extent, eliminate black areas appearing in our images.



5. Hit the Render Preview button to see how your skybox is looking. With default settings it should look like this.



Due to a bug in Terragen you will have to use Photoshop to remove the black areas at the bottom of each rendered image. These black areas will not occur if you render land.

6. You should double check that you did the first five steps right so you don't waste a lot of time. Now, choose Execute Script... from the Terragen menu, and choose the file C4skybox.tgs that you created earlier. Now the rendering will commence. It may take a while with advanced rendering options. Call someone you love.

7. When the rendering is complete, a dialog will pop up saying the script is complete. Quit Terragen.

Get The Textures Ready

Now, if you open up C:\C4\Import\tga\skybox\ you'll see six new BMP files.

skyrender0001
skyrender0002
skyrender0003
skyrender0004
skyrender0005
skyrender0006

Use Photoshop or PaintShopPro to save them as TGA files.

For information on using skyboxes with C4, please visit the Using Skyboxes page.

Personal tools