[Modpack] Mapgen Utils [mgutils]

Post Reply
User avatar
qwertymine3
Member
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

[Modpack] Mapgen Utils [mgutils]

by qwertymine3 » Post

This is a set of utility mods which I made for making my own Lua mapgen.

Please Note:
  • They are not designed to follow the conventions of the default mapgen API. In addition significant portions of the mapgen API are not supported by these mods.
  • They are primarily designed for ease of use, not performance. However these mods should not add significant performance overheads.
  • The APIs that are presented are subject to change.
  • These mods should work well together, but interfaces which are incompatible may be released.
mgnm: Noise Manager
This mod provides a combined interface for noise creation, buffer management, composition and indexing.
Spoiler
-- License: MIT
-- Download: https://github.com/Qwertymine/mgnm/archive/master.zip
-- API: https://github.com/Qwertymine/mgnm/blob/master/api.txt
-- Github: https://github.com/Qwertymine/mgnm

Use:
There is a larger interface than I can reasonably describe here, so I will provide some abstract code samples (used to design the interfaces) and a sample mod.

Code: Select all

local noise_params = {
        -- REQUIRED FIELDS
        size = {x=5,y=5,z=5},
        dims = 2,
}
local noise = mgnm:noise(noise_params) or mgnm:auto(noise_params)

minetest.register_on_generated(function(minp,maxp)
        noise:init(minp)
        noise[noise:index(x,y,z)]
end)

local ore_noise = {
        coal = nil, -- NoiseDef
        iron = nil, -- NoiseDef
}
local ores = mgnm:group(ore_noise)

local world_noise = {
        coal = ore_noise.coal,
        sand = nil,
}
local world = mgnm:group(world_noise)
 
local all = {
        world = world_noise,
        ores = ores,
}
all = mgnm:group(all) or mgnm:auto(all)

minetest.register_on_generated(function(minp,maxp)
        ores:init(minp)
        ores.coal[ores.coal:index(x,y,z)]

        world:init(minp)
        world.ores.coal[world.ores.coal:index(x,y,z)]
end)

local vmanip = mgnm:vmanip()

minetest.register_on_generated(function(minp,maxp)
        local emin,emax = vmanip:init()
        vmanip:get_data()

        vmanip.data[vmanip:index(x,y,z)]

        vmanip:set_lighting()
        vmanip.vmanip:set_lighting()
        vmanip:set_data()
        -- Cleanup ANY used tables
        vmanip:tini()
end)

local caves = {
        noise1 = nil, -- NoiseDef
        noise2 = nil, -- NoiseDef
        combiner = function(self,noises) -- Function
                for i,v in ipairs(noises.noise1) do
                        self[i] = noises.noise1[i] + noises.noise2[i]
                end
        end,

        size = mgnm.mapchunk_size, -- Size
        dims = 2,
}

local limited_caves = {
        caves = caves,
        limits = nil, -- NoiseDef
        combiner = nil,
        size = mgnm.emerge_size,
        dims = 3,
}

mgnm:combine(limited_caves) or mgnm:auto(limited_caves)

minetest.register_on_generated(function(minp,maxp)
        limited_caves:init(minp)
        limited_caves[index]
end)
Sample mod: https://github.com/Qwertymine/mgnm_test
mgmini: Minifier
This mod allows for all created noises to be scaled, to help view/test large scale noises.
Spoiler
-- License: MIT
-- Download: https://github.com/Qwertymine/mgmini/archive/master.zip
-- Github: https://github.com/Qwertymine/mgmini

Use:

Code: Select all

-- Call before any perlin noises have been initialised
mgmini:minify({x=15,y=2,z=15})

local noisedef = {
  --REQUIRED FIELDS
  octaves = 3,
  lacunarity = 2.0,
  persistance = 0.5,
  spread = {x=350,y=350,z=350},
  offset = 2,
  scale = 1, -- etc
  -- Dimensions must be added to the noise def to allow correct scaling of 2D noise
  dims = 2,
}
local noise = minetest.get_perlin_map(noisedef)
The vector passed is used for element-wise division of any created noises.
For 2D noises x divides x, y divides the noise scale and z divides y (and the unused z).
nlnoise: Noisedef Normaliser
This mod modifies a noise definition, such that the resulting noise has a range of +-noise.scale.
Spoiler
-- License: MIT
-- Download: https://github.com/Qwertymine/nlnoise/a ... master.zip
-- Github: https://github.com/Qwertymine/nlnoise

Use:

Code: Select all

local noise_def = nlnoise.normalise{
  -- REQUIRED DEF FIELDS
  octaves = 3,
  persistance = 0.5,
  scale = 1, -- etc
}
local noise = minetest.get_perlin(noise_def)

-- or 

noise = nlnoise.get_perlin{
  -- REQUIRED DEF FIELDS
  octaves = 3,
  persistance = 0.5,
  scale = 1, -- etc
}
-- License: MIT
Last edited by qwertymine3 on Wed Feb 15, 2017 19:20, edited 3 times in total.
Avatar by :devnko-ennekappao:

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [Modpack] Mapgen Utils [mgutils]

by azekill_DIABLO » Post

wow.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
TheReaperKing
Member
Posts: 531
Joined: Sun Nov 22, 2015 21:36
Contact:

Re: [Modpack] Mapgen Utils [mgutils]

by TheReaperKing » Post

Just a heads up, the first github link has a typo, you meant mgnm not mgmn
Become A Real Life Superhero - http://SuperheroHill.com
Project Lead of the Doom 3 Mod Last Man Standing - http://Doom3Coop.com
Project Lead of Platinum Arts Sandbox Free 3D Game Maker - http://SandboxGameMaker.com
Youtube Channel - https://www.youtube.com/user/PlatinumArtsKids

User avatar
qwertymine3
Member
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Modpack] Mapgen Utils [mgutils]

by qwertymine3 » Post

TheReaperKing wrote:Just a heads up, the first github link has a typo, you meant mgnm not mgmn
Thanks, fixed.
Avatar by :devnko-ennekappao:

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [Modpack] Mapgen Utils [mgutils]

by azekill_DIABLO » Post

This is a great addition to mapgen, i hope many mods will use it!
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
qwertymine3
Member
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Modpack] Mapgen Utils [mgutils]

by qwertymine3 » Post

Update!

Finally wrote an API reference for mgnm. Please suggest improvements for it.
Avatar by :devnko-ennekappao:

User avatar
TheReaperKing
Member
Posts: 531
Joined: Sun Nov 22, 2015 21:36
Contact:

Re: [Modpack] Mapgen Utils [mgutils]

by TheReaperKing » Post

This sounds super interesting. Do you happen to have any screenshots?
Become A Real Life Superhero - http://SuperheroHill.com
Project Lead of the Doom 3 Mod Last Man Standing - http://Doom3Coop.com
Project Lead of Platinum Arts Sandbox Free 3D Game Maker - http://SandboxGameMaker.com
Youtube Channel - https://www.youtube.com/user/PlatinumArtsKids

User avatar
qwertymine3
Member
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Modpack] Mapgen Utils [mgutils]

by qwertymine3 » Post

TheReaperKing wrote:This sounds super interesting. Do you happen to have any screenshots?
Here is a comparison for mgmini - Not particuarly good looking, but I had to remove the 3d noise (manually) used in the red hills, due to it being used with a 2d noise. (There is no way to detect this - I need to add a way for the user to give hints).
Spoiler
3d noises are scaled by reducing their spread params, 2d noises by reducing their spread AND their offset and scale.
This means that if (the value of a) a 3d noise is combined with a 2d noise using its value, it will change the outcome of the mapgen.
Also I didn't scale the height the mapgen adds sand - so the amount is inflated.
Other than that though, everything else scales well (including the 3d caves if you look closely).
Image
Image
Avatar by :devnko-ennekappao:

User avatar
TheReaperKing
Member
Posts: 531
Joined: Sun Nov 22, 2015 21:36
Contact:

Re: [Modpack] Mapgen Utils [mgutils]

by TheReaperKing » Post

Wow so crazy!! Map gen stuff always fascinates me :)
Become A Real Life Superhero - http://SuperheroHill.com
Project Lead of the Doom 3 Mod Last Man Standing - http://Doom3Coop.com
Project Lead of Platinum Arts Sandbox Free 3D Game Maker - http://SandboxGameMaker.com
Youtube Channel - https://www.youtube.com/user/PlatinumArtsKids

User avatar
qwertymine3
Member
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Modpack] Mapgen Utils [mgutils]

by qwertymine3 » Post

I quickly added the annotation system I'm talking about (not yet released), and it improved the output quite a bit:
Image
Avatar by :devnko-ennekappao:

User avatar
qwertymine3
Member
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Modpack] Mapgen Utils [mgutils]

by qwertymine3 » Post

Large update to mgnm and the test mod.

Now depends on mgbm - new MapGen Buffer Management mod.
https://github.com/Qwertymine/mgbm
OP and API ref is now out of date - will update when I have time.
Avatar by :devnko-ennekappao:

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 29 guests