Blender 2.5 has a new import feature that can be used for making terrain in Blender. Most terrain tutorials are about getting terrain into Blender and little if anything about getting it out. Those that are about exporting terrain are mostly for Blender 2.49. There are enough changes between 2.49 and 2.59 that it is hard to figure how to accomplish 2.49 tasks in 2.59. This article is about importing terrain to Blender and exporting for use in Second Life and OpenSim. Part 1 is about getting terrain in and Part 2 about getting terrain out.
I’ll be working with Blender 2.59 and OpenSim 0.7.2 Dev. The height maps can be used in either SL or OpenSim.
Terrain Vertices Count
First I need to know what I’ll be exporting for use in OpenSim. Plus I have a terrain I’ve worked on for some time in OpenSim that I want to get into Blender to start from. I need to import and export terrain to and from Blender.
The OpenSim web site has a page describing an older process for making terrain. (OpenSim Terrain Workflow) According to that information a height map image for a single region should be 256×256 pixels, which provides a pixel for each vertex in the terrain. So, that is the goal.
They also point out what is needed for larger regions. For instance, a 3×3 region area would need a 768×768 pixel image to hold the terrain. Before importing to OpenSim/SL the image would need to be sliced into 9 – 256×256 images, one for each region. The situation is different if one is running Mega-Regions.
When importing terrain Blender can handle more or less pixels than the precise number needed for the terrain’s number of vertices. Mismatching can cause oddities in the appearance within Blender. Oddly, larger images create more problems than too small image. Overly large images will produce stairsteps. But, mismatches certainly will not break the process. Within Blender One can work with as many vertices in a terrain as works for you.
When one converts their mesh into a height map, they are converting it into an image. For upload to OpenSim or SL the image will need to be 256×256 pixels for a 256x256m region. Fortunately in Blender the size image you create is independent of the number of vertices in the mesh.
Importing Terrain
If you have started a terrain in OpenSim, as I have, it is possible to export existing terrain from OpenSim using simulator console commands. That can give you a beginning terrain to start with. I’ll warn you now. It is a pain to get the exported height map from Blender to ever be the same vertical height as the export from OpenSim. Expect to have to spend some time tweaking train settings in Blender.
It is also possible to get RL terrain from government agencies and import it to Blender then OpenSim/SL. Google for how to convert RL terrain for use in Blender.
If you have started a terrain in OpenSim, it is possible to export existing terrain from OpenSim using simulator console commands. That can give you a beginning terrain to start with. I’ll warn you now, it is a pain to get the exported height map the same vertical height as the imported terrain. Expect to have to live with some warp or plan to spend some time tweaking settings in Blender.
It is also possible to get RL terrain from government agencies and import it to Blender then OpenSim/SL. Google for how to convert RL terrain for use in Blender.
OpenSim Console Commands
Following are the current console commands available in OpenSim. I’ll explain the commands as needed.
=== terrain ===
- terrain load – Loads a terrain from a specified file.
- terrain load-tile – Loads a terrain from a section of a larger file.
- terrain save – Saves the current heightmap to a specified file.
- terrain save-tile – Saves the current heightmap to the larger file.
- terrain fill – Fills the current heightmap with a specified value.
- terrain elevate – Raises the current heightmap by the specified amount.
- terrain lower – Lowers the current heightmap by the specified amount.
- terrain multiply – Multiplies the heightmap by the value specified.
- terrain bake – Saves the current terrain into the regions revert map.
- terrain revert – Loads the revert map terrain into the regions heightmap.
- terrain newbrushes – Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug
- terrain stats – Shows some information about the regions heightmap for debugging purposes.
- terrain effect – Runs a specified plugin effect
- terrain flip – Flips the current terrain about the X or Y axis
- terrain rescale – Rescales the current terrain to fit between the given min and max heights
Terrain maps can be exported from or imported to OpenSim as: .r32 (RAW32), .f32 (RAW32), .ter (Terragen), .raw (LL/SL RAW), .jpg (JPEG), .jpeg (JPEG), .bmp (BMP), .png (PNG), .gif (GIF), .tif (TIFF), and .tiff (TIFF).
Using PNG files gives one the expected gray scale map.
To get terrain out of OpenSim type: terrain save [path\file name.png]. If there are spaces in the path or file name enclose the entire path and name in double quotes.
Getting the Terrain into Blender
There are two ways to get terrain into Blender. One is to use the Import -> Images as Planes feature in Blender 2.5x. One needs to enable the feature as it is an extra. Open the top menu, File -> User Preferences. If you plan to use this feature often, enable the feature immediately after opening Blender or making a new file. Enable and then Save As Default. This last step will make it a permanent part of your default setup.
Using the Images as Planes function is not mandatory. One can open the UV/Image Editor and import/open any image as an alternative. Use the window mode selector to select the UV/Image Editor. (See the image) In the menu there is the item IMAGE which is used to open/import an image. Just open the OpenSim exported height map image.
One will need a plane to impose the height map on. If one uses the Import Images as Planes, it creates a plane and imports/opens the height map image.
If you skip using the Images as Planes function, you only need to create the plane and open the height map image using basic Blender commands.(Plane: Shift+A Mesh Plane – Image: switch to UV/Image Editor -> Image -> Open Image)
Using Images as Planes click FILE -> Import -> Images as Planes. You’ll be asked for an image file. The default size of the plane made by the function is 2x2bu (bu=Blender Units). To work at a scale that makes sense for your OpenSim model you may want to scale the plan up to 256m. You can also zoom in, whatever works for you.
WARNING: Do not scale the plane yet. There is an optimum time to do that.
I scale my plane up to 256×256 so I can work in meters. In a 2×2 plane 10m on in my region would be 0.039 bu. If I scale up to 256×256 a plane 10m is 10 bu, much easier to work with.
You can scale up the 2×2 plane by a factor of 128 (S 128 Enter) to make it a 256×256 unit plane. You can check the Transform panel to see if it is the correct size (See image). You can even use the panel to set the size, just type in the values. But, don’t scale it yet.
Enter Edit Mode (press TAB key) and subdivide the plane. Subdivide the plane with 254 cuts. That will give you a plane that contains 256×256 vertices, since the initial plan already had 2×2 vertices. You can look in the top menu of Blender to see the vertex count. It should be Ve:65,536, provided this is the only object in the scene.
When you first click SUBDIVIDE the properties for subdividing will appear. It is hard to say where because the windows and panels are in different places depending on how you configure Blender. But, usually the Subdivide properties are in the lower left. Type in a value (254) for the Number of Cuts.
Next we need to move the vertices according to the height map. This is done with a Modifier. Switch back to Object Mode.
In object mode clear your selection (press ‘A’ once or twice) then select your plane. In Properties select the wrench icon, Modifiers (see image). Then select Add to open the modifier list and select Displacement.
Set the Midlevel to zero now, if you are going to. I think doing so makes it easy to align other terrain meshes if you are going to work on more than one region. This needs to be done before you select your texture/height map image.
I leave Strength set at 1.
Next select the height map image using the texture selection icon in the Displace Modifier panel, the checkerboard icon. That will open a list of images within the Blender file. Select the image file for your terrain. It is there because you imported it earlier. You should now see the terrain take shape. If you are in Edit Mode, you will NOT see the terrain, just a flat plane. Switch to Object Mode.
Now scale the plane up to the size you want, if you are going to do so.
Last step is to apply the modifier. Now you are ready to work on the terrain.
WARNING: There are several things you can do that will suddenly flatten your terrain. To avoid that problem follow this specific order.
- Create your 2×2 plane manually or via Images as Planes.
- If you’re not using Images as Planes, open the height map image.
- Switch to Edit Mode and Subdivide the plane. (target size – 2 = number of cuts)
- Switch back to Object Mode.
- Add the Displace Modifier.
- Set the Midlevel to zero, if you are going to do that. Recommended.
- Leave Strength at 1.
- Select the Displacement image.
- Now scale it to the right size.
- Last Apply the modifier. When you switch between Object and Edit modes your terrain should stay the same. If not the modifier has not ‘Applied’.
The tutorials I’ve seen suggest using Strength to get the height correct. I found that awkward. There is an easier way that fits well with this work flow.
You can get the terrain’s height form the simulator console (terrain stats – the first value) or by going into the region and standing on the high point and checking your coordinates. In new SL viewers (V2 and up) you will need to right-click in the top menu and enable the coordinates.
You also need to know the elevation of the low point too. You can assume it is zero or find the low point and stand on it.
In Blender you can set the Z-dimension of an object in the Transform panel. That value is the distance from the low point to the high point, measured along the Z-axis.
Either the import feature in Blender or the export feature in OpenSim is a bit off and does not make a perfect conversion. So, in Blender I find my existing terrain is not the exact same height as in OpenSim. It usually needs some tiny adjustment. But, it is close and you may consider it accurate enough. I already have buildings in my region so I want it as close as possible.
In Object Mode the Transform panel will give you the objects Z-axis size in Dimensions. You can type the correct height in as the Z dimension.
To check the terrain is in the right place elevation-wise, select the lowest pixel in the mesh and check it is at the right elevation (Z value). If not, you need to move the mesh up or down the Z-axis to the right place. (G Z [±distance] Enter). Then check the highest vertex and make sure it is at the right elevation or close enough.
You now have your terrain imported to Blender. It is time to save the file.
I’ve given you a lot of information on getting elevations as numerically correct as possible. Unless you are trying to match to existing buildings and regions this level of accuracy is not needed. Also, no matter what you do, you will be doing some adjustment within OpenSim. More about that later.
Sculpting the Terrain
You can edit the terrain with any of the Blender tools. The only limit is the need to avoid changing the X and Y values of the vertices. Only change the Z values.
You are limited to Z-axis changes because when you convert to terrain back to a height map the image will assume each pixel is at a specific X/Y value and OpenSim/SL will make the same assumption. So, it is not possible to import new X/Y values for a terrain mesh. For things to look right in the exported map you must avoid moving pixels in the X/Y directions.
Terrian to Height Map
There are different ways to export the terrain. None are simple but neither are they overly complex. However, Gaia Clary provides a program named Primstar-2 that has a terrain export add-in that simplifies the process. It is a pay for program, L$6,000 (US$23±). It has already been upgraded for Blender 2.6.
If you want to export your own, it is not all that hard. I managed to figure it out. Blender can do it. I’ll explain how in the next part.
See: Blender 2.5 Exporting Height Maps Tutorial – Part 2 (Will be up at 6AM SLT/PDT 10/10)








2 Comments
Hello Nal, i get a 404 (Page Not Found) Error in part 2
I hate it when that happens… link is fixed. Sorry. Thx for saying something.