[C++ Mapgen] Terrainbrot - A fractal-based mapgen

Post Reply
User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

[C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

To install my mod, build the source code at:
zip package: https://gitlab.com/h2mm/minetest/-/arch ... inbrot.zip
GitLab branch: https://gitlab.com/h2mm/minetest/tree/terrainbrot.

After that you can see the "terrainbrot" as one option.

Warning! The settings are currently subject of change. If you download a new version of terrainbrot, reset the settings to default.

This mapgen is based on the "fractal" mapgen. It iterates a rational function and uses perlin noise to generate stuff endlessly. Its variety is very huge. It can generate anything from flat lands to insane mountains. It also generates rivers. Some areas are full of rivers, other areas contain no rivers at all. Some rivers are straight, other rivers are curly.

It is not supposed to be a realistic terrain. I focused that on being simple and using a lot of variety. However, there are many places those look very realistic. I think, it might be also a good fantasy world.

Some screenshots: https://imgur.com/a/HSv5oCN

A short explanation of how it works:
Spoiler
Terrainbrot is an iterative complex number fractal like the Mandelbrot set. The formula is z -> R1(z) + R2(c) where R1 and R2 are rational functions. The default settings use rational functions of rank 10. The complex number z is created from the X- and Z-coordinates, but how does it involve the Y-coordinate? In each step, the travelled distance is calculated. After that, the number z is scaled according to the travelled distance and the Y-coordinate. I tried also other ways of involving the Y-coordinate and this one seems the best.

This makes quite good terrain but it's still more or less limited to the unit disc because the farther points always diverge. The complex number z is generated by two perlin noises. They have the same parameters, only the seed is different. And that's not all. The coeficients of the rational functions are also generated by perlin noises. In the default settings, the rank of these rational functions is 10. The rank of the polynoms on the top is 10, the rank of the polynoms on the bottom is 8. The upper polynoms have 11 coeficients, the lower polynoms have 9 coeficients. Each coeficient has both real and imaginary part. There are totally 80 parameters and one perlin noise for each. Again, the noise parameters are the same, just the seed is different.

Rivers are generated by escape-angle. If the point hits the correct angle in its last iteration and is in the correct distance, it is a river point. There are some minor tweaks to prevent the rivers from flowing out of its banks but it still happens sometimes.
All screenshots are from one world. The seed is no longer valid but the look hasn't changed. It's hard to find a world in which all interesting stuff can be seen. I have found at least some of them in this world.

License LGPLv2.1+

Changelog:
Spoiler
2018-06-21 Initial version
2018-07-16 Improved speed
2018-07-19 Added Cavebrot
2018-09-03 Fixed spawnpoint bug
Video: https://youtu.be/XireVf2cwOM
Image
Last edited by Hume2 on Sat Feb 25, 2023 09:51, edited 10 times in total.
If you lack the reality, go on a trip or find a job.

User avatar
voxelproof
Member
Posts: 1087
Joined: Sat Aug 05, 2017 08:13
Location: Europe

Re: [C++ Mapgen] Terrainbrot

by voxelproof » Post

It looks very, very good. And this shot

Image

is just awesome. I hope you'll work on it further and the mg will be added to the Minetest engine.

EDIT: of course I meant Minetest Game :)
Last edited by voxelproof on Wed Jun 27, 2018 18:48, edited 1 time in total.
To miss the joy is to miss all. Robert Louis Stevenson

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

Thanks for your feedback. I made a video and a short explanation of how it works. I made two more screenshots:

Image

Image
If you lack the reality, go on a trip or find a job.

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by ChimneySwift » Post

Wow this is really cool, I like that it's not that realistic, it opens up a new world of awesome terrain. I can see this and similar mapgen becoming the mapgen of choice for people who want a fantasy world.

In my testing it was quite slow however, I don't usually have speed issues with map generation but through out my tests my CPU was pinned and the map still generated slowly, still cool though.

Oh, and for the Windows users who want to try it, I made a Windows build which you can access here
A spoon is basically a tiny bowl with a stick on it

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

ChimneySwift wrote:Wow this is really cool, I like that it's not that realistic, it opens up a new world of awesome terrain. I can see this and similar mapgen becoming the mapgen of choice for people who want a fantasy world.

In my testing it was quite slow however, I don't usually have speed issues with map generation but through out my tests my CPU was pinned and the map still generated slowly, still cool though.

Oh, and for the Windows users who want to try it, I made a Windows build which you can access here
Thanks for feedback.

I'll try to optimise the generator a bit. Maybe the mgterrainbrot_rank can be reduced to 4 but I am unsure about the consequences. I'll try to work with perlin noise more effectively.

Thank you for making a Windows binary. However, your link seems to be broken, it says file not found. Could you look at it please?
If you lack the reality, go on a trip or find a job.

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by ChimneySwift » Post

Huh. That's weird. My other files are still there... Hopefully this doesn't become a problem.

New link here
A spoon is basically a tiny bowl with a stick on it

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

Thank you. I added the link to the first post.
If you lack the reality, go on a trip or find a job.

User avatar
voxelproof
Member
Posts: 1087
Joined: Sat Aug 05, 2017 08:13
Location: Europe

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by voxelproof » Post

Hume2 wrote:Thanks for your feedback. I made a video and a short explanation of how it works. I made two more screenshots:

Image
Wonderful.
To miss the joy is to miss all. Robert Louis Stevenson

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by paramat » Post

Interesting. Good idea to randomly create the iterative function from noise and seed and make it a quite complex function to generate a more complex structure.

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

Update: I have improved the speed a few times. Now you can find my code on GitHub. I hate Micro$oft©®™ but this is an exception because Minetest source is still on GitHub.

The algorithm doesn't change but the worlds are different though. And the code needs clearing :)
If you lack the reality, go on a trip or find a job.

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

I was experimenting with scaling the noises. I scaled both coordinate and polynomial noise 4 times in each axis. Even more epic structures generate. However, it takes long to find a spawnpoint and it often ends with placing the spawnpoint on sea or underground so this will not be default settings.

Some screenshots:
Image
Image
More screenshots at: https://imgur.com/a/2a21gzp
If you lack the reality, go on a trip or find a job.

User avatar
voxelproof
Member
Posts: 1087
Joined: Sat Aug 05, 2017 08:13
Location: Europe

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by voxelproof » Post

Hume2 wrote: Some screenshots:
Awesome.
To miss the joy is to miss all. Robert Louis Stevenson

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

I'm now experimenting with cave generation. I reused some noises to generate caves. They are all sizes and less predicable. It's a shame that there's not much to show underground. I used cave_explorer mod.

Image
Image
Image
Attachments
screenshot_20180719_163500.jpg
screenshot_20180719_163500.jpg (85.2 KiB) Viewed 810 times
screenshot_20180719_163622.jpg
screenshot_20180719_163622.jpg (61.09 KiB) Viewed 810 times
screenshot_20180719_163721.jpg
screenshot_20180719_163721.jpg (47.1 KiB) Viewed 810 times
If you lack the reality, go on a trip or find a job.

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

Update: I managed to fix the issue with spawnpoint that caused the spawnpoint to place in wrong height.
I think, I'll disable Cavebrot by default because these caves aren't what I expected to be. It will be still possible to enable it in config. The caves generate too frequently, are too large, don't branch much and I don't see a way to fix this.

Now the mapgen is almost as fast as v7. The spawnpoint finding function might use caches as well but currently it takes approx. 7 sec to find one, so I don't plan to do it now.

PS: I never noticed structures like these: Image These highlands elevate between y=100 and y=200 and there are large caves bellow them. And there are these weird structures at the borders.
Attachments
screenshot_20180903_183828.jpg
screenshot_20180903_183828.jpg (126.97 KiB) Viewed 810 times
If you lack the reality, go on a trip or find a job.

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

I finally migrated my branch to GitLab.

I added an option to make the fractal purely polynomial. After some experiments, it results in such realistic terrain as this shown on the pics. Only the rivers aren't much realistic.
Image
Image
Attachments
screenshot_20190128_143052.jpg
screenshot_20190128_143052.jpg (84.55 KiB) Viewed 810 times
screenshot_20190127_194713.jpg
screenshot_20190127_194713.jpg (111.4 KiB) Viewed 810 times
If you lack the reality, go on a trip or find a job.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by runs » Post

How to add to Minetest? I mean the code only not the whole Minetest.


I think this should be added to the official branch...

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by Hume2 » Post

runs wrote:How to add to Minetest? I mean the code only not the whole Minetest.


I think this should be added to the official branch...
You can do it by git rebase. If your Minetest is already downloaded via git, it shouldn't be a problem for you to check out another branch. Git shouldn't download all the unchanged files again, only the changed ones. Also, this mod modifies the Minetest's engine, so you have to build whole Minetest to enable it.
If you lack the reality, go on a trip or find a job.

CalebJ
Member
Posts: 407
Joined: Sat Dec 29, 2018 19:21
GitHub: KaylebJay
IRC: KaylebJay
In-game: CalebJ
Location: Tunnelers' Abyss

Re: [C++ Mapgen] Terrainbrot - A fractal-based mapgen

by CalebJ » Post

Here's a 900m ice spike created by terrainbrot. :D
screenshot_20190614_070842.png
screenshot_20190614_070842.png (216.51 KiB) Viewed 810 times

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests