views:

1781

answers:

5
+1  A: 

Generating Random Fractal Terrain

Alex Reynolds
+1 - Fractal generation was the first answer that came to my mind.
James Black
But to be honest the output result between fractal generation and perlin noise is hard to distinguish. Besides it doesn't help in creating rivers.
Wodzu
Given that he's already using perlin noise to generate a height map that he's unhappy with, I don't see how that site will help.
Pod
Perlin noise is only one method for making random fractal terrains; there are others. Perhaps employing a different method will give results that meet the asker's criteria.
Alex Reynolds
+1  A: 

Terrain is created by a myriad different causes over many different time-scales. In order to truly create realistic terrain, you'd have to simulate these.

In the "short" term, the hydrosphere determines most of the characteristics. You can probably start with a voxel/particle/heightmap/mesh terrain containing major features (mountain ranges etc.) and treat it as immutable, then post-process it with a plethora of water simulations. You'll need to compute where the rivers and lakes will be, how they erode the base landscape, and where they form deposits. If I had to code this I'd probably start with a 3D voxel world.

This would be a gargantuan task and I'm sure there are lots of tricks available for generating specific terrain types that take milliseconds instead of minutes. What kind of terrain are you looking to create? Mountainous? Lowland? Industrialised? Forest? Desert? Archipelago?

Long story short: if you want terrain that looks realistic to humans (who tend to be, after all, experts on this kind of thing), you'll have to create it by simulating actual geological processes.

David Rutten
@David: thanks for your reply. However I don't find it helpful. You asking me what terrain type I want to create. I think I've explained it enough in my question and the sreenshots which I've attached are pretty descriptive. You tell me what I need to do (which I've already knew when I was asking for help) instead of giving any clues how to do it. Also I have to disagree with you that only teleological approach can give realistic results. Such result may be also obtained by observing nature and reproducing the output effect.
Wodzu
I will happy to give you thumb up if you provide me some of the tricks you've mentioned in your answer. So far I give thumb down.
Wodzu
@Wodzu, yeah, downvoting is a great incentive for me to elaborate and invest more time. I'm not a point-whore and I don't respond well to black-mail. Next time, if you feel me efforts are pointless, just ignore me instead.
David Rutten
@David "dude" you are acting like child right now. First of all - I did not downvoted Loren Pechtel and you will not be telling me who can I downvote and who can I not. The second thing is that you are again telling me what to do: this time in your case - I will downvote you if I decide that your answer doesn't bring anything helpful or constructive. Thats my vote. If community thinks different they have their votes to spend. Also my answer wasn't a black-mail. I've actually were really curious what tricks you could find.
Wodzu
+2  A: 

I've played with terrain generation before. Assuming the objective is a bitmap I found a way to make things like rivers and in general make it look better: Erosion.

Once you have terrain generated by other means erode it a bit: You need the world expressed as heights of pixels. Take a spot on the map and move one unit of height to the lowest neighbor. Move the cursor to this neighbor and repeat until it doesn't move. Repeat for other pixels.

To make rivers count the number of times you pass through a location moving bits down. Spots that get hit the most are rivers.

Followup: I wasn't eroding each pixel so much as simply a large number of random pixels until it weathered enough. The reason for actually eroding them is that this carries bits down and fills in holes. Without that there can be no rivers as there will be dead that trap the flow--the flowing pixels fill in any small holes and make working waterways.

Sorry I can't give any samples, this was many years ago and while the old code is probably around somewhere I don't know where to look.

Loren Pechtel
Thanks Loren. I am not sure I understand you correctly. Do I have to erode each pixel on the map? This is somewhat comparable to just for an example starting on the top of the local hill and than going down in a given direction. By "going down" I mean searching neighbour pixel with less or equall altitude. And continue until the condition is not violated. This is what I am doing now (but I do not lower the altitude) and you may see the results. It would be great if I could see some screenshots from your generator.
Wodzu
@Wodzu, I think Loren's suggestion is the right direction for you. And no you don't have to erode each pixel; but you should move some (displace them, the sediment is also important for shape). See http://markjstock.org/pages/builder.html image for 'erode'.
Unreason
A: 

My method in Terra3D was to generate random height values, and then make 3 smoothing passes with a little reshaping written into the algorithm. The reshaping causes the terrain under the water line to shift downwards a bit and everything above the water line shift up a bit. The effect though is a lot of hills and small lakes. And that may not be what you're looking for exactly.

However, I'm not convinced that the principal behind my method couldn't be used to get what you want. You may just have to write some more conditions into the reshaping/smoothing algorithm. For example, reducing the amount of smoothing on the terrain at higher elevations will create more of a rocky mountain appearance. And then writing a more involved smoothing (or gaussian) algorithm that stretches out further for the lower elevations could pull those lakes together to form natural rivers.

Here's the code for the terrain generation in Terra3D in case you're interested:

  // GENERATE TERRAIN
  for (i = 0; i < MAX; i++)
  {     
    for (i2 = 0; i2 < MAX; i2++)
    {
        if (i<10 || i2<10 || i>MAX-10 || i2>MAX-10)
        field[i][i2].y=0;
      else
        field[i][i2].y=(GLfloat(rand()%151)-75)/50+(field[i-1][i2-1].y+field[i-1][i2].y+field[i-1][i2+1].y+field[i-1][i2-2].y+field[i-1][i2+2].y)/5.05;
    }
  }

  // SMOOTH/RESHAPE TERRAIN
  for (int cnt = 0; cnt < 3; cnt++)
  {  
    for (int t = 1; t < MAX-1; t++)
    {
      for (int t2 = 1; t2 < MAX-1; t2++)
      {
        field[t][t2].y = (field[t+1][t2].y+field[t][t2-1].y+field[t-1][t2].y+field[t][t2+1].y)/4;

        if (cnt == 0)
        {
          if (field[t][t2].y < -1 && field[t][t2].y > -1-.5) field[t][t2].y -= .45, field[t][t2].y *= 2;
          else if (field[t][t2].y > -1 && field[t][t2].y < -1+.5) field[t][t2].y += .5, field[t][t2].y /= 5;
        } 
      }
    }
  }

It's sloppy code that I wrote about 10 years ago. Terra3D was a long learning process of experimentation and fumbling in the dark to produce the type of effects I was looking for. But maybe it'll help.

Steve Wortham
Oh my god that menu on your website was annoying!
Lasse V. Karlsen
Ah yes, I created that menu when I was 18 years old. Haha, just turn your volume down a bit. ;)
Steve Wortham
Thanks Steve for your interest and for the code. I am still working on my generator! Your code is good for a 3D flight simulator becasue in such type of games user is satisfied by having some lakes and mountains. He actualy don't care to much about the terrain structure and its logic. However, I am trying to accomplish something different. If you open an geographic album and you look at the terrain, you see that it is random but also comforms some rules. f.e. a river falls from mountains to some lake or sea, or mountains are arranged in some clusters.
Wodzu
Also the lakes and mountains seen from the top (with 2D view) will look artificial compared to the lakes and mountains from the geographic atlas. This will not be noticable in 3D flight simulator but it will be in some strategic turn-based games. Once again thanks for your answer.
Wodzu
@Wodzu - Sure thing. It sounds like you're much further along at this point (I just noticed this question is several months old). Indeed there are many details that I didn't delve into which you're obviously tackling head on. Good luck to you.
Steve Wortham
Thanks Steve and thank you for your time and involvement :-)
Wodzu
+1  A: 

Spherical displacement is pretty easy, I wrote it in python in a few hours: http://code.activestate.com/recipes/576929-planet-terrain-heightmap-generator/

Shea Kauffman
Thanks, this is not what I am looking for but it gives a really nice effect though.
Wodzu