Let's say there's a rectangle with height values associated to each of its corners. If we divide this rectangle into 4 identical rectangles, we can see that there are now 5 new vertices (points) for which we could calculate height values.
Now we have to figure out a rule that interpolates (calculates) a new height value from the existing ones.
I decided to go with height variability variable and a constant "roughness" factor that divides height variability at every iteration. New heights are first interpolated for each row, then new rows are interpolated between existing rows.
We could imagine many different ways to interpolate heights but, for the sake of simplicity, ill stick to this one.
All that is left to do is to render the result using a game engine. I used the "Panda3D" engine, which has a Python/C++ API.
Here are three examples using a uniform probability law, for the same random seed, with an initial height variability of 10 and different values of roughness:
What if that weight was a random number instead?
I was lucky enough to get a nice valley with a tall cliff on the right side, which illustrates my point.
Assigning a random weight was a small manipulation that improved the result, but there is still a lot to do we want our terrain to look believable. We could imagine generating several of such terrain sections with different parameters (to make them look like mountains/hills/plains), then sticking them together. In this case, the heights along the rim of a section would serve as a boundary condition for the adjacent section.
I will leave you with an image of the same terrain with an earth-like color map:
Next time: Planets!







No comments:
Post a Comment