Followers 0

# Minecraft Terrain Generator

## 7 posts in this topic

Hello !

I have recently seen a video on YouTube showcasing a bit of play-around with MineCraft's terrain generator:

Can someone give me some guide-lines on creating a voxel terrain generator similar to MineCraft's ? I have searched a ton on Google, but nothing I found explained 'noise' noise 'lerp' or how to use them to get a MineCraft-like terrain generator. Any guidelines would be helpful.

Anticipated thanks.

0

##### Share on other sites

The idea of using noise to generate game terrain has been around for a while and making it look decent is one of the most challenging and in my mind, rewarding task I have encountered in game programming.

http://freespace.virgin.net/hugo.elias/models/m_perlin.htm has a very good introduction into what fractal Brownian motion (the page has it wrong) is, and how you can make it with examples in simple pseudo-code. Take note of the idea of using several 'octaves' of the same noise signal and summing them with different amplitudes. If you consider higher frequency noise (lots of changes for a small change in sample position) you can consider that to make rough/spikey ground. If you consider the lower frequency noise (much less change for large change in sample position) then this gives a very smooth terrain on the same scale. If take the low frequency noise and multiply it with a large number, you would get mountains and valleys, then by adding a small amount of higher frequency noise you would get smaller details in the mountains like small bumps. If you do this with enough octaves with appropriate amplitude values you can generate interesting looking terrain.

A similar technique called the Diamond-square algorithm can also be used to generate interesting terrain (I prefer this for the close in detail). An example can be found at

http://www.gameprogrammer.com/fractal.html. An iteresting thing to note about this one is that if you set the first level or two's values, you can force the algorithm to fill in the blanks of a terrain which you have set the vague shape of. That is if you lowered some of the points, a valley/river/depression would be formed there and the close in detail will be randomly generated for you. Using this idea you could actually use the perlin noise above to generate set heights for every kilometer for example, then use diamond squares to fill in the higher resolution details down to 1m scale.

In the end, generating whatever kind of terrain you want is all about combining different types or noise and how you choose to use the values they generate. Making it look good is the result of fine tuning the amplitudes, roughness factors, scales, etc. until you get something that looks appropriate and can be used in your environment.

Edit'd to stop perpetuating the fractal Brownian motion/perlin noise mistake. Thanks Bacterius.

-BiT

Edited by RnaodmBiT
2

##### Share on other sites

The idea of using noise to generate game terrain has been around for a while and making it look decent is one of the most challenging and in my mind, rewarding task I have encountered in game programming.

If you are doing it realtime, it can be really challenging. Otherwise, just go nuts.

The hardest thing for me was always making this kind of world look good when rendered. So few resources, so many vertices and so much stuff you can't know is hidden until one frame later.

Otherwise, I just try to one thing at a time, or I will go insane.

Good luck with all your projects, and just message me if you want to talk about procedural generation things. Not that I know what I'm doing or anything.

At least it looks ok http://fbcraft.fwsnet.net/morning.png but the FPS is really bad.

Anyways,

the first thing to do when doing terrain generation is to make 2 steps:

1. create a function that returns an ID for each integral (x, y, z)

this is the procedural generation function, unless you aren't doing things realtime, in which case you can do several steps including volumetric fills etc for lakes

you basically use noise to generate density, and where density is < 0 add dirt (or stone, preferrably dirt as we will see later), otherwise AIR

if the value was AIR but the Y coordinate value was less than WATERLEVEL (eg. 64 blocks) just return water instead

2. postprocess the terrain from top to bottom to make it natural

start at the top, for each air block all the way down you have "atmospheric light" with you, so any dirt turns into grass

after you hit ground after a certain amount of blocks you should fake pressure by converting dirt into stone so that the world is layered

you can use noise here to emulate pressure differences

before postprocess create a 2d noise value:

use to create some variance in the seabed height, so that some green terrain is underwater, and other places have long beaches

use to create some forest boundries, use the inverse to add more dense ground foliage.

looks very natural now

use volumetric fill on randomly picked stones to quickly add minerals

3. Realize too late that the world scale is all wrong

My world is basically a giants version of a real world (I guess?) which makes it look really small when high up.

World scale is important! And don't write your generator in a dead language, like me.

I have collected some useful noise functions in my (new) generator (which doesn't generate anything yet):

https://github.com/fwsGonzo/generator/tree/master/terrain/noise

Edited by Kaptein
1

##### Share on other sites
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm has a very good introduction into what perlin noise is, and how you can make it with examples in simple pseudo-code. Take note of the idea of using several 'octaves' of the same noise signal and summing them with different amplitudes. If you consider higher frequency noise (lots of changes for a small change in sample position) you can consider that to make rough/spikey ground. If you consider the lower frequency noise (much less change for large change in sample position) then this gives a very smooth terrain on the same scale. If take the low frequency noise and multiply it with a large number, you would get mountains and valleys, then by adding a small amount of higher frequency noise you would get smaller details in the mountains like small bumps. If you do this with enough octaves with appropriate amplitude values you can generate interesting looking terrain.

Note this isn't Perlin noise, but fractal brownian motion (abbrv. fBm). It's often joked that this page is probably the source of most confusion regarding Perlin noise. Fractal brownian motion can still be used towards the same goal (creating nice procedural landscapes, etc..) but just keep in mind the author is mislabeling the algorithm he is describing, so you don't perpetuate the mistake

0

##### Share on other sites

Note this isn't Perlin noise, but fractal brownian motion (abbrv. fBm). It's often joked that this page is probably the source of most confusion regarding Perlin noise. Fractal brownian motion can still be used towards the same goal (creating nice procedural landscapes, etc..) but just keep in mind the author is mislabeling the algorithm he is describing, so you don't perpetuate the mistake

fbm is really good for creating terrain types, like http://jpdict.ath.cx:8181/files/biome2d.png

I also invented my own noisetype that is probably really bad, but worked out in some cases:

http://fbcraft.fwsnet.net/cnoise_v2_2.png

0

##### Share on other sites

I also invented my own noisetype that is probably really bad,...

I like it. Your screenshots look nice.

Here some additional resources. JTippets has a couple of journal entries about Minecraft style terrain generation:

http://www.gamedev.net/blog/33/entry-2227887-more-on-minecraft-type-world-gen/
http://www.gamedev.net/blog/33/entry-2249106-more-procedural-voxel-world-generation/

He uses his self-rolled noise library:

http://accidentalnoise.sourceforge.net/

Comes with a nice LUA interface. IIRC he even has an example script for such terrain.

Alternatively, there's this noise library:

http://libnoise.sourceforge.net/

If speed is a problem, it is of course possible to generate noise on the GPU (don't know of any library, though).
0

##### Share on other sites

I would also like to mention the use of sampling a 3D noise function using fBm sampling to generate a 'density' function (even just combining several 2D samples can look good). If you then subtract a threshold value from the function you can say that any where the density is less than 0, you have open space and larger than 0 indicates solid ground. This can be used to generate voxel fields or as input for the marching cubes algorithm to generate some nice terrain with the advantage of the ability to specify open spaces 'under ground', ie. caves.

-BiT

1

## Create an account

Register a new account