[Mod] Mapgen framework/example [0.2.0] [noise23]

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

[Mod] Mapgen framework/example [0.2.0] [noise23]

by paramat » Fri Feb 21, 2014 09:40

Image


Download and rename to noise23 https://github.com/paramat/noise23/archive/master.zip
Browse code https://github.com/paramat/noise23

noise23 0.2.0 by paramat
For Minetest 0.4.11 and later
Depends default
License: code WTFPL

Minetest 0.4.11 rewrite with the new noise features and all the corrections and optimisations i recently learned from hmmmm.
Now 3 simple biomes: grassland, desert and tundra.
16 nodes of perlinmap overgeneration to minimise mapchunk border glitches.
Last edited by paramat on Sat Feb 14, 2015 09:41, edited 5 times in total.
 

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

by paramat » Fri Feb 21, 2014 12:24

Bugfix, duh ...
Last edited by paramat on Fri Feb 21, 2014 14:08, edited 1 time in total.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by 4aiman » Sun Apr 20, 2014 09:41

Amazing :)

Hey, paramat, would it be hard to create a pure lua mapgen that would behave like mapgen_v7 in terms of API?

What I mean here is ability to use functions like lua_mapgen.register_biome(...) that would work similar to minetest.register_biome.

Regards!
 

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

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by paramat » Mon Apr 21, 2014 00:56

Hi, yeah hard for me but totally possible, although it doesn't interest me much at the moment.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by 4aiman » Tue Apr 22, 2014 08:16

Oh, don't worry, I was curious - that's all. Currently I've fixed my issues with MGv7 by delaying LVM's stuff.

PS: too bad we stil unable to like someone's posts...
 

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

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by paramat » Tue Apr 22, 2014 11:16

Yep MGV7 is the one to use for lua API, there's not much point in me trying to compete with it :)
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by 4aiman » Wed Apr 23, 2014 08:20

It's not about competition :)
Should the api be more specific I wouldn't have to think for any other possibility.
I was so frustrated when saw that any function that adds ores or creates terrains runs prior to creating caves and tunnels. So even if I wanted to split realms with "undiggable" nodes I couldn't. It took me some time to realize that such behavior is not the part of some mod.

But in the end, minetest.after() did the trick for me. It's good that LVM could be used anytime I want. I even fixed /spawn command to search for a surface using LVM :)
Too bad I still can't figure out how many nodes can be loaded and processed simultaneously...
 

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

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by paramat » Wed Apr 23, 2014 14:21

You can actually stop caves removing particular nodes (in MGV6 and MGV7) by adding:
is _ground_content = false
to the node definition (meaning 'this node is not part of the ground so shouldn't be removed by cavegen) this was a change i requested.
Because lua is slow i have to keep my mods and mapgens (relatively) simple for a reasonable speed, if i wrote a mapgen with a biome API that out-performed MGV7 it would be too slow for most people.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by 4aiman » Wed Apr 23, 2014 19:02

paramat wrote:You can actually stop caves removing particular nodes (in MGV6 and MGV7) by adding:
is _ground_content = false

Thanks! Guess I have to update my local lua_api.txt :)

paramat wrote:If i wrote a mapgen with a biome API that out-performed MGV7 it would be too slow for most people.

True...

I've tried to tamper with LVM but have a lot of questions...
Could you help me?
For example, I wanted to make your realm be lower than it was. I've changed YMIN and YMAX to 700 but I got nothing at Y=700 within a square kilometer. I've reset map but got nothing again. Restored those values back to near 7000 and got a realm at Y~=7000.

Or, if I want to change one of your biomes to smth different, then I need to change
Code: Select all
data[vi] = c_n23destone
to a different content_id? What about filler?
I mean the top node should differ from the beneath ones - how can I make that?
 

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

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by paramat » Wed Apr 23, 2014 21:00

YMIN and YMAX need to differ by at least 80-160 nodes for anything to generate, YMIN is the realm base and YMAX is the top of the atmosphere and where mountains will get chopped off. TERCEN and YWATER then should be inbetween those 2 values.
To change nodes for example:
Code: Select all
local c_sandstone = minetest.get_content_id("default:sandstone")

Code: Select all
data[vi] = c_sandstone

This mod doesn't do filler and surface material but can do so easily using 'density' to define layers of material underground, this is the advantage of 3D noise mapgen compared to the mostly 2D noise mapgen of MGV6 and MGV7, MGV5 was 3D noise but 3D noise was much slower back then, which is why MGV6 uses 2D noise.

I think the 'is ground content' feature is not yet documented in the lua-api.txt, that needs to be done.
 

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

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by paramat » Thu Apr 24, 2014 00:04

To make biome 2 dirt with a single surface node of grass, add the lines below marked by '-- *' (code untested). An 'under' table is added which stores the biome number of the previous fine material node added in each vertical column. 'if density < 0 and under ~= 0 then' checks for air immediately above a fine material node, and 'data[viu] = c_grass' places a surface node underneath that air node, replacing the existing dirt node.
Code: Select all
   local c_dirt = minetest.get_content_id("default:dirt") -- *
   local c_grass = minetest.get_content_id("default:dirt_with_grass") -- *
   
   local sidelen = x1 - x0 + 1
   local chulens = {x=sidelen, y=sidelen, z=sidelen}
   local minposxyz = {x=x0, y=y0, z=z0}
   local minposxz = {x=x0, y=z0}
   
   local nvals_terrain = minetest.get_perlin_map(np_terrain, chulens):get3dMap_flat(minposxyz)
   local nvals_biome = minetest.get_perlin_map(np_biome, chulens):get2dMap_flat(minposxz)
   
   local nixyz = 1 -- 3D noise index
   local nixz = 1 -- 2D noise index
   local stable = {}
   local under = {} -- *
   for z = z0, z1 do
      for x = x0, x1 do
         local si = x - x0 + 1
         under[si] = 0 -- *
         local nodename = minetest.get_node({x=x,y=y0-1,z=z}).name
         if nodename == "air"
         or nodename == "default:water_source" then
            stable[si] = 0
         else
            stable[si] = STABLE
         end
      end
      for y = y0, y1 do
         local vi = area:index(x0, y, z)
         local viu = area:index(x0, y-1, z) -- *
         for x = x0, x1 do
            local si = x - x0 + 1
            local grad = (TERCEN - y) / TERSCA
            local density = nvals_terrain[nixyz] + grad
            local n_biome = nvals_biome[nixz] -- biome noise for node
            local biome = false -- set biome id to undefined
            if n_biome > 0.46 + math.random() * 0.04 then -- set biome id
               biome = 3
            elseif n_biome < -0.5 + math.random() * 0.04 then
               biome = 1
            else
               biome = 2
            end
            if density >= TSTONE then
               if biome == 3 then
                  data[vi] = c_n23destone
               else -- biomes 1 and 2
                  data[vi] = c_n23stone
               end
               stable[si] = stable[si] + 1
               under[si] = 0 -- *
            elseif density >= 0 and density < TSTONE and stable[si] >= 2 then
               if y <= YWATER + 3 then
                  data[vi] = c_sand
                  under[si] = 0 -- *
               elseif biome == 3 then
                  data[vi] = c_desand
                  under[si] = 3 -- *
               elseif biome == 1 then
                  data[vi] = c_flosand
                  under[si] = 1 -- *
               else -- biome = 2
                  data[vi] = c_dirt -- *
                  under[si] = 2 -- *
               end
            elseif y <= YWATER then
               if biome == 1 and y >= YWATER - 3 then
                  data[vi] = c_ice
               else -- biomes 2 and 3
                  data[vi] = c_water
               end
               stable[si] = 0
               under[si] = 0 -- *
            elseif density < 0 and under[si] ~= 0 then -- *
               if under[si] = 2 then -- *
                  data[viu] = c_grass -- *
               end -- *
               under[si] = 0 -- *
            else
               data[vi] = c_air
               stable[si] = 0
               under[si] = 0 -- *
            end
            nixyz = nixyz + 1 -- increment 3D noise index
            nixz = nixz + 1 -- increment 2D noise index
            vi = vi + 1
            viu = viu + 1 -- *
         end
         nixz = nixz - 80 -- rewind 2D noise index by 80 nodes for next x row above
      end
      nixz = nixz + 80 -- fast-forward 2D noise index by 80 nodes for next northward xy plane
   end
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47
 

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

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by paramat » Thu Apr 24, 2014 14:24

Yeah i know =}

Does that code work? if not post the error message.
 

User avatar
RHR
Member
 
Posts: 215
Joined: Mon Jan 27, 2014 20:07
GitHub: RHRhino

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by RHR » Wed Jul 09, 2014 18:22

paramat wrote:Does that code work?

Hey Paramat, your code works fine! Thank you very much, it is very usefull! I'm trying to customize this mod and add some new features, so I have some questions:
1) How can I add caves e.g. subterrain or just air pockets in the stone
2) Which parts of the mapgen need lots of performance or what should I avoid to keep the mapgen fast?
3) How can I repeat the area e.g. force it to spawn from -30,000 to -28,000 and repeat it every 2,000 nodes up to +30,000?
 

User avatar
Wuzzy
Member
 
Posts: 3241
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by Wuzzy » Wed Jul 09, 2014 19:17

Sorry, dude. I found some unstable sand:
Image
Coordinates and seed are in screenshot.

Edit. I have seen further cases where there is hanging sand. In all instances, the sand hangs at Y=7006. I hope this information helps.

Edit 2: OK, there is floating/hanging sand even at different heights:
Image
This is an interesting case. Here, there is a floating sand island; it is not connected to the main land at all. In the background, you can see more hanging sand and another floating island.
 

User avatar
HeroOfTheWinds
Member
 
Posts: 470
Joined: Wed Apr 23, 2014 23:16
Location: Hawaii
GitHub: HeroOfTheWinds
IRC: WindHero

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by HeroOfTheWinds » Wed Jul 09, 2014 22:41

If I were to guess, I would say that probably cave generation cut out the bottom after it was generated. That being said, it DOES look a little bit too clean cut for that...
Nam ex spatio, omnes res venire possunt.
Why let the ground limit you when you can reach for the sky?
Back to college now, yay for sophomore year schedules. :P
 

User avatar
Wuzzy
Member
 
Posts: 3241
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by Wuzzy » Thu Jul 10, 2014 02:02

I found the bug!
The problem lies in the stability detection:
Code: Select all
for z = z0, z1 do -- for each xy plane progressing northwards
for x = x0, x1 do
local si = x - x0 + 1
local nodename = minetest.get_node({x=x,y=y0-1,z=z}).name
if nodename == "air"
or nodename == "default:water_source" then
   stable[si] = 0
else
   stable[si] = STABLE
end
end

Looks OK, right? No. What if the node type is ignore? No wonder it was so clear cut, it was a typical MapBlock/chunk border (whatever) problem.

All that is needed for a fix is to check to check for ignore, too.
Code: Select all
local si = x - x0 + 1
local nodename = minetest.get_node({x=x,y=y0-1,z=z}).name
if nodename == "air"
or nodename == "ignore"
or nodename == "default:water_source" then
   stable[si] = 0
else
   stable[si] = STABLE
end

If the code doesn’t know what is below the node, I assume the worst (there is air or water below it), which is the safest choice. If the assumption was wrong, this is not a problem, just some sand is removed then.

Actually, the code could be even improved further. Why limit ourselves to default:water_source? We can generalize that by checking wheather the node is not walkable (=passable for falling nodes). default:water_source is not walkable, air is not walkable either, so I can merge it.
Code: Select all
local si = x - x0 + 1
local nodename = minetest.get_node({x=x,y=y0-1,z=z}).name
if nodename == "ignore"
or minetest.registered_nodes[nodename].walkable == false then
   stable[si] = 0
else
   stable[si] = STABLE
end


I tested it for myself on the screenshot positions. If you want to help, please test it for yourselves, too. Bring yourself to these positions and tell me wheather there is floating sand or not. For me, there was no more floating sand at these positions.
 

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

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by paramat » Fri Jul 11, 2014 00:31

HeroOfTheWinds nope, these happen on chunk borders.

Wuzzy thats exactly the cause, but it's intentional :) I put a check for ignore in there at first but removed it. When the upper chunk is generated first, the safe assumption you made creates horrible looking cutoffs in the sand, i much prefer the 'look' of the unsafe assumption and it's more fun to go around collapsing, or better have random collapse by ABM. The walls of sand from collapses are beautiful. Chunks are more often generated upwards when exploring on foot, you get to see more of this when flying though.
 

User avatar
Wuzzy
Member
 
Posts: 3241
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by Wuzzy » Fri Jul 11, 2014 03:50

>:-O You gotta me kidding me! In your first post you wrote that stability was a goal, now you tell me that you actually don’t care about this goal.
I think stability is a good thing and having a map gen which supports that is even better. If there is a lot of hanging sand and it all falls down because you dig one node, Minetest can slow down extremely. :-/
And I am yet to see “horrible cutoffs in the sand”. Pics (and coords and seed) or it didn’t happen. :P
 

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

Re: [Mod] Mapgen framework, 2D and 3D perlin noise [0.1.1] [

by paramat » Fri Jul 11, 2014 04:04

Heh, the cutoffs happen when generating chunks downwards, i might search out an example.

RHR, fixed parameter TERCEN defines average terrain level, so needs to become a variable 'tercen' that is rounded to the nearest realm layer. In the on-generated function change TERCEN to 'tercen' then insert this code at line 105:
Code: Select all
   local chulay = math.floor((minp.y + 32) / 80) -- chunk layer number, 0 = surface chunk
   local tercen = (math.floor(chulay / CHUINT) * CHUINT + CHUINT / 2) * 80 - 32 -- terrain centre of this realm layer

Where new parameter CHUINT is the vertical distance between realm layers measured in chunks (80 nodes).

For caves see my newest mod which does what you want. Add a 3D noise, define boolean 'nofis' (no fissure / no cave) then add a 'and nofis' in the line deciding whether to place stone.
 

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

Re: [Mod] Mapgen framework/example [0.2.0] [noise23]

by paramat » Sat Feb 14, 2015 09:41

Version 0.2.0
Minetest 0.4.11 rewrite with the new noise features and all the corrections and optimisations i recently learned from hmmmm.
Now 3 simple biomes: grassland, desert and tundra.
16 nodes of perlinmap overgeneration to minimise mapchunk border glitches.
 

User avatar
afflatus
Member
 
Posts: 317
Joined: Tue Apr 01, 2014 19:47
Location: Avalonia
GitHub: 0-afflatus
IRC: afflatus
In-game: afflatus

Re: [Mod] Mapgen framework/example [0.2.0] [noise23]

by afflatus » Sat Feb 14, 2015 12:04

Downloaded for study. Thank you!
Grailtest is dreaming ...
 


Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 8 guests