Blender 3D: Noob to Pro/Making Landscapes with heightmaps
|Applicable Blender version: 2.41.|
This tutorial will show you how to make advanced terrain such as mountains using Blender and gimp or any other image editing software. Blender has the ability to use height maps to create meshes. Height maps are black and white images with white representing the highest point and black the lowest.
Creating the heightmap image
Note: This entire Tutorial presumes that you are already familiar with other Editing Software, such as GIMP... and already know how to create "textures" with that software. However, you do not have to use another program to obtain a texture. At the end of the next section, they show you how to generate a random 'cloud' texture which you can use directly. Do not worry about GIMP or Photoshop. Just skip the rest of this section and most of the next one.
To begin with, open your image editing software. This part applies to Gimp only (downloadable at http://gimp.org), if you use another program you will have to do it another way.
First use the "New" menu option to create an image 1600 wide by 1200 tall. Go to Filters → Render → Clouds → Plasma (In Photoshop, this is Filter > Render > Clouds). For this example just use the default settings, it doesn't really matter. Click OK. You should now have a nice colorful image. We don't want that, we want it in black and white. Make sure your Gradient is set to "FG to BG(RGB)"(this is the default anyway) and that your foreground color is black and the background color is white. Go to Colors → Map → Gradient Map. This will convert it to black and white for you.
Save your image as PNG or JPEG.
It should look something like this
Create grid and add the image as texture
Open Blender and delete the default cube.
Add a grid (SPACE → Add → Mesh → Grid) with resolutions 32 and 32 from top view. Do not scale the grid just yet, zoom instead if you wish to take a closer look at your grid. It will be explained later why you shouldn't scale now.
|Note: When I followed this tutorial it didn't work - the vertices in the grid were moving sideways rather than vertically. It turns out I needed to TAB into object mode after creating the grid, then hit CTRL+AKEY to reset the transformation, then TAB back into edit mode. If someone could explain why that was necessary, or what it does exactly, that would be helpful.|
- Response 1: You should create the basic shape and outline in object mode, then edit the details in edit mode, kinda like the names imply.
- Response 2: When you create an object using the Front or Side views while having Aligned to View selected in the Edit Methods in Blender Settings Panel, the Local Z axis of the object will be pointing to the Global Y or X axis, respectively. For the matter of this tutorial, if you do that, you'll be forced to rotate the object 90º in X or Y, before going on. That's where problems may begin, if you rotate it in Edit Mode which doesn't change local axis orientations. In that case you'll be forced to reset transformations (Ctrl+A -> Scale and Rotation to ObData). However, if you rotate it in Object Mode, and if you make sure the Local Z axis points upwards after the rotation, you should be seeing good results later on. ( To see the Local orientations of an object, Press F7 for the Object Panel (the one with three arrows, 4th from the left) and in the Draw pane click the Axis button.)
Click F5 to go to the Shading panel. By default the Material buttons button should be selected (button with red ball), but if it isn't then click on it. If this window has a panel named Preview and it is empty then look to the right for the Links and Pipeline panel. Here you should find an Add New button beneath Link to Object, click on it. 3 more panels should appear when you do this. You should find the Texture buttons button, it is just to the right of the Material button and is black & yellow. You may also just hit F6. Now you should get two new panels titled Preview and Texture, in the Texture panel you'll find an Add new button, click it. Where the button just was it should now be a text field saying something like "TE:Tex.001", click in the text field and write "height" instead. Look a bit to the right and down for a dropdown menu allowing you to choose Texture Type, click it and select Image. Two more panels will appear and the rightmost should be Image with a Load button.
|Note: The Texture buttons button is not part of the windows that pop up after you click Add New button, but it directly to the right of the Material button that is a red ball.|
|Note: If you can't find the Texture Type menu, press F6. Once you press F6, or the Texture buttons button, you'll see another panel, also called Texture. This one, however, shows a Texture Type menu after you select Add new. Having two very similar panels can be a nasty trap.|
Before you load the image take a look at the Map Image panel. About in the middle there should be 5 buttons, Extend, Clip, ClipCube, Repeat and Checker. Select Clip or your heightmap may wrap around the grid (if this doesn't make sense then do this tutorial twice, one where you keep Repeat selected and one without. In that case make sure there's some bright white spots in your height map on each edge).
Click the Load button and load the heightmap you just created in your favourite image editing software.
If you're going for the random cloud-type image, though, you can make it from within Blender itself - when you add a texture, in the menu where you select 'image,' before actually selecting it, pick 'clouds' instead, and play with the settings.
Click the Material buttons button again (the red ball button) and look in the Preview panel. If this just shows a black ball then click on the uppermost button just to the right of the black ball.
Use texture as heightmap
(Blender 2.5+ note: Now you do this using a "Displace" modifier that applies the Texture you created.)
Look to the top right of the rightmost panel, the window should have 3 panes titled Texture, Map Input and Map To. Click on the Map To pane. A whole lot of buttons will appear:
- Turn off the Col button. "Col" stands for "color," and we don't want our plane to be colored by this texture.
- All of these buttons should be turned off: we're not going to be using this texture to "Map To" anything. Instead, we'll be using it to deform the actual geometry.
Go to the Edit window (F9) and enter edit mode (TAB) if you're in Object Mode. Go to either front or side view so you can see what you are doing. Click the Noise button in the Mesh Tools-panel (it's located in the top left corner of this panel) and your grid should start to change shape.
Note: make sure all your vertices are selected with AKEY or whatever you want to use to select. If not selected, Noise won't do anything!
- (While you could, theoretically, use this to your advantage ... intentionally de-selecting vertices that you don't want to influence ... in practice that's quite awkward if for some reason you have to do it again. It's much easier to leave any such areas, that you don't want to influence, "completely white" in the image.)
Continue clicking the button until the terrain has reached the height you want and voilà, you have just made terrain using heightmaps. You may want to subsurf the shape to get a smoother effect. If you wish to scale your new landscape then now is the time. There seems to be a bug or gotcha causing your heightmap to be tiled on your grid rather than resized if you scale the grid before applying the heightmap. Hopefully someone familiar with blender will clarify how this should be done properly, but until then this method will work.
1.If you want a more jagged landscape then adjust the contrast on the image editing software
2.Once you've finished using the Noise button in the Mesh Tools panel as shown above, the texture is no longer needed: the effect it has made on the geometry of the object is permanent. If texture-resources are tight, you can remove it now. But it's advisable to keep it, unchanged, in case you need to re-do your work at some time in the future. If you want to use other kinds of texture-maps (Color, Normal maps, and so-forth), you can use the landscape-image as a handy reference (say in a background-layer in your painting program) for correct placement of these features, but you should not alter the landscape-image itself).
3.Height maps can also be used to make city terrain. Draw white squares on a black background. If you do this make sure you make the squares perfectly parallel to the sides of the image. This prevents jagged edges to buildings. You can also use gray squares to adjust the buildings to different heights.
4.The "Noise" mesh-editing button displaces vertices in the object's Z-Axis and negative Z-Axis only. To deform your mesh's other dimensions, simply rotate your object and "apply rotation," or rotate the vertices in edit mode, and apply Noise. Then, rotate it back again to get your original orientation.
5.The "Noise" button permanently modifies your mesh according to the material texture. Each click adds onto the current mesh. For a temporary effect, map the texture to Disp(lacement) for a render-time effect (and do not click the "Noise" button at all). In object/edit mode your object will appear normal, but will render deformed.
6.Note: The "Noise" mesh-editing button, as used here, is not the same as the "Noise" texture that is referred to in other tutorials!