Page 1 of 1

Canyon Mapgen Mod

PostPosted: Tue Apr 05, 2016 23:07
by MillersMan
At the moment I'm working on implementing an old idea about maps with rivers that go strictly downhill. I'm doing this in a local fork but I would love to see it added to minetest once it got usable.

Update: The Canyon Mapgen Mod is a C++ based modification/fork of Minetest that brings a mapgen with plausible streams that will flow downhill to join and form bigger rivers. You can check out the code at: https://github.com/MillersMan/minetest_canyon_mapgen/tree/canyon-mapgen

Features implemented:
  • A valley-like map with roughly 1000x1000 nodes (Update: spans the whole MT map now)
  • Rivers with a length of more than 1000 nodes
  • A groundwater-heightmap
  • Groundwater is strictly flowing downhill to form rivers
  • Rivers are strictly flowing downhill until they join with other rivers or leave the map
  • Rivers now also affect the biomes close to them

Current limitations:
  • Supporting area for each river is squared (causes straight cliffs)
  • Groundwater might be above ground at the border of the supporting area
  • Rivers might form loops where they almost touch an uphill part of themselves
  • River beds are currently hacked in so they are always sandy and ignore the biomes

Planed features:
  • Paging of generation structure (would allow rivers spanning the whole MT map with decent performance and only a few MB needed for caching, generation without cache also possible but needs a O(log n) duration instead of O(1) for generation of each chunk where n is the size of the whole MT map in one direction) (Update: is implemented now)
  • Random shape for the supporting area of rivers
  • Lakes and Oceans
  • Waterfalls
  • Rivers in caves
  • Changing humidity for biomes: Currently rain is expected to be evenly distributed over the whole map
  • Glaciers as springs for rivers

Image
Image

160406a.png
160406a.png (945.13 KiB) Viewed 7642 times

Re: Canyon Mapgen Mod

PostPosted: Sat Apr 09, 2016 06:35
by Krock
The preview of your mapgen looks good but would it be possible for you to adjust the scaling of the map calculation?
Currently the terrain looks a bit too small. Walk 15 nodes and you've got into a river again. For builders, who would like to have a nice landscape, it would be helpful to have larger and flatter areas.

Re: Canyon Mapgen Mod

PostPosted: Sat Apr 09, 2016 22:00
by paramat
Interesting, something i have wanted to work on, a big challenge, good luck.

Re: Canyon Mapgen Mod

PostPosted: Sun Apr 10, 2016 11:12
by MillersMan
paramat wrote:Interesting, something i have wanted to work on, a big challenge, good luck.


Thanks a lot. I just finished the paging which is necessary to have rivers potentially spanning the whole map without having to calculate the map at once.

160411.jpg
Shows how generation structure is split into chunks of 64x64 with stone-borders whereas the first post used one single 1024x1024 chunk
160411.jpg (176.64 KiB) Viewed 7642 times


Here are some details in case anyone wants to try a similar approach from scratch:

I'm generating the rivers together with the landscape as inserting them to finished landscapes will take to much resources for a real-time-generation. I'm using a fractal like approach where I start off with a very low-resolution map and adding details with each iteration. Therefore I can't use complete noise-generators and instead creating the noise together with the whole map. The most basic map in current implementation would create a single NoiseMap (currently ValueNoise instead of PerlinNoise which would be more balanced) with the following properties:
* lacunarity: 2.0 (fixed)
* octaves: fractal iterations / 2 (=10)
* spread: size of whole map (=65536)
* persist: no limitations
* offset and scale: no limitations, but have different values as they are applied per round

I'm currently using two such maps (ground-water-level and ground-level) and another map which contains the location and direction of rivers. At each iteration I'm adjusting all noise-values so that they fit to all noise-values of grid-neighbours without breaking any of the rules.

Re: Canyon Mapgen Mod

PostPosted: Sun Apr 10, 2016 11:32
by MillersMan
Krock wrote:The preview of your mapgen looks good but would it be possible for you to adjust the scaling of the map calculation?


I'm planning to fine-tune it once the basic stuff works reliably. The current density of rives has the advantage that it's easy to spot potential issues without having to travel a lot. Some issues on my list are:
  • Avoiding touching of different rivers or sections of rivers (e.g. there is a small loop in the screen-shot of my first post. Or there are two separate rivers almost touching in my second screenshot).
  • Avoiding that small rivers on mountain-tops touch cliffs, cause waterfalls and then flow on to the other side of the mountain.
  • Reducing the chance that rivers build canyons straight through the biggest mountain in the area
  • Expanding rivers so that they might be bigger than a single node
  • Finally creating real mountains and plains as currently everything is just a single noise-function
Of course there is a lot more on my list but those are the priorities.

Re: Canyon Mapgen Mod

PostPosted: Sun Apr 10, 2016 13:04
by prof-turbo
This looks like a cool and hard thing to make. Good luck !

Will you share your work soon ?

Re: Canyon Mapgen Mod

PostPosted: Sun Apr 10, 2016 21:55
by MillersMan
prof-turbo wrote:Will you share your work soon ?


I'm planning to get it more stable, do a clean-up and to adjust it to the MT coding style before release. I hope to get to this state in the next weeks, but it really depends on my time and motivation.

Re: Canyon Mapgen Mod

PostPosted: Mon Apr 11, 2016 00:28
by twoelk
paramat wrote:Interesting, something i have wanted to work on, a big challenge, good luck.

deja vu?

Re: Canyon Mapgen Mod

PostPosted: Mon Apr 11, 2016 21:20
by MillersMan
twoelk wrote:
paramat wrote:Interesting, something i have wanted to work on, a big challenge, good luck.

deja vu?


@paramat: Oh, I wasn't aware that there is a mod with similar goal and same name. I hope this doesn't bother you. Maybe I should rename it...

Re: Canyon Mapgen Mod

PostPosted: Mon Apr 11, 2016 22:31
by MillersMan
Some updates with biomes/decoration enabled:

160412.jpg
Relative close to the source with a waterfall in the background
160412.jpg (156.58 KiB) Viewed 7642 times


160412a.jpg
Somewhere more downstream, the waterfall in the middle is a bug, the right one is a small river from an higher region.
160412a.jpg (194.32 KiB) Viewed 7642 times


160412b.jpg
And another one
160412b.jpg (147.43 KiB) Viewed 7642 times


Unfortunately rivers are still limited to a width of one node.

Re: Canyon Mapgen Mod

PostPosted: Tue Apr 12, 2016 18:00
by prof-turbo
Ow. That gets really interesting !
Is it a lua mapgen or a C++ one ?

Re: Canyon Mapgen Mod

PostPosted: Tue Apr 12, 2016 20:26
by MillersMan
It's a C++ one. It's just easier to code it in the language I use at work every day (Actually it's C++11, but it could be easily ported back to MT style)

Re: Canyon Mapgen Mod

PostPosted: Wed Apr 20, 2016 22:25
by MillersMan
I'm currently preparing a first version for code-release. It's still very rudimentary and has a lot of rough edges (or better blocky canyon walls) but here are a few other screens:

bigger-river.png
bigger-river.png (716.76 KiB) Viewed 7642 times


canyon-at-night.png
canyon-at-night.png (445.69 KiB) Viewed 7642 times


What pages are proposed for image-upload? I don't want to spam the forum with my screen-shots and I'm also not able to inline attachments in the posts :(

Re: Canyon Mapgen Mod

PostPosted: Thu Apr 21, 2016 10:28
by azekill_DIABLO
i just love this :)

you can also do [img]the%20url[/img]

Re: Canyon Mapgen Mod

PostPosted: Thu Apr 21, 2016 11:13
by paramat
No problem, my mod is called 'canyon' but it's not essential to avoid that exact name.
My mod is very different and very simple, no attempt at realistic rivers that go downhill.
Good work.
I and some others use http://imgur.com/ it has a limit of 100-200 images.

Re: Canyon Mapgen Mod

PostPosted: Thu Apr 21, 2016 12:26
by ExeterDad
Hi MillersMan.

Attach you images as you have done already. When it/they are uploaded, right click and copy link location. Then use the "img" tag and paste the copied image url into it. It will look like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
[img]https://forum.minetest.net/download/file.php?id=5897[/img]


And it will appear like this when posted:
Image

Repeat as needed up to three attachments per post.

Re: Canyon Mapgen Mod

PostPosted: Thu Apr 21, 2016 23:10
by MillersMan
I've forked minetest and pushed my changes:
https://github.com/MillersMan/minetest_canyon_mapgen/tree/canyon-mapgen

I'll also update the initial post.

Re: Canyon Mapgen Mod

PostPosted: Fri Apr 22, 2016 10:27
by paramat
You need 2 more files changed, see my watershed branch as an example https://github.com/paramat/minetest/tree/rivergen
If you feel like contributing to the engine we could do with more C++ talent, see the issues/PRs at github and maybe chat to us on IRC dev channel.

Re: Canyon Mapgen Mod

PostPosted: Fri Apr 22, 2016 15:30
by MillersMan
Oh, thanks, shouldn't commit and push the changes late at night, reverted the CMakeList.txt to undo the C++11 related changes and forgot that it is also needed for listing the source-code. Should be updated now.

Re: Canyon Mapgen Mod

PostPosted: Sun Jun 19, 2016 21:49
by Gael de Sailly
That looks great. I'm very interested in this project. I've tried to understand the code but I… didn't managed :D
I've been trying for months to find an algorithm for creating rivers this way, that really intersects properly. I've never managed to get this.
Could you describe broadly how it works? I'd love to work on it with you!
Really, congratulations.

Re: Canyon Mapgen Mod

PostPosted: Sun Jun 26, 2016 18:09
by MillersMan
I've pushed a new version.

This version slightly improved river-routing and grew the mountains. Rivers now also affect the biomes. They have a more average temperature and a higher humidity.

Re: Canyon Mapgen Mod

PostPosted: Thu Dec 08, 2016 22:20
by MillersMan
Image

Nice location while testing some changes: Two rivers and a small stream join to form a bigger river. The only strange thing is that the rivers come from the mountains while the small stream goes on in valley.

In other news: I'm working on a more generic implementation that might be modable.