Merge Images Window


Terragen is a landscape rendering program developed by Matt Fairclough. It is extremely good at creating realistic natural views, with fantastic lighting, skies and terrain texturing. However, in its present state it does not support any form of adding objects to the landscape.

When I first started writing Forester (in July 1999) its purpose was to create a POV-Ray scene that would mimic the Terragen scene, allowing any objects in the POV-Ray image to be 'cut-out' and positioned accurately onto the Terragen landscape.

It achieves this by rendering a number of images in POV-Ray, using various colours for the objects and terrain so that it can create 'Masks' for extracting the objects from the image. It can then process these images and overlay the objects onto a pre-rendered Terragen image.


By the very nature of the way the images are merged, there are a number of problems that are difficult to overcome:


Terragen and POV-Ray use different lighting algorithms which makes it difficult to match the two together. POV-Ray is an all-purpose ray-tracer, which means that it models individual rays of light. This makes it very accurate, and it is possible to create individual objects that are difficult to distinguish from the real thing. However, when rendering very large scale images (ie landscapes), a non-specialised raytracer cannot easily recreate atmospheric effects such as diffraction (creating blue skies and red sunsets), glare, haze, clouds, etc. Terragen, on the other hand, has been specifically written to create these atmospheric effects.

When creating images in Forester/POV-Ray to overlay onto Terragen images it can be difficult to render the POV-Ray scene so that the objects look as if they 'belong' on the Terragen landscape.


Terragen and POV-Ray use different methods for modelling the shape of waves on the water plane. This makes it impossible to merge the object reflections seamlessly between the two images. To overcome this, when merging the images, Forester takes the entire water plane from POV-Ray and overlays it onto the Terragen scene. The results are variable but are generally not too bad!

The Procedure

The procedure for creating a Terragen/POV-Ray composite is fairly straightforward, but can take a little time.

1. Render the Terragen Image

Find a suitable terrain and viewing location using the 3D preview window in Forester. Use the Export Camera button on the Camera Window to save a Terragen TGS script file of the coordinates. Import this into Terragen using the Terragen/Execute Script menu command.

Render the Terragen image and save it as Forester-R0.bmp in the Forester Scenes folder (the exact filename and folder is important as Forester does not currently give you the option to choose a different location).

Note: If using Terragen v0.8+ DO NOT set the 'Render Curved Terrain' option. This is not supported by Forester and the images will not merge correctly

Terragen Image - R0

2. Add the Forester Objects

Populate the Forester scene with objects and/or grass.

3. Render the POV-Ray Images

Open the Merge Images with Terragen window and render the four POV-Ray images - click the four Render buttons individually or use the Send to Queue option (Once the scenes have been generated by Forester open POV-Ray and manually add the four INI files in the \Queue folder to the POV-Ray queue).

Main Objects - R1

Objects Mask - R1

Shadows Mask - R2

False Shadows Mask - R3

5. Merge the Terragen/POV-Ray images

You should now have five images in the Forester\Scenes folder (Forester-R0.bmp, Forester-R1.tga ... Forester-R4.tga).

Click the Create Preview button. Thumbnails of the five images should be loaded and a thumbnail preview created of the final image. Alter the Haze Colour, Shadow Colour and Shadow Lightness settings to suit and click the Create Preview button again. Repeat until the preview looks acceptable.

Click the Generate Final Merged Image button. The images will be merged together and saved as Forester-Final.tga in the Forester\Scenes folder.

Merged Image - Final