-5

I need to generate terrain. Easy enough you might say, but I need to create Biomes if you will(Can't think of another name) and lakes, Trees and all on a height map.

So I have really no idea how to use a height map or even perlin noise. If you could help me out. I need 3D and 2D help. If you could explain the math behind it, really help me understand this for good.

Jordan Schnur
  • 1,225
  • 3
  • 15
  • 30

1 Answers1

2

That is such a broad question that it is almost impossible to answer. There are lots of different ways to go about terrain generation and lots of ways to implement them as well. Depending on the graphics hardware you are targeting and your needs you could do it with programmable shaders or with the old fixed function pipeline. It can be implemented in DirectX or with OpenGL. I'm assuming this is roughly what you are looking for...

http://youtu.be/lBGPupldGz0

This is done with a so-called heightmap. I took a black and white image with darker spots representing low elevations and lighter spots representing high. Then I converted the image into a single color channel (red in my case, thought it is irrelevant which you choose). I started with making a grid of triangles. I walked through the image and used the pixels difference in the 0-255 range to change the 'y' vertex position.

The biggest problem encountered was getting the normals correct so that the lighting worked. Another problem with using a heightmap is that they do not scale well with large terrains...image size gets out of hand fast.

As for perlin noise...that is a procedural technique you could bake into the map itself using a tool like L3DT (or even paint.net) or you could do it in a shader, real-time. Too broad a question.

I suggest you check gamedev.net forums...there are bound to be plenty of open ended questions about terrain there. Stackoverflow is a terrible place for vague questions. Check this tutorial series...it is written in XNA, but the ideas apply to any language...

http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/Terrain_from_file.php

Timothy John Laird
  • 1,101
  • 2
  • 13
  • 24