Question

First of all sorry for my pour english.

I'm trying to make virtual world with terrain just like in simcity2000 or transport tycoon where terrain is made from tiles and tile heights can't jump more than one level between tiles, so there is no cliffs.

For terrain generation I'm using perlin\simplex noise but I'm getting to stiff slopes with that.

I've took a look on the source code of Open Transport Tycoon, and there after terrain generation all tiles on map are looped through and smoothed out to have elevation for just one unit.

But it won't work this way for me, because my map will be much bigger and I cannot afford smoothing all of it by loop. Also it's not possible to smooth just the visible part of terrain , because it will be different depending on from which tile smoothing was started.

I've tried to write my own noise function which is returning linearly interpolated value between two points with distance equal to max height of those points, that way slope can't be more than 45 degree, it worked but until you try to sum such functions together.

How can I pseudo-randomly generate terrain with mountain slopes of max 45 degrees, and aproach this other way than just smoothing out some previously generated map?

Right now I'm out of ideas, and hoping that Perlin noise may have some possible option like "max slope angle", but google didn't help me with that.

Was it helpful?

Solution

Perlin noise is inherently slope-limited, since the values within each grid cell are interpolated between four gradients that all have slope 1/gridSize (or some other fixed value depending on your implementation).

If you generate a limited number of octaves with a fairly wide grid relative to your tile size, you should be able to find a scaling factor experimentally that ensures a maximum slope of 1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top