I'm looking to build (for start) a simple tool, that could raise, lower, smooth and texture the terrain.

So, what are the things I have to go through in order to make such terrain editor?

And maybe there are valuable resources available on subject?

Yes, forgot to mentioned, that I'm interested in a 3D terrain editor.


4 Answers 4


For a 'classic' 3D terrain editor, the steps could be those:

Generate a mesh (e.g a grid of squares, every square made of two triangles), all vertices are shared between triangles (so that there is only one normal per intersection). enter image description here

This should be made a 3DMesh and rendered in your program.

Make a tool to raise and lower (smaller and bigger) parts of the grid (you need to calculate where on the mesh the mouse cursor is and modify the meshes vertices, but only up and down).

Create a big texture (like 1024x1024x4 or better) and texture it with what is called a splat-map: enter image description here

Make it possible to paint it (with R,G,B OR Alpha, not pink for example) and to choose textures replacing those ugly primary colours (Red,Blue, Green, Alpha), or moreover, be represented by them:

The shader (that you will need to create) should multiply those nice textures (say stone, grass, ...) with the intensity in the splatmap (the ugly one) and then mix together the whole so it looks, for example (with like only 2 colours), like this: enter image description here

Sorry for the big images, I whipped together this at work...

  • \$\begingroup\$ Ah, this made it a bit clearer. Theoretically, after the 3D mesh it's simply vertice respositioning (up/down) and the texturing at this example you've done the "splatmap" way, after which the shader resemble it into a "3D" terrain? \$\endgroup\$ Commented Nov 18, 2011 at 16:01
  • 1
    \$\begingroup\$ Correct for the 3D mesh. The shader doesn't do anything special with the mesh (the vertex shader), the big job is in the fragment-shader (the "pixel shader") where the texel lookup from the splatmap gives how much grass, stone etc the final pixel shall get (you can of course also have a 'base' texture, like stone for example which is always at 100% and other textures get splatted on to it). \$\endgroup\$
    – Valmond
    Commented Nov 18, 2011 at 16:05

The first thing is to be clear on the data structure of your terrain, and what you want from an editor. Is it a mesh? An array of heights? Some sort of Minecraft-style voxel system? Do you need to be able to add mesh terrain features like trees and buildings? Manually, automatically or both? I could go on, but you get the idea.

A basic terrain editor isn't that difficult to write, but the details will vary a lot depending on the game you're making, and thus the type of terrain you want to make.

  • \$\begingroup\$ Well, a mesh/array og heights/voxels etc. is just a way to store the assocated data, I was more interested, on how to write the tools to populate this data. Actually, I have totaly no idea, how a terrain editor looks "behind the scenes". I can reverese engineer it, but only in my own way, I bet there are some guidelines I should follow though... \$\endgroup\$ Commented Nov 18, 2011 at 15:34
  • 2
    \$\begingroup\$ -1. This doesn't look like much of an answer to me. You're asking some questions, which would have been better suited as a comment. \$\endgroup\$
    – bummzack
    Commented Nov 18, 2011 at 16:10

This is just mostly a follow-up to Valmond's response, but it doesn't seem short enough to add as a comment.

Once you get around to making a basic editor, you might want to experiment by generating the heightmap entirely on the GPU. This is completely optional but it's a good way of offloading work to the GPU for a constantly changing terrain. Valmond already mentioned the texture splatting being done on the pixel shader, but the vertex shader can be used as well, using a texture lookup to raise and lower the vertices in the grid. Here's a tutorial on how to accomplish this with the vertex shader. The non-shader stuff is C# and XNA specific, but the important stuff is in the shader code.

In this case, your code on the CPU side will just deal with modifying the grayscale texture stored in memory. Your mesh grid stays flat, vertices don't get updated by the CPU. Each time the texture is changed, the new texture can be passed to the GPU.

Keep in mind that not all shader models support texture sampling on the vertex shader (for instance in HLSL you need at least shader model 3.0).


You can have a look at Ogre's ETM http://www.ogre3d.org/addonforums/viewforum.php?f=16 , should give you some ideas. Artifex Terra is based on it if you want to see it in action.

  • 2
    \$\begingroup\$ I suggest you merge your answers and delete unused ones. \$\endgroup\$ Commented Jan 20, 2012 at 14:32
  • \$\begingroup\$ For GPU created / manipulated terrain check out Gilliam de Carpentier's Scape articles, very informative read on the subject. decarpentier.nl/scape-render \$\endgroup\$
    – Johann
    Commented Jan 20, 2012 at 14:51
  • \$\begingroup\$ As Tom already suggested it, the Scape articles might've served already as an interesting reference on generating and rendering terrain. But since that suggestion, I've posted yet another Scape article that is even more relevant to this topic, fully covering its brush-based editing pipeline. So I though I'd let you know. www.decarpentier.nl/scape-brush-pipeline \$\endgroup\$
    – user16373
    Commented May 18, 2012 at 12:44

Not the answer you're looking for? Browse other questions tagged .