Updates: Includes minor updates for use with Blender 2.63.
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 into Blender 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 need to export for use in OpenSim. Plus I have a terrain in OpenSim (OSGrid) which I’ve worked on for some time that I want to get into Blender and start from there. So, 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 my 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 into 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 in OpenSim.
When importing terrain Blender can handle more or less pixels than the precise number needed for the terrain’s number of vertices. Mismatching pixel and vertex count can cause oddities in the terrain’s appearance within Blender. Oddly, larger images create more problems than too small an image. Overly large images will produce stair steps in the terrain. But, mismatches won’t break the process, so you can make mistakes without a disaster. 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. So again, the process is forgiving.
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 terrain export from OpenSim. So expect to spend some time tweaking the terrain settings once you have it in Blender.
It is also possible to get RL terrain from government agencies and import it to Blender, which can then be exported for use in OpenSim/SL. Google for how to convert RL terrain data for use in Blender.
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 OpenSim exported height map and the Blender heights the same. Expect to have to live with some vertical scaling 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 export it for use in 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. (Blender 2.63 still requires the feature to be enabled.) 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 Blender 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 for you.
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. Because 10m in my OSGrid region would be 0.039bu in Blender when using a 2x2bu plane. If I scale that up to 256x256bu plane then 10m in the region is 10bu in Blender, which is much easier to work with.
You can scale up the 2x2bu 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, again 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.
Update: If your image is not showing up in the Displace texture selector, you will need to add it into Blender as a texture. That is the only way I could get it to work Blender 2.63a.
Now scale the plane up to the size you want. If you want the height to match what you had in OpenSim/SL, this where you will need to do your tweaking.
The last step is to apply the modifier. Now you are ready to work on the terrain. It is possible to enable vertex editing in the Displacement tool, I just prefer not to.
WARNING: There are several things you can do that will suddenly flatten your terrain. To avoid that problem follow this specific order.
- Create your 2x2bu plane (default size) 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) – In 2.63a the subdivide process is much slower than in 2.59. Be patient.
- See Steps 1 to 13 below and make you UV map.
- 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. Use the Transform panel (N-key 3D View)
- Last step is to apply the modifier. When you switch between Object and Edit modes your terrain should stay the same. If not the modifier has not ‘Applied’.
- You now have the terrain imported and in a workable state.
- Select Texture in the properties panel.
- Create a texture using your terrain map image.
- Name it something useful.
- Open a UV/Image Editor window
- Add a 256×256 pixel UV Test Image.
- In the 3D View window switch to Edit Mode (tab key).
- Press ‘A’ to select everything.
- Press 7 to switch to top view.
- Press U to unwrap and use Project from View.
- In the UV menu select Constrain to Image Bounds.
- Press ‘A’ to select all the UV map.
- Press ‘S’ to scale the UV map to fill the image.
- Switch back to Object Mode (tab key).
- Now it will show up in the Displace Modifier.
- Continue frmo step 8 above.
The tutorials I’ve seen suggest using Strength to get the height correct. I found that awkward. Using the Transform panel is an easier way that fits well with this work flow.
You can get the imported terrain’s height from the OpenSim 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 coordinates.
You also need to know the elevation of the low point. 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. So, you don’t get a perfect conversion. So, in Blender I find my existing terrain is not the exact same height as in OpenSim. It usually needs some adjustment. But, it is close and you may consider it accurate enough. I already have buildings in my region, so I want it as precise 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 and scaled and positioned correctly. 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 likely 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 vertices 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 for-pay program, L$6,000 (US$23±). It has already been upgraded for Blender 2.6.
If you want to export on 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)
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.
I’m using the blender 2.63. I have the planes saved as default, and also import .raw files. I have an SL .raw file saved on my computer. I imported from my desktop, nothing appears on the screen but the xyz arrows and a tiny dot.
I’m sure that there is something missing in the process in order to get this file functional. Any thoughts would be appreciated.
I am trying to use the existing sim .raw file to smooth out some of those nasty jagged spots that is frequent with extreme height changes and just Second life, it seems. Makes it rather difficult to run around.
Can you see the plane you created?
I have Blender 2.80 and there is active File > Import > Images as Planes.
I did my own region on Terminal.app “terrain save name.tif” then Blender 2.80 Images as Planes cause planes only 4 vertex and flat.
I am KentDavis Edman is the same in SL and OSGrid.