Creating HDRI Panoramas with Terragen

This is a quick and dirty tutorial I whipped up for craeting HDRI panoramas with Terragen.

Software

Creating the source images

Creating a single composite image

Displaying the Panorama


Camera Settings

The simplest method of creating a panorama from Terragen is to render 6 x 90° images representing the faces of a cube. For this we need the following camera settings for each image.

Graphic of camera setttings dialogue box

  1. Zoom = 1
  2. Exposure/Light Sensitivity = 1
    (actually I'm not sure if this effects the HDR output, I usually set this to 1 anyway)
  3. Effects = SO HDR Output

Gaphic of Photo Effects dialogue box

After adding the SO HDR Output effect you need to double click on it to set its options. There are only two options:

  1. the output filename and location
  2. whether to save a single file or saequentially numbered series for each render.

For the last option, just click OK to create a numbered series of files.

NB. Cube faces are square, so remember to set your image size to equal height and width!


Creating the Image Sequence

Displaying HDR panoramas via a java applet uses a lot of memory so don't get too ambitious on the image sizes. Stick to cube faces 500-750 pixels in size.

Most stitching applications prefer the images to be in the following order:

  1. Front
  2. Left
  3. Back
  4. Right
  5. Top
  6. Bottom

The simplest way of doing this in Terragen is to run the following script after you have selected your viewpoint:

initanim "C:\temp\cube", 1
CamOri 0,0,0
frend
CamOri 90,0,0
frend
CamOri 180,0,0
frend
CamOri 270,0,0
frend
CamOri 0,90,0
frend
CamOri 0,-90,0
frend 

This will give you 6 .bmp files (which you can also use to convert to normal QTVR panoramas) and 6 .hdr files


Creating the Panorama

From here it gets a little messy with a few extra file transfomrations as the images are eventually arranged into the appropriate format for viewing.

  1. Cube2Cross - convert the 6 .hdr cube faces into an .hdr image "cross"
  2. HDRShop - transform the .hdr image cross into an .hdr equirectangular projection (required for PTViewer)
  3. PTConvert - convert the .hdr image into a floating point JPEG image

Cube2Cross

(largely extracted from the Cube2Cross readme)

In order to allow Cube2Cross to be able to find all 6 files, the following naming convention is used:

Output from TG Input file for Cube2Cross Orientation Sample output image
???00001.hdr ???_ft.hdr "Front" image
???00002.hdr ???_rt.hdr "Right" image
???00003.hdr ???_bk.hdr "Back" image
???00004.hdr ???_lt.hdr "Left" image
???00005.hdr ???_up.hdr "Up" image
???00006.hdr ???_dn.hdr "Down" image
  1. Run Cube2Cross.EXE.
  2. A file selection box will come up. Select (any) one of the HDR images in the environment.
  3. The output file will be named ???_cross.hdr and will be placed in the same directory as the input files.

HDRShop

Luckily, HDR shop will reproject the cross images provided by Cube2Cross to equirectangular.

  1. Sample output imageOpen the cross image produced above in HDRShop
  2. From the menus select Image > Panorama > Panormamic Transformations
    1. Source image format = Cubic Environment (vertical cross)
    2. Destination image format = Latitude/Longitude
    3. Destination image height = 2 x height of rendered cube face
      e.g. if you rendered 750x750 pixel images from TG then your image height would be 1500
    4. Turn OFF Use Bilinear Interpolation
      If this is left on you will get black pixels appearing along the seams

Graphic of Panoramic Transformations dialogue box

Save the resulting image

 


Convert to Floating Point JPEG

This is a relatively simple stage requiring you to run PTConvert from the commandline. (You can try drag and drop but it didn't work for me using WinXP). You should read the readme file that comes with PTConvert and I'd recommend using at least the following options:

PTConvert Inputfile -o Outputfile -q quality

... remembering to use .fjpg for the file extension.


For the commandline-challenged you will need 3 files in the same directory.

  1. Your HDR panorama from above
  2. The PTConvert application
  3. A text file with a .bat extension.

e.g. Using the Lat/Long image you produced in the previous section, with a name of mypano.hdr, type the following text in notepad:

PTConvert mypano.hdr -o mypano.fjpg -q 100

and save it as "ptconvert.bat" in the same directory as PTConvert.exe.

Double click on ptconvert.bat and wait for mypano.fjpg to appear. If PTConvert crashes, it is usually because the input file specified doesn't exist. If you leave out the -q option PTConvert will use a quality of 80 as the default.


 


Viewing the Panorama

See the readme for PTViewer for now. The basic code for the applet is included below. Click and drag on the image to pan around. The exposure of the image will change to match the proportion of light and shade. The image artefacts around the sun are a glitch caused by Terragen. You can avoid this by a) hiding the sun or b) setting the diameter of the sun to 0, although the latter is not much use for sunsets. Here is a test panorama with a sun diameter of 0.

The code for the applet:

 <applet code=ptviewer.class name="ptviewer" width=420 height=300 mayscript=true archive=ptviewer.jar>
 <param name=file value="cube.fjpg">
 <param name=gamma value="1.5">
 <param name=exposure value="500">
 <param name=autorange value="20">
 <param name=quality value=2>
 </applet>