Jump to content
  • Advertisement
  • entries
  • comments
  • views

Skipping Ahead

Sign in to follow this  


Hi again! For this entry I'm going to talk about the Midpoint Displacement stage and post more pictures, everybody loves pictures! (Yes, I'm a sellout, shush!) Skipping whatever is left of the ridge generation phase and the river generation phase since I'm having difficulties with the last stage right now and the river phase is incomplete.

[font='comic sans ms']

In the beggining...


I remind you the paper where all of this comes from: Ridges and Rivers, Bottom Up Approach There is another version somewhere that was meant for other presentation I think, same authors, same date, just described differently.

Stages of the terrain generation algorithm:

  • Ridge particle generation. Traces ridge lines on the map, blurs the height values.
  • River particle generation. Creates velocity field and traces river lines on the map. Discard everything except river lines and the original ridge lines after that.
  • Inverse midpoint displacement pass. Fill up the ridges and rivers network with some relevant data.
  • Midpoint displacement pass. Fill up the rest of the missing data.

    Last two are pretty much a single stage.

    We covered up ridge generation stage in the previous entries. River generation stage is more or less an erosion algorithm applied to few particles. You spawn a particle at the top of a random ridge, and simulate its trajectory around the terrain, "carving" a river on the landscape.

    [font='comic sans ms']Craving for rivers[/font]

    All of this is made with a single purpose, feeding specific data to a midpoint displacement algorithm. That specific data represents the features of a believable terrain, ie, ridges and rivers that follow a logical path (at least for the rivers).

    Once that stage is done you'd end up with something like this:
    Image is lightened up a little because it was too dark for viewing.

    Rivers are light blue and ridges are the yellow lines. The blurred gray heights are there just for reference, they're actually dropped once the river generation stage is complete (ie, you're only left with the ridge lines and the river lines).

    There are a few problems with the river generation, such as, they live in a magical land without friction, thus they carve their way around like balls in a pinball, and they have no notion of water mass, so their size is constant.

    This particular stage could go on forever as it is (perpetual motioners dream)... But I placed a timer on it, it stops after a second or so. Hack, totally, I know. I'll get it fixed eventually. It deserves its own entry though.

    [font='comic sans ms']Midpoint Displacement's Inverse[/font]

    Now here is where it gets more interesting. Remember that I said that the point of the algorithm is to feed a midpoint displacement pass some useful data? Well, its not that simple.

    The midpoint displacement algorithm is nice in the sense that for a given square, its internal values depend on the external values (this link might have more information about it). The center and the sides of the square depend on the heights of the corners. For any subsquare inside, it follows the same rule.

    It is an algorithm that can be feed some data, say, reference points like, oh surprise, ridges and rivers. In theory the algorithm could follow the points already precomputed as reference to compute the points that are missing. Thus obtaining a terrain that makes sense in the context of the rivers and ridges already present in it.

    In reality, it isn't that simple. If you grab the heightmap as it is. The information available would be just too low to get a decent "contextualized noise" out of it. That's why the paper presents another stage to fill up the heightmap with some "guide points" for the midpoint displacement algorithm.

    The authors use something they call... (dramatic drum roll in the background) Midpoint Displacement's Inverse. (MDI from now on) And the point of all of this is that I can't understand what it is.

    [font='comic sans ms']MDI and my problems with it[/font]

    It sort of describes it as a way of guess the corner values of every square and subsquare of the heightmap by interpolating its "child values", which I guess it means the midpoints that you obtain from a regular midpoint displacement pass.

    So far I can't understand their (lack of) explanation about the process.

    See, say that I have the 5 midpoints of a square, and I want to figure out the corner values. You can get a rough estimate (as in "almost wrong estimate" ) of what the corner values were by interpolating the values that it contributed to.

    Example from the Wikipedia.

    As you can see there, the top left corner contributes to the values of the left midpoint, upper midpoint and the middle midpoint. If you do (1+2+3.5)/3 you get 2.16'. Which isnt 0 at all but I guess is better that having no point at all.

    These (very) rough estimates should help the regular midpoint displacement pass so the values it produces follows the general landscape that the ridges and rivers defined. That's all I could get from the paper.

    Doing the MDI pass as I imagined doesn't yields good results:
    There you have the bright higher ridge lines and the wider darker river lines going down from the top of the ridges.

    As you might or might not see, the map isn't filled with corner points like the example of the paper shows. I'm producing barely any new point, but I can't see how could I be more lax with the algorithm so I can interpolate more points.

    The interpolation as I see it needs at least one thing. The point I'm trying to find contributes to three other points, and I need those 3 points to exist to get an average out of them and get the corner value's estimate.

    This happens very little on the map given the information it has. There just isn't that many points to get corners from. Moreover, the image you saw its not even checking for the middle value of the square, it tries to find the midpoints of the sides of the square and averages them, and it stills doesn't happens a lot.

    So I end up without enough data to feed the regular Midpoint Displacement pass. Here is an example:
    The result shows almost the same discontinuities the paper talks about before trying with the MDI pass. That means that my MDI pass isn't working as it should.

    Though I understand now why the paper insist on storing everything on a few lists for processing later. If you want to do all of this on some for loops, you're going to need a lot of if checks, since you have to check if there is a need of calculating the height value, and if it isn't, to use the height value that already exists for the later computations. Which usually means to check for all of the 9 values of every sub-square (corners and midpoints) to see if you have to calculate them or not. It was a bit of an index madness for me there biggrin.png

    Here is a colored version just for giggles:


    That's it until I figure out the MDI proccess. If someone want's to help, it would be appreciated. Bye!
Sign in to follow this  


Recommended Comments

What I am saying here is only loosely related to what you are doing as it deals with terrain but I though it might interest you:




In that video, you can see the terrains I made from a simple MSPaint bitmap in a few minutes in Blender. Watch for this one at about 1:38 :


and this one at about 2:40 :


Share this comment

Link to comment

This still just seems to me like an extremely convoluted method to achieve some rather 'meh' results.


First, you have the rigid structure of "ridges here, rivers there" that precludes any sort of interesting terrain variation that isn't composed of neat ridges in relative isolation. Secondly, you seem to waste a lot of work, building a map full of ridges only to discard it and rebuild something different later. Thirdly, the midpoint displacement algorithm just seems to be a needlessly complex means of generating randomized detail. The only real redeeming characteristic I see of the algorithm is the ability to flesh-out a ridge/river map with fractal detail, but you don't really need to jump through all of these weird hoops just to accomplish that task.


From what I saw in the linked paper, the resulting terrain just feels... off. Erosive features just don't really look like that. You can achieve much more realistic results from a simple raindrop erosion simulation: seed a terrain with some generated fractal noise, spawn an arbitrary number of raindrops across the map, and simulate stepping their movement as they run downhill to their lowest neighbor, simultaneously raising the sample they run to and lowering the sample they run from by some fraction of the difference in their heights. It's brain-dead simple, it relies upon a single pass of a noise generator plus a single pass of the erosion simulator, and if you enhance the erosion simulator to model raindrop accumulation and to track traffic "heaviness", or flow of raindrops, then you get lake/pond collection "for free" and a detailed flow map showing the most heavily-used waterways. Here are some quick examples, erosion only, performed upon a basic ridged noise fractal:




Even given the hideous quick texturing, the shape of the terrain feels much more natural to me than the ridges-and-rivers technique can produce.

Share this comment

Link to comment

@latch Well, it seems that having good lighting/materials goes a long way to make good terrain :D


@FLeBlanc Yeah you're probably right. I've seen water erosion algorithm's results before, it was the first thing I looked for after learning how to make a heightmap out of noise, and I know they have pretty good results even with simple algorithms. I wanted to try something different though. As I said before, I'll try with water erosion algorithms after I finish with this (or if give up trying to figure it out lol).


One question, if the water particle movement is done based on the heights of the neighbors, given that we're talking about a grid of points, wouldn't that produce some "squared" artifacts since every direction works in 45º steps?

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!