12
\$\begingroup\$

What's the best way to implement a detail feature, like a road, on a heightmap-based terrain?

enter image description here

Update: It's a bit hard to see in the image, but the road descends from the top of the quarry to do its base.

\$\endgroup\$

2 Answers 2

14
\$\begingroup\$

What is great with images is that they usually embed up to 4 channels (red, green, blue and alpha). As an height map needs only one dimension, you could just use the red channel to store the height informations (you still have 256 levels for the height), and then use other channels for other purposes (like using the green channel to map the roads, blue channel for water / moisture) etc...

Like this you could make sure that when you're building your terrain, the zones where a road should be built will appear flat instead of following the height gradient.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Is it possible to use HDRI image , so float numbers can be used to store more precise height information? \$\endgroup\$ Jul 13, 2011 at 9:32
  • 1
    \$\begingroup\$ HDRI image is not a file format but a concept, but yes you could use specific file formats to allow more accuracy. It would mostly depend on your hardware/software, but there is a float RG image you can store either on 32 or 64 bits. But Whatever the format, if you use more bits per channel, you could always convert int values to floating point number like this : f = (v / 256.0) where f is your float, v the current int value \$\endgroup\$
    – XGouchet
    Jul 13, 2011 at 9:39
  • \$\begingroup\$ Is it a good idea to store all the static objects of a map on a (height) map? like vegetation, foliage, house? or pointers where other object will be placed on? or some other way exists? \$\endgroup\$ Jul 13, 2011 at 9:47
  • \$\begingroup\$ I wouldn't store the exact location, but maybe just a density information, and then generate the data (vegetation, house etc...) from the density information. But the best way is to place these objects by hand and save them using a binary data file or an xml description file \$\endgroup\$
    – XGouchet
    Jul 13, 2011 at 9:51
  • 1
    \$\begingroup\$ @iamcreasy of course you can use the heightmap to have your house touching the floor, but you need to describe what the house model looks like (walls, doors, any furniture inside), which can't be described in a pixel. Also jsut pixel information won't give you an accurate orientation, so your houses will all be aligned (which won't seem natural or "pretty"). \$\endgroup\$
    – XGouchet
    Jul 13, 2011 at 10:17
1
\$\begingroup\$

The way I do it is to separate the heightmap (I use floats for example, 513*513) and splatmap (the "control-texture") that often needs a bigger resolution (I use 32bit bmps, 512x512).

The heightmap creates the mesh (the terrain, the triangles).

The control-map spans the whole terrain and each of its layers (RGBA) says how much say Stone,Dirt,Road etc. you should see On the terrain.

This way you can use an editor to a) create the terrain and b) Paint the terrain (with Rock,Dirt,Road etc.)

Do a quick goolge on 'painting heightmap', 'heightmap splatmap' and such for a more thorough explanation or download say Unity3D to check out how it might work in 'reality'.

\$\endgroup\$

You must log in to answer this question.

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