Page 1 of 1

[Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Tue Jul 24, 2018 22:04
by Beerholder
Image

Multi Map allows subgame devs/ mod devs/ mapgen devs to create multiple worlds or "extend the world area" by stacking them on the Y axis. As such it can be used to:

  • Virtually extend the world area by allowing the same mapgen logic to be called for multiple layers, albeit with a completely different noise hence creating different terrain. The world area extension is then faked by layering these extensions on the Y axis
  • Alternatively it can also be used to implement multiple worlds, each having its own type of terrain or mapgen logic. E.g. underground worlds, sky worlds, desert worlds, lava worlds, jungle worlds, alien planet worlds, all within the same game/ on the same server
  • Offer a consistent way of dealing with multiple layers by offering a map generator plugin system and "global noises", rather than having multiple mods doing things differently each time, each having its own noises, etc.
  • Basically, reclaim "unused" space on the Y axis and allow this to be done in the easiest way possible, provided compatible map generator plugins are available. If not, you will have to roll your own of course, but by sharing the plugin it can be reused easily by others via the multi_map framework
  • Solve some common problems such as shadows, underworld/ overworld lighting, relative to layer Y positions, etc. when dealing with multiple layers
Heavily inspired by paramat's floatlands, duane's underworlds, the desire of some in the community to have a larger world and to better use the Y space, multi_map is part mod, part map generator and part framework, and can be found here (modpack):

Source: https://github.com/evrooije/multi_map
Documentation: https://github.com/evrooije/multi_map/wiki

Version: N.a. yet (alpha code, under heavy development, though I only tend to commit working code, knock on wood)
Tested with: Minetest Game master branch (0.5.0-dev)
Depends: default

License: Source MIT, textures derived from Minetest game CC BY-SA 3.0 (PilzAdam celeron55 sfan5 kilbith davidgumberg). Modified levels mapgen and lvm_example originally by paramat under WTFPL

The framework can be found in the multi_map_core mod
A few multi_map compatible generators are available in the multi_map_generators mod
Sample usage: https://github.com/evrooije/multi_map/b ... s/init.lua

A quickstart guide can be found here: https://github.com/evrooije/multi_map/wiki/Quickstart and an overview of the framework's concepts can be found here: https://github.com/evrooije/multi_map/wiki/Concepts

The API is available here: https://github.com/evrooije/multi_map/wiki/API

Warning!! Do not use this on existing worlds. Make sure you set the water_level to -31000 and mapgen to singlenode. Also, at this stage it is very bare bones and still requires a lot of work, especially on the map generator plugins ...

Pics or it didn't happen (mapgen used for the screenies is a modified levels mapgen by Mr. Mapgen himself, paramat):
+ "Pictures"

List of planned and implemented features:
+ "Features"

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sat Jul 28, 2018 03:32
by paramat
I love the stacked icon you made for this.

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sat Jul 28, 2018 08:45
by Krock
The mod idea is promising - but I'm missing something. How would I register a new layer from my Lua mapgen using this mod? Increasing the variable `multi_map.number_of_layers` by one sounds quite dangerous since it might offset all other registered layers.

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sat Jul 28, 2018 09:47
by Beerholder
Krock wrote:The mod idea is promising - but I'm missing something. How would I register a new layer from my Lua mapgen using this mod? Increasing the variable `multi_map.number_of_layers` by one sounds quite dangerous since it might offset all other registered layers.


I must admit I haven't had a chance to document this properly yet, sorry about that :( But it's most def a valid concern Krock. I'll give a couple of scenarios with examples (and copy that to the wiki):

Increasing number_of_layers by one should not be a problem, as it will stack on top of other layers. But as with changing normal parameters for other mapgens, there are some destructive operations. E.g. suppose that I have the following in init.lua in multi_map_generators:

Code: Select all
multi_map.number_of_layers = 1
multi_map.layers_start_chunk = 0
multi_map.layer_height_chunks = 20
multi_map.register_generator(0, mmgen_levels.generate)


Would create a world with 1 layer, starting from Y = -30912, 1600 nodes high using the levels plugin. Above that, nothing would be there. You can then actually change it on an existing world to:

Code: Select all
multi_map.number_of_layers = 2
multi_map.layers_start_chunk = 0
multi_map.layer_height_chunks = 20
multi_map.register_generator(0, mmgen_levels.generate)
multi_map.register_generator(1, mmgen_simple.generate)


This is still fine, as an additional layer of the simple singlenode generator is just added on top, unless you had visited this layer 1 before with e.g. fly/ noclip in which case it would break for the areas already visited or require you to regenerate the area. However, if you were to change the layer height to 21:

Code: Select all
multi_map.number_of_layers = 2
multi_map.layers_start_chunk = 0
multi_map.layer_height_chunks = 21
multi_map.register_generator(0, mmgen_levels.generate)
multi_map.register_generator(1, mmgen_simple.generate)


This would most def be destructive to existing worlds, and the layers will start to misalign. There will be a sharp 80 node high border in the singlenode world (as well as in the bedrock/ skyrock in the layer below). And if you had even more layers, it would cascade to the layers above, getting more and more misaligned with each layer.

Other things that would be destructive is to change the generator plugin for a layer, e.g. change the levels mapgen to something else, changing the start chunk. One more that is upcoming is "noise mixing". This allows a layer to wrap to the next, and does so by mixing its noise with the noise of the next. Add automatic teleportation and you "wrap" from one layer to another, as if the world does not end at the world border.

Anyways, was there any particular scenario you had in mind that could break things unintentionally using the mechanism I devised? Would it maybe be better if I write a multi_map_meta.txt with the settings in the world directory? Or is it the current lack of documentation and did I just forget to add big warning signs for changing certain settings on existing worlds? I must admit that the use of this mod requires careful planning ahead.

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sat Jul 28, 2018 10:52
by Krock
For me it was simply not clear on how I could register a new map layer. I imagined there could be an API to register a layer with an unique identifier and a custom thickness. The multi_map mod would then check the world configuration and insert a new layer where's free space in the world when the layer didn't exist previously. Or it would return the minimal/maximal coordinates of the layer directly so that they could be used in on_generate to calculate where the new "sea level" of the layer is.

Overall I miss an API and the documentation for it.

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sat Jul 28, 2018 17:22
by Beerholder
Krock wrote:Overall I miss an API and the documentation for it.

Fully agree, working very hard on it! :)

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sun Jul 29, 2018 00:54
by Beerholder
Demo of multi map showing: noise mixing, noise mirroring and layer wrapping

https://www.youtube.com/watch?v=hNrQASCeQsU

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sun Jul 29, 2018 01:27
by GreenDimond
Feature request for when this gets more stable: Override teleport and make it utilize zones and zone-specific Y-axis coords :D

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sun Jul 29, 2018 18:17
by sorcerykid
I'm continuing to keep a close eye on this project. Beerholder mods are always above and beyond impressive :)

Quick question: Is there any reason this multi-map concept couldn't eventually be implemented as a C++ mapgen wrapper? It seems like an essential feature. And being integrated into the engine, you could certainly overcome some of the notable obstacles (like the global F5 coordinates, the bedrock in the sky, etc.). Of course, that might also require changing the client-server protocol, but I'm not sure.

I realize you've already invested a lot of time on this, so I don't want to sound like I'm pushing you in a different direction. Just genuinely curious is all!

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sun Jul 29, 2018 21:10
by Beerholder
sorcerykid wrote:Beerholder mods are always above and beyond impressive :)

Aww thanks sorcerykid :D

sorcerykid wrote:Quick question: Is there any reason this multi-map concept couldn't eventually be implemented as a C++ mapgen wrapper?

Actually, this could most definitely be implemented in C++! To be honest, I started working on a subgame, so I just started writing it in Lua. C++ did not even cross my mind...

I should probably iron things out in the Lua version first as my C++ is still a bit rusty ;-) and some of the logic is sort of mind bending, kinda like the Inception way with the layer wrapping I am working on now O_o

So yeah, when I iron out the bigger design of this mod (e.g. Krock's comment made me think whether there should be a per layer height instead of a global one for all layers), have a reference implementation in Lua, something that works, some more feedback, I should most definitely investigate porting this to C++.

I like the idea as it could potentially also solve some memory and performance problems that I am worried about. The noise mixing especially concerns me, as it requires sets of noises (base terrain, mountains terrain, temperature, humidity, caves, etc.) to be duplicated at the border (and they might even have to be tripled at the world corner ... O_o) LuaJIT might not like that ... ... ...

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sun Jul 29, 2018 21:13
by Beerholder
GreenDimond wrote:Feature request for when this gets more stable: Override teleport and make it utilize zones and zone-specific Y-axis coords :D

That might actually be very handy to have yes, adding that to my list!!

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Mon Jul 30, 2018 05:12
by GreenDimond
sorcerykid wrote:like the global F5 coordinates

I think the F5 info can be controlled by the server in 0.5.0

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Mon Aug 06, 2018 23:19
by Beerholder
Hi all, I will be traveling for 3 weeks starting Wednesday. So a small update before I leave:

  • Documentation, documentation, documentation. I spent a lot of time writing documentation. Every day a little bit, and now I have 50 articles in the wiki. Then again, there was a lot to document and it was badly needed for a mod like this. Right now most if not all things you'd normally have to deal with are documented. And some of the things you should not need or even touch are documented as well
  • The levels mapgen has been fully ported now (it was only done partially sort of, not using all the multi_map features)
  • Layer wrapping works, but *on world edges only* :-( Next major challenge will be to mix and mirror noises at world *corners*. That I will look into when I am back. P.s. if you link a layer to itself, it does actually wrap you around to the opposite edge :D
  • Bedrock and skyrock can now be specified globally and per layer
  • Some fixes such as miscalculations, but I also removed the "nolight" parameter as I thought it would not be necessary. This broke the lighting I had worked so hard on to make it work, whoops ... O_o

Code updates haven't progressed as much as I would like and my todo list is getting longer instead of shorter -_- Guess writing the documentation and prepping for travels took most of my time. But in the meantime please always feel free to comment, give it a testrun, give feedback etc. It'll just take a while before I reply ;-)

Pushed all my latest changes, and docs can be found here: https://github.com/evrooije/multi_map/wiki

GreenDimond wrote:I think the F5 info can be controlled by the server in 0.5.0


Had a quick look last week, but couldn't find it right away. Then the documenting happened, but will check some more when I am back :-)

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Tue Aug 07, 2018 16:20
by CBugDCoder
This is Amazing Beerholder I can't wait till MT 0.5.0 is stable and more amazing mods like this come out.

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Wed Sep 12, 2018 05:31
by DrFrankenstone
I just watched the video, the blending idea is awesome!

Valleys mapgen adjusts the temperature and humidity, this leads to oasis or greenery following rivers, and some mods are tuned for it.

Example of the trick it pulls

I assume this means we're not going to be able to port the Valleys mapgen?

Is it worth attempting to get lua humiditymap objects writeable, so multi_map API can affect biomes?

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Thu Sep 13, 2018 15:05
by Beerholder
DrFrankenstone wrote:I just watched the video, the blending idea is awesome!


I will give credit where credit is due tho! :) viewtopic.php?f=11&t=10753&start=25#p164943 and viewtopic.php?f=11&t=10753 and many discussions such as viewtopic.php?f=5&t=9183

DrFrankenstone wrote:Valleys mapgen adjusts the temperature and humidity, this leads to oasis or greenery following rivers, and some mods are tuned for it.

<snip>

Is it worth attempting to get lua humiditymap objects writeable, so multi_map API can affect biomes?


I should look into this, but this concerns the noises provided by core/ C++ mapgens. It would be logical then to also do the noise blending in C++ but that is opening a whole can of worms and would only be applicable when porting multi map to C++. From a Lua perspective, writing the humidity map would not make sense.

Multi map does not write the maps is blends but only gets the two maps from opposite sides and returns the weighted averages. For the humidity map that would mean one would have to call a wrapper to get the noise, allowing multi map to decide whether the humidity map itself is returned, or a blended version. Unfortunately that means changes to mods making use of e.g. the core's humidity map :( To write the map might mean too much back and forth between Lua and the C++ map, impacting performance.

I did have a look at the Lua version of the valleys mapgen, I could try and make a multi map compatible version of that. But regardless, the engine's noise maps (humidity, temperature, etc.) are all food for thought :)

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Mon Nov 05, 2018 21:52
by Kilarin
This mod seems to be answering exactly what I needed!
You have added LOTS of documentation, which is wonderful! BUT, I'm stupid, and having trouble following the documentation, sorry.

So when the wiki says "The layer would be 20 chunks high"
What exactly does that mean? will it be 10 chunks (800 nodes) of dirt, and then 10 chunks (800 nodes) of air?
Is there a way, (or are you considering adding a way), that I could specify:
I want layer 0 to have 62 chunks (4960 nodes) of dirt and then 3 chunks (240 nodes) of air???
And I want layer 1 to have 10 chunks (800 nodes) of dirt and then 20 chunks (480 nodes) of air?

<edit>
Ok, after further study, I see:
This means that every layer has the same height
So, I can still work with this, but is it critical to the design, or would it be possible to build up a table of layers, so that they do not all have to be the same?

Why? I have a dream that I was playing with before you came out with this wonderful mod, where I would have multiple underground realms under y=0, and multiple above ground realms above y=0.
for this to work properly, I need to be able to turn off the bedrock on the below ground layers, and they need to be drastically different ratios of rock to air from the above ground layers. I can explain in more detail if it matters.

<edit 2>
AHA! I think I'm catching on. I can do whatever I want within a layer, this much rock, this much air, just by customizing the map gen function I use for that layer, is that correct?

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Tue Feb 05, 2019 08:33
by texmex
Hello Beerholder. With your mod, is it possible to generate the exact same map twice, as two layers? I'm thinking of a "shadow world" concept.

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sat Feb 09, 2019 09:48
by DrFrankenstone
Gael-de-Sailly's lua version of Valley's mapgen running as a Multi_map layer (see bottom right corner):
Image

/trying to drum up more excitement and interest in this awesome multi_map concept!

Having now played with multi_map, I reckon it could provide its own biome registration functions and biome lookup functions made in the image of Minetest's ones, rather than having generators use the C++ ones. That allows landscape generators to be separate from the game/world content of each layer, more mods could be converted, and it allows the noise blending tricks.
Alternately, if we could get the MapgenBasic::generateBiomes() c++ function exposed to lua (for great biome speed), we could use minetest.set_mapgen_setting("mg_biome_np_humidity", ..., true) etc to change the biome noise seeds whenever the layer changes. Beerholder - do you have any plans or imaginings for multi_map.register_biomes_and_decorations() or similar functionality? Should I play with the idea?

And texmex - shadow worlds... nice idea! I'm pretty sure it's possible without even specific support from multi_map by some hacks like:
Code: Select all
multi_map.global_2d_params[noise_name][<shadow_layer_num>].seed = multi_map.global_2d_params[noise_name][<layer_num>].seed


Though the functionality of matching a layer's noises could be formalized into a multi_map feature.

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Sat Feb 09, 2019 22:02
by texmex
Sweet, I need to try that!

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Wed Mar 06, 2019 22:50
by bhree
If it is possible to generate 2 or more exactly the same map layer then i'm thinking a map with time travel scenario like if you know chrono series. The coordinates may reveal the trick but the game may be more interesting like stronger mobs at the other layer. Or may be the same schematic while fresh at one layer but griefed in the other layer.

Re: [Mod/ Mapgen] Multiple Map Layer Generator [multi_map]

PostPosted: Thu Mar 07, 2019 16:07
by texmex
Yes exactly. I was thinking of Chrono Trigger and Zelda.