Post your mapgen questions here (modding or engine)

User avatar
StarNinjas
Member
 
Posts: 286
Joined: Wed Mar 14, 2018 00:32
Location: aincrad
GitHub: starninjas
IRC: StarNinjas
In-game: J1
 

jakab
Member
 
Posts: 86
Joined: Mon Aug 15, 2016 17:19
IRC: jakab
In-game: jakab

Re: Post your mapgen questions here (modding or engine)

by jakab » Fri May 03, 2019 13:40

hi! how can i set stuff to generate in the sky ? like i set a biome that min depth +10000 and max depth +15000.
like a sky world, or just something entirely different than usual, so people can teleport there. (for example teleport up to the moon's surface.)
 

Exilyth
Member
 
Posts: 71
Joined: Sun Jul 28, 2013 18:46
Location: Earth

Re: Post your mapgen questions here (modding or engine)

by Exilyth » Sat May 11, 2019 11:03

Is there a visual guide to the different mapgens and their settings?
 

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

Exilyth
Member
 
Posts: 71
Joined: Sun Jul 28, 2013 18:46
Location: Earth

Re: Post your mapgen questions here (modding or engine)

by Exilyth » Sun May 12, 2019 15:18

Skamiz Kazzarch wrote:https://wiki.minetest.net/Mapgen
This is the closest I know of.


Thank you.
That's nice. Not as extensive as I would have liked, but great nonetheless.
 

sirrobzeroone
Member
 
Posts: 106
Joined: Mon Jul 16, 2018 07:56

Re: Post your mapgen questions here (modding or engine)

by sirrobzeroone » Wed Jun 26, 2019 02:27

I think what Im trying to do might be beyond the scope of the lua inbuilt mapgens as I wish to fundamentally change the perlin noise on generation and not just by running additional octaves, adjusting the frequency (lucunarity) or amplitude (persistance).

More want to confirm my understanding is correct or close essentially minetest.get_perlin_map() provides the ability to alter a single perlin noise image in the scope of adjustments to octave, frequency and amplitude.

However is it possible to manual specify the generation of noise map using custom settings then generate the perlin noise map as per normal then subtract the two images one from the other. Providing a new single map image which would then be used to generate the terrain as required? I dont think this is possible as via lua we don't seem to have access to the ability to merge/blend but rather the data is dumped out of the function in a pre-tabled format.

I'm hoping what I've said make some sense as I've spent a fair bit of time trying to get my head around this but not sure at this time how my understanding is going so wanted to confirm if what I've said above is about correct.

thanks for the help.
 

User avatar
duane
Member
 
Posts: 1523
Joined: Wed Aug 19, 2015 19:11
Location: Oklahoma City
GitHub: duane-r

Re: Post your mapgen questions here (modding or engine)

by duane » Wed Jun 26, 2019 04:37

sirrobzeroone wrote:However is it possible to manual specify the generation of noise map using custom settings then generate the perlin noise map as per normal then subtract the two images one from the other. Providing a new single map image which would then be used to generate the terrain as required? I dont think this is possible as via lua we don't seem to have access to the ability to merge/blend but rather the data is dumped out of the function in a pre-tabled format.


No, you can't do that. It's not a common requirement. However, there's no reason you can't generate the noise in lua. As far as pure math goes, lua is about half the speed of C, and you wouldn't have to wait for the game to format a table full of data, so the result wouldn't be all that slow.
Believe in people and you don't need to believe anything else.
 

sirrobzeroone
Member
 
Posts: 106
Joined: Mon Jul 16, 2018 07:56

Re: Post your mapgen questions here (modding or engine)

by sirrobzeroone » Wed Jun 26, 2019 05:22

Thanks Duane and for the info on performance, that was my main concern with a diy option was to bigger performance hit but i can live with 50%-ish slower.
 

sirrobzeroone
Member
 
Posts: 106
Joined: Mon Jul 16, 2018 07:56

Re: Post your mapgen questions here (modding or engine)

by sirrobzeroone » Fri Jun 28, 2019 10:19

Just playing around with Noise23 to wrap my headaround how this works.

I think I'm understanding, however inside the code:
Code: Select all
   local chulens3d = {x=sidelen, y=sidelen+17, z=sidelen}   
   nobj_terrain = nobj_terrain or minetest.get_perlin_map(np_terrain, chulens3d )

Why is 17 added to the Y axis? I can see both X and Z = 80 or whatever your mapchunk size is. However why does the Y axis get a magical 17 added to it? I tried dropping the +17 but then get a failure lower down at:

Code: Select all
   local ni3d = 1
....
....
            local n_terrain = nvals_terrain[ni3d]
            local grad = (YZERO - y) / TERSCA
            local density = n_terrain + grad


So I can see its essential but I cant grasp why we need such a large overlap on the Y axis for noise, I also did intresting things like add more than 17 and set all the numbers up which resulted in some interesting outcomes. However given a mapblock is 16x16x16 and this a +17 Im guessing it relates somehow.

I did check out the example on the wiki and no 17s added there but Im not convinced thats working code. Im also slightly baffled as I thought with 3d noise one value represented density or is minetest a bit different in implimentation?

Thanks again for the help, I'm starting from a very low base of knowledge but reading as much as I can but the 17 has me stumped......

Edit: I still don't udnerstand why that 17 is added, but I've worked up basic example from scratch and no 17s so guessing its somethign special for noise23. Still would like to know :)
 

sirrobzeroone
Member
 
Posts: 106
Joined: Mon Jul 16, 2018 07:56

Re: Post your mapgen questions here (modding or engine)

by sirrobzeroone » Sun Jun 30, 2019 04:34

Can I just confirm that chunks are generated by the map gen from the most negative x,y,z coordinate first to the most positive x,y,z coordinate last or as a rough picy of a chunk (sorry I wasn't going to draw 80 little cubes...):

Image

Just finding the wiki a little unclear as it uses the terms forwards and back 1 side length, were as I think of it more as simply moving more positive along each axis in order of X first then Y then lastly Z. I did output a bunch of data to debug and it appears to function that way - anyways please let me know if I've got this right or not:

https://dev.minetest.net/PerlinNoiseMap

end
--go back, one side_length
perlin_index = perlin_index - side_length
end
--go forward, one side_length
perlin_index = perlin_index + side_length


Thanks for confirming
Attachments
Chunk.png
(279.79 KiB) Not downloaded yet
 

User avatar
duane
Member
 
Posts: 1523
Joined: Wed Aug 19, 2015 19:11
Location: Oklahoma City
GitHub: duane-r

Re: Post your mapgen questions here (modding or engine)

by duane » Sun Jun 30, 2019 04:50

sirrobzeroone wrote: Why is 17 added to the Y axis?


The +17 is necessary because Paramat is requesting more noise than the chunk requires. Further down, you'll see that data is only placed in the chunk. However, he's making sure that he doesn't place sand or water over an open space below the chunk, and that he doesn't place grass at the top if there's dirt above it. Grass should only show on the top-most node in dirt, and enough falling sand or water can can crash your server.
Believe in people and you don't need to believe anything else.
 

User avatar
duane
Member
 
Posts: 1523
Joined: Wed Aug 19, 2015 19:11
Location: Oklahoma City
GitHub: duane-r

Re: Post your mapgen questions here (modding or engine)

by duane » Sun Jun 30, 2019 05:32

sirrobzeroone wrote:Can I just confirm that chunks are generated by the map gen from the most negative x,y,z coordinate first to the most positive x,y,z coordinate last or as a rough picy of a chunk (sorry I wasn't going to draw 80 little cubes...)


Your question confuses me, because in my experience, chunk generally refers to a chunk of terrain, not anything to do with a noise map.

If you're asking what order terrain chunks are generated in, that depends on where the players are and where they are looking. There is no fixed order, and the mapgen must be able to produce them in any order.

If you're asking what order nodes are placed within chunks, that depends on the mapgen. There's no required order, but usually a loop runs from the mathematically least coordinate to the greatest in each axis. However, valleys runs from the highest Y value to the lowest.

It sounds like you just want to know how to pull data out of (or put it into) a flat noise map. The best way to answer that is to show you the formula to get the data. The order the noise is generated in is sort of meaningless:

index_3d = z * csize.y * csize.x + y * csize.x + x + 1
index_2d = z * csize.y + y + 1

Note that lua arrays are 1-based (so +1), and the game uses x, y for 2d noises, even though the Y coordinate of the noise is usually used as the Z coordinate of the terrain. The csize values are nearly always 80 in each axis, and the x, y, and z values are relative to the minimum coordinates you specified when you asked for the noise, so 0 <= (x|y|z) <= 80.

As you can see, the most significant axis is Z. The least significant is X. So when I read or write terrain data, I could loop through z, then y, then request the index of the (minimum_x, y, z) coordinate, then add one each time I loop through x.

Code: Select all
-- get data from voxelmanip
local data = vm:get_data(m_data)
local index_noise = 1
for z = minp.z, maxp.z do
   for y = minp.y, maxp.y do
      -- terrain data is usually larger than one chunk
      local index_terrain = area:index(minp.x, y, z)
      for x = minp.x, maxp.x do
         data[index_terrain] = get_data_from_noise(noise[index_noise])
         index_terrain = index_terrain + 1
         -- noise data can be exactly the size of the chunk
         --  so all you'd have to do is increment
         index_noise = index_noise + 1
      end
   end
end


Frequently, mapgens want to stack terrain nodes from the bottom to the top of each column, so they have to use a more confusing loop structure:

Code: Select all
-- get data from voxelmanip
local data = vm:get_data(m_data)
for z = minp.z, maxp.z do
   for x = minp.x, maxp.x do
      local index_noise = z * csize.y * csize.x + (0 * csize.x) + x + 1
      local index_terrain = area:index(x, minp.y, z)
      for y = minp.y, maxp.y do
         data[index_terrain] = get_data_from_noise(noise[index_noise])
         index_terrain = index_terrain + area.ystride
         index_noise = index_noise + csize.x
      end
   end
end


"area.ystride" is the amount you need to add to get the index of the next node up from your current index.
Last edited by duane on Mon Jul 01, 2019 01:57, edited 1 time in total.
Believe in people and you don't need to believe anything else.
 

Kilarin
Member
 
Posts: 774
Joined: Mon Mar 10, 2014 00:36

Re: Post your mapgen questions here (modding or engine)

by Kilarin » Sun Jun 30, 2019 16:59

its stupid question time again!

Here is an example of a register_decoration from default that passes noise:
Code: Select all
minetest.register_decoration({
      name = "default:cactus",
      deco_type = "simple",
      place_on = {"default:desert_sand"},
      sidelen = 16,
      noise_params = {
         offset = -0.012,
         scale = 0.024,
         spread = {x = 100, y = 100, z = 100},
         seed = 230,
         octaves = 3,
         persist = 0.6
      },
      y_max = 30,
      y_min = 1,
      decoration = "default:cactus",
      height = 3,
           height_max = 4,
   })


My assumption is that the way this works is minetest uses the noise to determine where the decorations go instead of just random numbers. This should result in decorations that appear in clumps and patterns as determined by the noise. (and that is what I seem to observe in the default map decorations)

BUT, you will notice, nowhere is a THRESHOLD value set. Somewhere I assume that minetest generates the noise, and then says "if nval<0 placedecoration", or something like that. Since no threshold value is set, I'm guessing it is just a hard coded threshold in minetest.

But here my lack of c coding experience is hurting. I tried to dig through the minetest code to find out how the decorations with noise were generated, and the code did not seem to answer my question. I assume it is happening here? https://github.com/minetest/minetest/blob/b298b0339c79db7f5b3873e73ff9ea0130f05a8a/src/mapgen/mg_decoration.cpp
but I got lost.

So, could someone explain to me how minetest uses the noise passed in register_decoration to generate decorations? Most specifically, is it just based on a threshold value, and if so, what is that value?

Thank you.
 

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

Re: Post your mapgen questions here (modding or engine)

by ShadMOrdre » Sun Jun 30, 2019 23:18

There are no stupid questions.

I prefer to use the sidelen and fill_ratio methods.

As for threshold value, I would assume 0. Noise values higher get placed, lower, not placed.

A better way to determine this, if no one has an answer, is to create a very simple noise, with low octaves, and play with the values to see how it affects the decoration distribution. Unfortunately, I don't think the decoration manager gives much feedback as for getting a specific noise value at a specific position. However, you can recreate the noise using minetest.get_perlin, and iterate through that noise set, using current position as the index into the noise, and see if there is any correlation.

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

User avatar
duane
Member
 
Posts: 1523
Joined: Wed Aug 19, 2015 19:11
Location: Oklahoma City
GitHub: duane-r

Re: Post your mapgen questions here (modding or engine)

by duane » Mon Jul 01, 2019 02:13

Kilarin wrote:So, could someone explain to me how minetest uses the noise passed in register_decoration to generate decorations? Most specifically, is it just based on a threshold value, and if so, what is that value?


I can do better than that, I can link the source.

As you can see, it's not quite as simple as greater than zero. The noise value at the center of the current area that's being filled (determined by sidelen, and usually smaller than a chunk) becomes the fill_ratio, which is multiplied by the area in question to get the number of decorations to put in that area or the chance of a decoration in that area if less than one. If the noise/fill ends up being 10 or greater, decorations are placed over every available node.

The game doesn't consider each location and decide if it gets a decoration. Instead, it figures out how many it wants to place in a section, then tries to place that many (but may not succeed). This is much faster.
Believe in people and you don't need to believe anything else.
 

Kilarin
Member
 
Posts: 774
Joined: Mon Mar 10, 2014 00:36

Re: Post your mapgen questions here (modding or engine)

by Kilarin » Mon Jul 01, 2019 02:42

ShadMOrdre wrote:A better way to determine this, if no one has an answer, is to create a very simple noise, with low octaves, and play with the values to see how it affects the decoration distribution.

good point.

duane wrote:As you can see, it's not quite as simple as greater than zero

Thank you for your explanation. I looked at that code, I got my son who codes in c to look at that code, and both of us were confused about what it was actually trying to do. With your explanation, it makes sense.
 

sirrobzeroone
Member
 
Posts: 106
Joined: Mon Jul 16, 2018 07:56

Re: Post your mapgen questions here (modding or engine)

by sirrobzeroone » Mon Jul 01, 2019 07:28

Duane, also thank you for the detailed reply it has helped immensely
 

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Wed Jul 03, 2019 00:58

StarNinjas wrote:Paramat is there a way to create highland pools (as in your mod) but that work well with mg7?

I recommend Sokomine's approach, which uses some clever heightmap analysis to work. My 'highlandpools' mod is quite old and uses a simpler and probably not so clever method. It also needs updating to cope with the newer biome nodes.
However, 'highlandpools' will work with any mapgen, it may not work well in mgv7 because that mapgen creates quite smooth terrain, with few depressions, but then, that problem will affect Sokomine's method too.
 

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Wed Jul 03, 2019 01:09

sirrobzeroone wrote:However is it possible to manual specify the generation of noise map using custom settings then generate the perlin noise map as per normal then subtract the two images one from the other. Providing a new single map image which would then be used to generate the terrain as required? I dont think this is possible as via lua we don't seem to have access to the ability to merge/blend but rather the data is dumped out of the function in a pre-tabled format.

Is the resulting noise for use in a core mapgen or in your own Lua mapgen?

There isn't a dedicated noise merging/blending API but you can program this in Lua.
Once you generate the 2 perlin maps you can create a 3rd table that combines them however you want.
 

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Wed Jul 03, 2019 01:14

sirrobzeroone wrote:Just playing around with Noise23 to wrap my headaround how this works.Why is 17 added to the Y axis? I can see both X and Z = 80 or whatever your mapchunk size is. However why does the Y axis get a magical 17 added to it?

This is just a clever thing done in this Lua mapgen to analyse the terrain below each generated mapchunk in order to determine whether biome surface nodes above are properly supported by stone.
Due to this cleverness the mod is not suitable as a simple introduction to Lua mapgen coding, for that see https://forum.minetest.net/viewtopic.php?f=18&t=19836
 

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Wed Jul 03, 2019 01:18

sirrobzeroone wrote:Can I just confirm that chunks are generated by the map gen from the most negative x,y,z coordinate first to the most positive x,y,z coordinate last or as a rough picy of a chunk (sorry I wasn't going to draw 80 little cubes...):

Yes your image is correct, MT C++ code and the core mapgens always progress through 3D volumes of nodes in X Y Z order. Lua mapgens often do otherwise according to need.
Last edited by paramat on Wed Jul 03, 2019 01:42, edited 1 time in total.
 

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

Re: Post your mapgen questions here (modding or engine)

by paramat » Wed Jul 03, 2019 01:31

Duane is correct about how noise is used in decoration placement.
The decorations are actually positioned randomly (that is, just using a simple pseudorandom number generator), the noise determines how many are randomly placed in each subdivision of a mapchunk (each subdivision is an area sidelen * sidelen nodes in size).
The advantage is that, for example, if sidelen is 16, there are 5 * 5 subdivisions in a mapchunk. so only 5 * 5 = 25 noise values have to be calculated, instead of 80 * 80 = 6400.

It's essentially noise determining the 'fill ratio' for each subdivision of a mapchunk, the size of the subdivisions is set by sidelen.

So also, sidelen determines the resolution of the decoration density variation. Higher density decorations require smaller values of sidelen (like 4 or 8) to avoid the density variation having a 'square-edged' appearance.
 

Kilarin
Member
 
Posts: 774
Joined: Mon Mar 10, 2014 00:36
 

sirrobzeroone
Member
 
Posts: 106
Joined: Mon Jul 16, 2018 07:56

Re: Post your mapgen questions here (modding or engine)

by sirrobzeroone » Sun Jul 07, 2019 06:26

Kilarin wrote:Thank you for the further details paramat!


Likewise really appreciated :)
 

Extex
Member
 
Posts: 82
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

Re: Post your mapgen questions here (modding or engine)

by Extex » Mon Jul 08, 2019 18:13

How would I make a mapgen that is entirely large caves like at -700 in Minetest game
All the way up and all the way down
Player of PK, RIP. Creator of the light_tool mod. Working on another mod which is pretty cool so far
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 3 guests