Create random hills and smooth terrain

Blitz3D Forums/Blitz3D Beginners Area/Create random hills and smooth terrain

rebootbug(Posted 2009) [#1]
Hi everyone

I am trying to create randomly placed hills on a terrain in code and found references to the following page which no longer exists

http://www.robot-frog.com/3d/hills/index.html

Does anyone have any good resources for random hills and terrain smoothing?

I am aiming for rolling random hills similar to those by MisterMecha as seen here

http://www.blitzbasic.com/gallery/view_pic.php?id=1015&gallery=hr&page=27

Thanks Brendan


puki(Posted 2009) [#2]
"Makakoman" created the Blitz Infinite Terrain Engine (B.I.T.E.).

As far as I know, it is not random, but it is infinite which means you can drop the player (whatever) in anywhere.

http://www.blitzmax.com/Community/posts.php?topic=75758


sswift(Posted 2009) [#3]
http://blitzmax.com/codearcs/codearcs.php?code=696

Just create a mesh based on the height values produced by that function, and you will have a random terrain with hills.

If you want smooth hills like those seen in that screenshot then you'll need to do a gaussian or bilinear blur to that heightmap before you use it.

Another way you could possibly accomplish this is just fill an image with random noise and then create a mesh which is finer than your image map, and interpolate between the noise pixels. Ie, if your vertex is between four pixels, then add them after multiplying the values by the relative distance of the vertex between them. That achieves the same thing as scaling the noise image up with bilinear filtering and then using that as a height map.


Yasha(Posted 2009) [#4]
An alternative to Perlin noise is the diamond-square algorithm. Notable in this instance because it makes it a little easier to predefine certain things like the location of hills - more info here. Although it doesn't produce results exactly like those in the screenshot you linked.


rebootbug(Posted 2009) [#5]
Thankyou puki for posting the above thread with the link to the web archive and the blitz infinite terrain engine, both very useful.

Also thankyou very much sswift for your great explanation, and your nice perlin noise function it will definately come in handy.

And finally thankyou Yasha for the link to the diamond square algorithm I have always been fascinated by fractal terrains it was very interesting to read.

Thanks Brendan

Here are the web archive links for reference as they may be useful to others
http://web.archive.org/web/20071028121233/www.robot-frog.com/3d/hills/hill.html
http://web.archive.org/web/20071217234828/www.robot-frog.com/3d/hills/normalize.html
http://web.archive.org/web/20071217233631/www.robot-frog.com/3d/hills/flatten.html
http://web.archive.org/web/20071217233720/www.robot-frog.com/3d/hills/island.html