Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Heightmap Generator for a City Generator

  1. #1

    Default Heightmap Generator for a City Generator

    Hello, I'm working on a city(actually more like a big network of towns) generator. So, it starts off making a terrain, choosing places to live, connecting 'em all up and then putting in all the streets and buildings and wotnot. So, since the whole basis of the thing is the terrain, I'd appreciate some friendly advice/not at all friendly advice/ brutal criticism of some heightmaps that the terrain generator churned out. They're only 256 pixels square(not because anything larger takes bloody ages or anything like that, cough,cough), but you can probably get the idea. The goal is nice varied terrain preferably with a bunch of suitable locations for town building, but it'd be nice if the terrain conformed somewhat to reality and didn't upset the river police too much...

    height1.png

    height2.png

    height3.png

    height4.png

  2. #2
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,611

    Default

    You might try an exponential transform on the landscape if you're not already doing so. A power of 2ish will flatten out the valleys a fair bit. Applying the exponential to a local base relative to the major river areas might also do well.

  3. #3

    Default

    Thanks! It already applies a power of 3 to the landscape before it does the erosion, but that might be needed because it puts a few layers of perlin noise on top of each other. You're right I think, it could do with some more exponent afterwards...

    I don't really understand what you mean by applying the exponential to a local base means. Do you mean, like, only apply the exponent on heights above the river network?

  4. #4
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,611

    Default

    I think that you've got the basic idea. The general idea is to compute a surface as the difference between the river's level and the surrounding terrain, with an area of effect proportional to the flow. Then apply an exponent (or blur, or averaging operation) to that map and blend it back to the original surface. It looks like you have something similar in the river width calculation, but what I'm suggesting would go a bit farther and should result in a little less chiseled canyon walls.

  5. #5

    Default

    Ah I see, I think... Yeah the river width calculation does work something like that(it goes a bit crazy when the river gets quite long).

    When I look at real terrain, it's like the highest areas have the most relative height differences where they've been eroded ,big chunks taken out of mountain areas, less erosion on a bigger area at low elevations, and I'm finding it hard to balance this with the erosion systems because the lower areas are more likely to be passed through more times by longer rivers...it kind of gets the amount of power from the exponent of the height, then gets less(???) as it goes downhill and grows in size....something like that anyway.

  6. #6
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,611

    Default

    The erosive cutting power of water is very approximately equal to the amount of flow multiplied by a power of the slope angle divided by the hardness of the underlying material. Steep mountains get eroded fairly quickly because the slope is high, even though they are made of fairly hard stuff. On flat lands, the slope is close to 0, meaning that the river won't erode downward. If your equations keep track of the sediment being cut and carried, then terrain will build up where the land flattens out and can't carry much stuff.

  7. #7

    Default

    Gold, my friend, absolute gold! I wish I'd come here first instead of trying to come up with my own crummy system by myself with virtually no knowledge of erosive processes. Right, I'm off to rework the whole thing...and probably read a few geology books or something.

  8. #8

    Default

    So, hopefully these are a bit better, and not worse, than the last lot. It calculates the cutting power using the slope now instead of a bunch of successive botches. It still uses successive botches for other stuff though, most notably the getting rid of the sinks bit. So it fills the sinks, adds some perlin noise to the sinks, and does this about thirty times. If the map has big enough sinks, the cutting power is very low and the maps don't look very nice. Obviously this is nothing like what really happens. I guess the sinks would really be filled in with sediment and allow the river to continue flowing or something like that.

    And, basically all the towns are surrounded by mountains, which isn't very realistic either but hey, I like mountains.

    Anyway, if anyone's still reading this thread (Mr. Wilbur, perhaps...), here's some more heightmaps...

    height1.png

    height2.png

    height3.png

    height4.png

  9. #9
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,611

    Default

    Read the following paper for a good basin-filling algorithm:

    Planchon, O. and Darboux, F., 2001. A fast, simple and versatile algorithm to fill the depressions of digital elevation models.

    There are no doubt newer ones out there, but this one works well and he was willing to provide sample code way back when I asked him. OK, that was about 12 years ago now...

    Another paper that may be interesting is Ken Musgrave's erosion paper from way back in the dawn of time. http://codeflow.org/entries/2011/nov...g-and-erosion/ is also interesting for the WebGL crowd.

    The problem of towns being surrounded by mountains is trivially solved just by scaling the height. From plains to high mountains, it's just a scale factor away. The hydrography will be the same (in a pure geologic sense, there are differences between nearly-flat and steep mountain water flows - meanders, for example - but for game purposes, it will be plenty good).
    Last edited by waldronate; 07-19-2014 at 01:18 AM.

  10. #10

    Default

    I believe that the Planchon and Darboux algorithm is indeed what I am using. Is that what Wilbur uses too? The problem I think is that the fill basins algorithms seem to be better suited for filling minor pits in real elevation models, rather than fixing vast areas of bad hydrology in fractal heighmaps. So I get massive, very nearly flat areas that I have to fill in with some sort of noise and then fill the sinks again to get river systems that dont go in a straight line across the filled sink, or else designate them as giant, tens of kilometre big lakes. Neither of which is very good really.

    I like that craftscape link, the erosion looks really nice. Not sure I really want to GPL my program just yet, though I suppose I could take a little peek at the source...

    Thanks for coming back and giving me the benefit of your years of experience in this area!

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •