---
deprecated: true
excerpt_separator: <br/>
category: technology
layout: post
title: 'Tutorial: Creating OpenSim terrain with Blender'
date: '2009-09-08T17:18:00.000-04:00'
author: Anna Wiggins
tags:
- tutorial
- opensim
- second life
- linux
- metaverse
- Technology
modified_time: '2013-10-22T11:19:50.728-04:00'
blogger_id: tag:blogger.com,1999:blog-4209116010564764361.post-5832678214939499715
blogger_orig_url: http://www.stringofbits.net/2009/09/tutorial-creating-opensim-terrain-with.html
---

This tutorial will explain how to create RAW terrain files for <a href="http://opensimulator.org/wiki/Main_Page">OpenSim</a> and <a href="http://secondlife.com">Second Life</a> using <a href="http://blender.org">Blender</a> and the <a href="http://www.gimp.org/">Gimp</a>.<br/><a name='more'></a><br/><h3>Before we begin</h3><br/>You will need the following software for this tutorial.  All of this software is free and open source.<br/><ul><br/>	<li><a href="http://blender.org">Blender</a>, a professional 3d modelling tool.  Blender is powerful but complex, and basic blender knowledge is assumed for this tutorial.  Blender will be used to actually create the heightmap.</li><br/>	<li><a href="http://www.gimp.org/">The Gimp</a>, a powerful program for creating and editing raster (i.e. normal) image files.  The Gimp will be used for splitting the heightmap into RAW terrain files that OpenSim can use.</li><br/>	<li><a href="http://dominodesigns.info/project/gimpterrain">gimpterrain</a>, a plug-in for The Gimp that allows it to open and save RAW terrain files.</li><br/>	<li><a href="https://github.com/annabunches/terrainerizer">terrainerizer</a> (optional), a bash script I created to automate splitting the heightmap into RAW files.  Terrainerizer only works on Linux, and still requires The Gimp and gimpterrain to be installed.  It also requires <a href="http://www.imagemagick.org/script/index.php">ImageMagick</a>.</li><br/></ul><br/>In addition to the above software, you will also need a blank RAW terrain file.  You could download a terrain file from OpenSim and transform it into a blank one (replace the Height layer with #ffffff, replace the factor layer with #808080), or you could just use the one I've included with terrainerizer.<br/><br/><h3>Create a heightmap</h3><br/>A good tutorial on creating a generic heightmap in Blender can be found <a href="http://wiki.blender.org/index.php/Doc:Tutorials/Textures/Maps/Creating_a_Heightmap_from_a_Plane">here</a>.<br/><br/>The tutorial above creates a heightmap that is 512x512 pixels.  However, an OpenSim RAW terrain file is only 256x256 pixels.  This means that the above tutorial will create terrain for 4 regions, arranged in a square.  If you need terrain for a different number of regions, you can modify the above tutorial to create different sized heightmaps.<br/><br/>For example, suppose you want to create an oblong island that is 2 regions by 4 regions in size.  To do that:<br/><br/>1. Create the plane, but instead of scaling it to 2x2 blender units, scale it to 2x4 blender units.  To do this, you can use this command sequence in blender:<br/><ul><br/>	<li>Right-click on the object to select it.</li><br/>	<li>Change the mode to Edit mode.</li><br/>	<li>Press 's', 'y', '2', 'return'.</li><br/>	<li>Press 's', 'x', '4', 'return'.</li><br/></ul><br/>Now you should have a plane that is oblong instead of perfectly square.<br/><br/>2. When you configure the render settings, you will need to use different values.<br/><ul><br/>	<li>In the Scene settings (F10), SizeX and SizeY should be set to 256 * (number of regions).  In our case, we have 2 regions in the Y dimension, and 4 regions in the X dimension.  So, SizeX should be set to 1024, and SizeY should be set to 512.</li><br/>	<li>In the camera settings, the scale needs to be adjusted to fit the plane precisely.  In our example, the scale should be set to 8.  To get it just right, select the camera, and press Numpad0 to switch to camera view.  You should see two concentric rectangles composed of dashed lines.  Now, press F9 to view the Editing options for the camera.  Now, adjust the Scale value until the outer dashed rectangle encompasses your plane completely, without including anything outside the plane.  If the dashed rectangle is not the same shape as your plane, then you still need to set SizeX and SizeY in the Render settings.</li><br/></ul><br/><br/><br/><h3>Creating RAW terrain files with the Gimp</h3><br/>Now that you have a heightmap file, you still need to turn it into terrain files that can be uploaded into OpenSim.<br/><br/>Enter <a href="http://dominodesigns.info/">Domino Marama</a>, creator of <a href="http://dominodesigns.info/project/gimpterrain">gimpterrain</a>, an import/export plug-in for the Gimp that can handle the OpenSim RAW terrain format.  Download gimpterrain and install it into your gimp plug-ins directory.<br/><br/>Now, if you are running Linux, you can automate the rest of this section with my terrainerizer script.  See <a href="#easier">below</a>.<br/><br/>We also need the blank terrain file that I mentioned earlier.<br/><br/>Armed with these tools, we can open a terrain file in the gimp and combine it with a portion of our heightmap.<br/><br/><ol><br/>	<li>Open your blank terrain file (blank.raw) and the heightmap in the Gimp.</li><br/>	<li>Using the Rectangle Select tool, select a 256x256 pixel section of the heightmap, starting in the upper-left corner.</li><br/>        <li>Click Edit -&gt; Copy</li><br/>	<li>Select the terrain file and make sure the Height layer is selected.</li><br/><li>Click Edit -&gt; Paste.  You should see the section of the heightmap you copied appear as a floating layer.</li><br/>	<li>Click Layer -&gt; Anchor Layer.  The Height layer should now look like the copied portion of the heightmap.</li><br/>        <li>Click File -&gt; Save As and save this file as a new file with the .raw extension.</li><br/></ol><br/><br/>Now, repeat this process for every 256x256 pixel section in your original heightmap.<br/><br/><h3><a name="easier">Making it easier</a></h3><br/>Performing the steps in the previous section is very tedious, especially given how long it takes to save the terrain files.  To make this easier, I have automated the process with the <a href="https://github.com/annabunches/terrainerizer">terrainerizer</a> script.<br/><br/>If you are running Linux, simply put the terrainerizer script somewhere in your path.  Edit it and specify the path to your blank.raw file, then run:<br/><br/><blockquote><code>terrainerizer heightmap.png</code></blockquote><br/><br/>Replace 'heightmap.png' with your heightmap file.  Now let terrainerizer work.  It will handle everything we did in the previous section automatically.  It may take a while, depending on how large your heightmap is.<br/><br/>When it is finished, terrainerizer will leave several files in your current directory, named with this scheme:<br/><br/><code>heightmap-nxm.raw</code><br/><br/>Where 'n' and 'm' are numbers starting at 0 that represent the column and row for that terrain file.  So, <code>0x0</code> is the top left region of your terrain, <code>0x1</code> is the next region (moving from top to bottom), and so on.  Just upload these terrain files and you're done!<br/><br/><br/><h3>Uploading the terrain files</h3><br/>Now that you have the terrain files, you can upload these files into OpenSim.  There are two ways to do this.<br/><br/>1. From the OpenSim server console, you can simply:<br/><br/><blockquote><code>change region RegionName<br/>terrain load /path/to/terrain.raw</code></blockquote><br/><br/>Repeat this for each of your regions.<br/><br/><br/>2. From a viewer connected to OpenSim (assuming you are using Hippo or a similar viewer):<br/><br/><ul><br/><li>Move to the region you where you want to upload terrain.<br/></li><li>Navigate to World -&gt; Region/Estate -&gt; Terrain</li><br/><li>Click "Upload RAW Terrain..." and select the terrain file you created for this region.</li><br/></ul><br/><br/>[caption id="attachment_190" align="alignright" width="300" caption="The Upload Terrain menu in Hippo"]<a href="http://stringofbits.files.wordpress.com/2009/09/upload_terrain.png"><img src="http://stringofbits.files.wordpress.com/2009/09/upload_terrain.png?w=300" alt="The Upload Terrain menu in Hippo" title="upload_terrain" width="300" height="218" class="size-medium wp-image-190" /></a>[/caption]<br/><br/>Repeat these steps for each region where you want to upload terrain.<br/><br/><br/><em>Edit: Apparently wordpress.com doesn't allow arbitrary files any more, so I've moved terrainerizer to github. The links have been fixed above, or you can simply click <a href="https://github.com/annabunches/terrainerizer">here</a>.</em>