Wednesday, February 1, 2012

Terrain Generation In TFFS


My game will have more than 1,000,000,000,000,000 maps! How do I store that many maps in a downloadable file? (Or even make that many) How do I add one Gazillion maps to my game, but still keep the download size reasonable? It's called 3-D multifractual perlin noise. It takes numbers and letters, and turns it into a flowing, beautiful map.

But how does it work? How do I turn a seed like "183h91bc9d90dbnd" into a map? First I need to turn the seed into an integer. But I still don't have a map. I only have "183648951598459" (example). I am going to need a lot more numbers than that, but, I still want the map to be dependent on the seed (same seed = same map). To get more numbers, I use Java's seeded random number generator, and whenever I need a number, I just ask for one (they are still dependent on the seed!).

How do I make it 3-D? Simply, it looks at each block and checks whether it is solid. In more technical terms, it interpolates between eight points (see picture) using 1-D perlin noise. Eventually, it returns the answer to whether or not it is solid based on weights (if the weight is between 0 and 1, it is solid).

But what about caves? Imagine, you are without any resources to build a house, and you can't sleep in a cave because I never implemented cave generation. You generate a 2-D heightmap, and then use 3-d perlin noise to variate it in the different layers. Now you don't have to be robbed by raccoons (too bad you didn't have resources, anyway) and eaten by bears!

Thanks for following my development!

Doc

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.