Cuberite Forum
Some semi-random thoughts on terrain generation - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Some semi-random thoughts on terrain generation (/thread-409.html)



RE: Some semi-random thoughts on terrain generation - xoft - 10-25-2014

And now I've got beaches:
[Image: grown_biomes_02.png]


RE: Some semi-random thoughts on terrain generation - bearbin - 10-25-2014

Cool!


RE: Some semi-random thoughts on terrain generation - NiLSPACE - 10-25-2014

Is it possible to not always have beaches since vanilla Minecraft doesn't have beaches everywhere either.


RE: Some semi-random thoughts on terrain generation - xoft - 10-26-2014

It is possible to define which biome gets a beach when next to ocean, and which does not. It should be possible to add some randomness to it, too.


RE: Some semi-random thoughts on terrain generation - xoft - 10-27-2014

Progress report. Mainly concentrated on beaches and rivers. Note that the screenshot is now at 25% resolution.
[Image: grown_biomes_03.png]


RE: Some semi-random thoughts on terrain generation - NiLSPACE - 10-27-2014

That's awesomeBig Grin I can't wait to try this Smile


RE: Some semi-random thoughts on terrain generation - xoft - 10-27-2014

Go ahead, it's in the repo.
I'm only trying this with QtBiomeVisualiser, and I have a feeling that the rivers will be too narrow again.


RE: Some semi-random thoughts on terrain generation - xoft - 10-27-2014

Trust me, you don't want to read the code, it's a mixture of templates that is both awesome and awful at the same time.


RE: Some semi-random thoughts on terrain generation - NiLSPACE - 10-27-2014

One thing I noticed is that the biomes are quite big. Is it possible to reduce the size of them a little?

The rivers are a little to narrow as you said, but not by much:
[Image: 506c894f2c.jpg]


RE: Some semi-random thoughts on terrain generation - xoft - 10-31-2014

I've added a second implementation of the generator, GrownProt, which is exactly the same, but the code is probably easier to understand and it's really easy to play with it, chain the generators in a different way and see what that creates. The downside is that this easier code is less performant (I measured some 15 % loss, with a crude timer), so once I find a good chain for the int generators, I'll rewrite it back into the original version. I might keep the prototyping code in, if there's an interest.

For those of you who'd like to poke around: Probably the biggest surprise is how the generator achieves such random yet compact shapes. This comes mostly from one single thing - the Zoom class. It zooms the generated array by a factor of 2, but instead of using nearest-neighbor, or some form of bilinear interpolation, it uses a simple "random neighbor" decision. So in order to generate an N * N square of values, it first lets the underlying generator generate (N / 2 + 2) * (N / 2 + 2) square of values, and then for each square of 3 * 3 neighbors, sets the corners to the original values, the 4 values along the edges to a random one of the adjacent corner values, and the center value to a random one of the four corner values. That's it, that's the complete magic.
The rest of the methods just provide some smart biome selection, first deciding about where to put groups such as oceans, hot biomes, temperate biomes, cold biomes and mountainous biomes, zooming a few times to randomize the shapes, then choosing random biomes for each of the biome groups, again zooming a few times. By now the biomes are mostly formed, so the final steps are to do an edge-detection on the ocean-side, this creates beaches; zooming for the final time makes the beaches somewhat larger.