fenomas / noa

Experimental voxel game engine.
MIT License
616 stars 91 forks source link

Procedural World Generation using Perlin Noise?? #44

Closed masonmahaffey closed 6 years ago

masonmahaffey commented 6 years ago

@andyhall Just out of curiosity, have you used perlin noise before for procedural world generation?

terrac commented 6 years ago

If you would like to see an example https://voxelverse.io/g/s/cooltester1/testPerlinNoise . In the world editing menu you can mess with the xyz lengths to see examples.

Although technically that is simplex noise which is supposedly an updated version of perlin noise with a bit more flexibility.

masonmahaffey commented 6 years ago

Excellent. I've been reading about this a lot and am going to try to implement it.

masonmahaffey commented 6 years ago

@terrac Is there a repository for voxelverse?

terrac commented 6 years ago

Sorry, no respository. I'd suggest looking at https://github.com/andyhall/noa-testbed/blob/master/lib/worldgen_worker.js for the basics of how to implement it.

fenomas commented 6 years ago

Thanks for the answers @terrac!

@mason0958 The demo Terry linked combines a couple of things. First it samples 2D noise to generate a height map, and then it samples a different set of 3D noise to decide where clouds are. Then within certain ranges it also decides whether to generate trees using a hash.

In all three cases the noise and hash functions are just ways of getting predictable random numbers (noise functions give you numbers that change smoothly, hash functions give numbers that change unpredictably). The "predictable" is the key - you can't really have anything truly random in world generation, because voxels at the edge of each chunk will get generated more than once (once for the chunk they're in and once for the chunk they border), and the values need to be the same each time.

masonmahaffey commented 6 years ago

Excellent! I can't wait to look at the code. I've been reading a lot how this works and it's pretty neat.