Jump to content

  • Log In with Google      Sign In   
  • Create Account


Minecraft Terrain Generator


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Marron   Members   -  Reputation: 115

Like
0Likes
Like

Posted 08 June 2014 - 12:52 PM

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.

 

 



Sponsor:

#2 Eck   Members   -  Reputation: 2114

Like
5Likes
Like

Posted 08 June 2014 - 02:39 PM

I did a quick search for noise terrain generation, and the first link looks like a promising overview:

http://www.thedevilisinthecode.com/terrain-generation-using-perlin-noise.html

 

I did a search for minecraft terrain generation and came up with a post from Notch:

http://notch.tumblr.com/post/3746989361/terrain-generation-part-1

 

Lerp stands for linear interpolation. Given two points startPoint and endPoint, you can imagine the path of a point as it goes from startPoint to endPoint. Lerp functions often take a parameter that reprecent a percentage of how far along that path you go in the range [0,1] typically called t. When t is 0.0, you're at the startPoint. When t is 1.0, you're at the endPoint. When t is 0.5 you're halfway between startPoint and endPoint.

 

http://en.wikipedia.org/wiki/Lerp_(computing)

 

- Eck



#3 RnaodmBiT   Members   -  Reputation: 610

Like
1Likes
Like

Posted 11 June 2014 - 12:38 AM

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, 11 June 2014 - 05:51 AM.


#4 Kaptein   Prime Members   -  Reputation: 2058

Like
1Likes
Like

Posted 11 June 2014 - 01:04 AM

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, 11 June 2014 - 01:28 AM.


#5 Bacterius   Crossbones+   -  Reputation: 8523

Like
0Likes
Like

Posted 11 June 2014 - 01:12 AM

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 smile.png


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#6 Kaptein   Prime Members   -  Reputation: 2058

Like
0Likes
Like

Posted 11 June 2014 - 01:34 AM

 

 

 

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 smile.png

 

 

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



#7 unbird   Crossbones+   -  Reputation: 4973

Like
0Likes
Like

Posted 11 June 2014 - 02:00 AM

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).

#8 RnaodmBiT   Members   -  Reputation: 610

Like
1Likes
Like

Posted 11 June 2014 - 05:56 AM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS