- Home /
Some questions about random world generation
Hi!
I want to make randomly generated world entirely made of cubes(minecraft-ish). And I have a few questions: 1.Giveing every block a random coordinate is really great but it doesn't look uniform (I can't make smooth hills and things like that). Every block is just there without any "interaction" with others.![alt text][1]
So I came up with creation of chunks (32x32 for example) based on random height and a mathematical function. ![alt text][2] But it won't let me build more complex forms that will go across few chunks. And I still don't know how to handle transition between chunks. If someone could help with that it would be great.
My script really slows down when it makes bigger chunks. Some tips for optimization? I have a script that disables rendering of cubes if they are not in the bounding box of main camera (second picture) but this seems to slow down even more.
Thanks for your time. Any help highly appreciated. Greg [1]: /storage/temp/34861-randomness.png [2]: /storage/temp/34862-less+random.png
Answer by gribbly · Nov 08, 2014 at 09:02 PM
Take a look at Mathf.PerlinNoise. It's designed for this kind of thing. See also this thread.
A common approach to things like this:
Generate your terrain based on a heightmap - i.e., a greyscale bitmap image where a black pixel is your lowest terrain value, and a white pixel is your highest terrain value. 50% grey is 50% height, etc.
Now instead of generating your terrain directly, generate heightmap images. This will make it much easier to experiment with various 2D noise functions and get interesting/smooth features, etc.
You could do a similar thing without using a heightmap image, but having the image is nice because you can generate offline, use known images, etc. It also gives you a nice way to save your terrains.
Thank you good sir. I'll try to learn this technique. Any tips for optimization?
Your answer
Follow this Question
Related Questions
Serious Drawcall Issues 1 Answer
Random Terrain Generation (Trees, Details, Textures) by passing a Seed? 0 Answers
Minecraft strater package in JS 0 Answers
Is minecraft made of cubes? 4 Answers
Random Terrain Generation 2 Answers