[mod]Builtin mapgens in Lua[github]

Post Reply
ShadMOrdre
Member
Posts: 696
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

[mod]Builtin mapgens in Lua[github]

by ShadMOrdre » Post

Builtin mapgens in Lua

There are several here. v6, v7, valleys 2d, valleys 3d. Also included are 3d and voronoi mapgens

Mapgens v6, v7, 3d, and valleys provides those terrain features from within Lua.

Voronoi is custom made, uses a 3 layered recursive voronoi.

All mapgens use lib_materials / lib_ecology biomes and decorations.

Biomes are determined within each mapgen.

Mapgens provide heightmaps and biome maps to other mods that depend on the mapgen.

Based on code from grunds mod, here are mg_v6 and mg_v7 Lua based mapgens.

Basic biomes system entact, uses MTG and default.

Depends on default.


LICENSE: LGPLv2.1
DEPENDS: lib_materials, lib_ecology

SUPPORTED VERSIONS:
v6 - https://github.com/ShadMOrdre/lib_mg_v6 ... _materials
3d - https://github.com/ShadMOrdre/lib_mg_3d
valleys2d - https://github.com/ShadMOrdre/lib_mg_valleys2d
valleys3d - https://github.com/ShadMOrdre/lib_mg_valleys3d
voronoi - https://github.com/ShadMOrdre/lib_mg_voronoi

ALTERNATE VERSIONS: (for use with MTG and default mod)
MG_V7: For default mod
mg_v7
MG_V6: For default mod
mg_v6

LICENSE:
LGPLv2.1

SCREENSHOTS:
mg_v7
Image
mg_v6
Image
Last edited by ShadMOrdre on Fri Nov 20, 2020 21:04, edited 2 times in total.
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

ShadMOrdre
Member
Posts: 696
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: [mod]mg_v6 and mg_v7 Lua mapgens [github]

by ShadMOrdre » Post

Now on Github!
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

ShadMOrdre
Member
Posts: 696
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: [mod]Builtin mapgens in Lua[github]

by ShadMOrdre » Post

Update with new mapgens, each a standalone mod.
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

Skamiz Kazzarch
Member
Posts: 178
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: [mod]Builtin mapgens in Lua[github]

by Skamiz Kazzarch » Post

Tried to get 'lib_mg_3d' going and noticed that it lists only optional dependencies for 'default' and 'lib_materials'. So I added it to a new world and upon loading got an error beacuse it tried to index a table from 'lib_materials' (which I didn't add, since it is listed as optional).
Adding 'lib_materials' just got me in the same dead end as i described here: viewtopic.php?p=384493#p384493


Also I made a PR for 'lib_mg_v6' which about doubles the generation speed.

Edit: Also, also the first link in the OP is messed up.

ShadMOrdre
Member
Posts: 696
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: [mod]Builtin mapgens in Lua[github]

by ShadMOrdre » Post

Skamiz Kazzarch,

My bad. If you're comfortable doing so, for each of these mods, you'll find at the top of init.lua, a list of the nodes used. There is a commented list of nodes for default, and the uncommented list for lib_materials nodes, the default choice. I admit I need to code that better.

The main branch for lib_mg_v6 and lib_mg_v7 should support default from MTG. This may be broken. For proper support for lib_materials / lib_ecology, please use the lib_materials branch for the v6 and v7 mods.

Edit: As for the PR, I actually had them coded for those performance "enhancements", but found zero difference between using the pre-defined buffers and what paramat calls "point polling". This is still true, but your link also points to new info of which I was unaware. I'll reinvestigate a few of those points.

Also, there are some further code enhancements regarding biome selection that I've made which will affect each of these mods and their respective performance.

One reason I've chosen the point polling method, is that when scaling noise values, using the recommended pre-defined buffers generally complains about too many octaves when other parameters are scaled low enough, but the point polled method still provides valid noise values. I'm not sure if this is intentional or a bug, but the behavior of the two methods is different. I used the voronoi mapgen for most tests, which is how I discovered this difference, when scaling the world size by 0.01.

The v7 and voronoi mapgens use some logic from Termos' Islands mod to form cliffs. All of these mods do in some way or another "depend" on lib_materials / lib_ecology, because I do not code for MTG or default. I've cobbled together my own mod soup for a "basic" development game base. I've refactored many, many mods to use this base, as opposed to MTGs default mod. In the process, I've made performance enhancements by trimming unnecessary code, rethinking basic logic, and by merging many redundant mods and code. While still buggy in mods that I've not given enough attention, it is complete and stable enough to code against.

Please let me know if you encounter any other issues or have any comments.

Shad
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

Skamiz Kazzarch
Member
Posts: 178
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: [mod]Builtin mapgens in Lua[github]

by Skamiz Kazzarch » Post

Still using 'lib_mg_3d'.
Went into the mod and chanched list of nodes used. Crash. At another place you also asume theat lib_materials is aviable:

Code: Select all

	local min_ocean = lib_materials.ocean_depth
	local min_beach = lib_materials.beach_depth
	local max_beach = lib_materials.maxheight_beach
	local max_highland = lib_materials.maxheight_highland
	local max_mountain = lib_materials.maxheight_mountain
so I go into lib materails find the values and paste them in. Crash. Too many octaves. (Why does that happen with the default vaules?)
So I find the numbers and after a bit of calculation I turn world scale up to eleven.
Crash.
This one took even more digging around and as far as I can tell you have hardcoded biome names it looks for.
Conclusion: 'lib_materials' is in fact not an optional dependency.

The simplest solution is probably to just mark it as a hard dependency and be done with it.


ShadMOrdre wrote:
Mon Nov 23, 2020 05:57
found zero difference between using the pre-defined buffers and what paramat calls "point polling".
You are mixing up different concepts.
On one hand you have point polling vs getting the noise data in bulk, that is using a 'PerlinNoise' vs 'PerlinNoiseMap' object.
On the other, if you are using a 'PerlinNoiseMap' and if you then use one of the functions which return the values in a flat array, you have the choice to use a second parameter to pass a table which gets filled with the result, instead of getting a whole new table with 512000 values.

The 'too many octaves' messege isn't realy acurate. What it is actually complaining about is that at least one level of octaves is shorter then one node (for example in lib_mg_3d with the provided values the shortest octave was less then 1/10 of a node long) The bulk noise generator uses interpolations to get the individual values to speed up, instead of calculating the values separately for each possition. I am guessing there is some issue with that method when the lenght of the octave falls bellow 1 node. If you 'point poll' you get one value at a time so there is nothing to interpolate.

Another point: The methods described in the article are focused on optimizing memory usage (to preventOOM), speed is a nice side benefit.

As for my PR, the biggest speed increase wasn't moving from point polling to bulk polling. It was from not creating four new noise objects for each x|z position. The same thing you already do here:
nobj_heatmap = nobj_heatmap or minetest.get_perlin_map(np_heat, permapdims3d)
can also be aplied to 'minetest.get_perlin'. Create once and then just reuse it.

PS: The first link in the OP is still messed up.

ShadMOrdre
Member
Posts: 696
Joined: Mon Dec 29, 2014 08:07
GitHub: ShadMOrdre
In-game: shadmordre
Location: USA

Re: [mod]Builtin mapgens in Lua[github]

by ShadMOrdre » Post

Skamiz Kazzarch,

The OOM optimizations that you pointed to are applied, where I could. In some instances, such as the v7 mapgen, the alt and base noise values scaled according to the persistance noise, and generated on the fly. Rather speedy, even when point polled. Because the two noises are scaled at runtime, using the OOM optimization recommended map and buffer is not possible. Also, due to scaling of noise values for alt, base, and height select, the map and buffer cannot be generated by the functions. "Too many octaves". The local polling also discards the map entirely, from what I can tell, calculating the value for that position, giving it the speed it has.

Where optimizations have not been applied elsewhere in these mods, if it was not on purpose, then it was only an oversight, and I'll get each updated to use the map and buffer.

On a related note, I use the following, instead of paramats' example. I honest couldn't get the map_flat to work, and didn't play with code very much. I also noticed that he uses an over length of 2, grabbing a node inside of each of the neighboring chunks. This causes gaps in terrian every 48 meters, and causes tree to be decapitated at that same elevation. This is reference to the definition and use of the chulens boundary variable being set to minp.x -1 to maxp.x + 1. The permapdims2d variable is minp.x to maxp.x, and does not write into neighboring chunks.

declared outside of on_gen call

Code: Select all

local nobj_2dnoise = nil
local nbuf_2dnoise = {}

local np_2dnoise = {noise params....}

local data = {}
declared inside of on_gen call

Code: Select all

local sidelen = maxp.x - minp.x + 1
local minpos2d = {x = minp.x, y = minp.z}
local permapdims2d = {x = sidelen, y = sidelen, z = 0}

nobj_2dnoise = nobj_2dnoise or minetest.get_perlin_map(np_2dnoise, permapdims2d)
nbuf_2dnoise = nobj_2dnoise:get_2d_map(minpos2d)
Shad
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.

Skamiz Kazzarch
Member
Posts: 178
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: [mod]Builtin mapgens in Lua[github]

by Skamiz Kazzarch » Post

So I took a look at 'lib_mg_v7' and must admit that I also see no easy way to optimize the getting of 'height_base'/'height_alt'. Though I am prety sure you would get a noticable speedup form creating the noise objects used for 'hselect' and 'persist' only once.

Anohter very easy optimization is to use this:
vm:get_data(data)
instead of this:
data = vm:get_data()
The later creates a new table and assigns it to 'data', while the former reuses the already existing table and thus doesn't have to allocate new memory.

As for the "Too many octaves." issue: That is affected by three factors: spread, octaves and lacunarity. Since the only thing you are scaling in this mapgen is persistance, you only need to set the initial noise params correctly, so they don't produce octaves shorter then one, and then you don't have to wory about it.

PS: The first link in the OP is still messed up.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests