Content is copyright © KatsBits™ 2000-2013. All Rights Reserved.
No part of this web site may be reproduced (except for personal use) without prior written permission from KatsBits.com. For more infomation on copyright click here.
Although making a terrain is generally regarded as being the most problematic asset to produce for game related projects, it need not be. Using the "Displace" modifier in Blender provides a quick way to create terrain meshes so long as a few ground rules are followed. The following video tutorial runs through the basic process, making a simple terrain in Blender 2.49.
The defining characteristics of a terrain are determined through the use of a special image. Called a "Heightmap", this image uses 'black', 'white' and 'grey' to represent the lowest and highest peeks possible in a mesh, with 'grey' being a variable in between the two. In practice this might mean being able to create a terrain that has a 'floor' and 'peek' (cliff top) with a graduated ramp between the two. Generally speaking heightmap dimensions should conform to the Power of Two rule irrespective as to the size and/or dimensions of either the mesh to be deformed or the amount of area that's actually needed. Ideally heightmaps should also be saved using an uncompressed or 'loss less' format to avoid potential issues that may occur due to compression artifacts.
Design Note: jpg images tends to display compression artifacts that manifest as lines and blocks (depending on the level and type of compression) that can be incorrectly interpreted by Blender as being legitimate tonal values for deforming a terrain. This needs to be avoided where-ever possible.
The physical size of a heightmap is not as important as tonal variances contained within, so although an image can be of reasonable size relative to normal texture creation, terrains typically being much, much larger objects mean an image matching the size of a mesh will more-than-likely be impractical. There is no real need therefore to make heightmaps larger than 512x512 pixels in 'height x width'.
The heightmap used to deform the terrain is a simple image with 'black', 'white' and 'grey' representing various levels of mesh deformation - 'white' the highest, 'black' the lowest and 'grey' variations in between
The basic principle behind making a terrain using a heightmap is to use said texture as a means to deform a suitable prepared mesh. This is done using the "Displace" modifier.
First add a "Plane" to the scene (remove the cube if desired, "Del") using "Shift+A" to open the "Add" menu, selecting "Mesh » Plane" from the available options. In 'Edit' mode ("Tab"), "Select All", "A" and "Subdivide" the mesh a number of times ('six' is shown in the video'). Exit 'Edit' mode ("Tab"). Click the "Shading" ("F5") button to add a new, or use a pre-existing material. Click the "Texture" button ("F6") and add a new, or use a pre-existing slot, note the name used for this ("Tex" is shown in the tutorial). Change "Texture Type:" to "Image" and click the "Load" button to open the file browser; find the asset to be used (the heightmap for in this tutorial for example), select it and click "Select Image". On doing this Blender will return to the Texture slot with the new image in place (should be displayed in the 'Preview' pane).
With the material set-up, assign it to the mesh by selecting the Object and then the material via "Material" properties - in the "Link to Object" panel, click the "Browses existing choices or adds NEW" drop-down menu and select the slot previously created.
The next step is to deform the mesh using the texture. In 'Object' mode, select the subdivided plane and then click "Editing" buttons ("F9"). Find the "Modifiers" panel and click the "Add Modifier" button. From the list select "Displace". A new set of properties will appear. Here, in the "Texture:" property, add the name given to the Texture slot previously created, in this instance that's "Tex". On pressing "Enter" the mesh will deform based on the 'black', 'white' and 'grey' values present in the heightmap image. To reduce or increase the deformation value, change "Strength:" as appropriate - higher for more displacement, lower for less. Once happy with the degree of displacement, click "Apply" to 'make real' the changes to the mesh.
Once the desired detail has been produced, the mesh then needs to be optimised using the "Decimate" modifier and then finally UVW mapped and textured in a way that's appropriate for the destination technology - this can mean simply mapping a single image to the entire mesh or unwrapping using a more complex approach that's determined by the game engine or technology the terrain mesh is for.
very easy to follow and concise video tutorial kat, and impressive results from the heightmap. i'd previously not used the angle based edge split on terrain, so again cool to see that being put to good use.
Posted by ratty redemption on April 05, 2012, 04:37:11 am
Technically game engines split verts to create/represent smoothing anyway so the way it's done, 'groups' a-la 3DS Max, or 'edge splits' a-la Blender (and just about everyone else) makes no odds to the GPU - verts have to be split for smoothing (unless there's some proprietary tech involved). But yes, you're going to want to always check that (a) the format being exported to support split verts in some form for smoothing, and (b) the game engine can properly read the exported meshes (the meshes are properly formatted).
Posted by kat on April 05, 2012, 05:02:38 am
interesting, thanks kat.
Posted by ratty redemption on April 06, 2012, 12:04:12 am