Page 1 of 1

[Mod] Mudflow mapgen [0.3.0] [stability]

PostPosted: Tue Feb 04, 2014 05:16
by paramat
Image


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

stability 0.3.0 by paramat
For Minetest 0.4.11 or later
Depends default
Licenses: Code WTFPL

Use in a singlenode mapgen world. You might spawn underground so disable damage before starting a world, then enable freemove, switch 'noclip' if necessary and fly to find the surface.
Currently a simple mapgen example / tutorial / framework for developing and demonstrating a new stability system that emulates mudflow while adding surface material. Simple concept: only place a biome node if supported by all 9 nodes directly below it, essentially limiting dirt/sand steepness to 45 degrees, creating a slight pyramid look to the surface.

PostPosted: Tue Feb 04, 2014 22:20
by Casimir
Fascinating. So little code and it works like a charm.

I already have a mod idea where this will be perfect for.

PostPosted: Tue Feb 04, 2014 23:10
by paramat
Cool, im happy it's useful. I might as a next step release an example mod that adds 2D noise for biomes, to show how to combine 2D 'per column' noise and 3D noise within the ZYX order mapgen loop, it's all to do with calculating 2D noise indexes.

PostPosted: Sun Feb 09, 2014 01:40
by paramat
Experimenting with this mod i had an idea to use an arctan density gradient instead of a linear one.

Basic 3D noise mapgen

Basic mapgen with 3D noise is done by calculating a sort-of density value for each node, then making that node solid if that value is above zero.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local grad = (TCEN - y) / GRAD
local density = nvals_terrain[ni] + grad

'density' is a combination of some 3D perlin noise and a linear density gradient 'grad' which decreases steadily (linearly) with altitude.
'grad' is what creates a land surface, if it wasnt there, the noise on it's own would create an asteroid field / floatlands type realm, if the noise wasnt there there would just be a completely flat world at y = TCEN, the average terrain level.
So the blend of the 2 creates rough terrain, at certain locations the 3D noise overpowers 'grad' to create overhangs and a few bits of floating terrain, likewise underground a few caves are formed near the surface, this is something that basic 2D noise mapgen cannot do.
Minetest mapgen V5 was in it's simplest form 3D noise plus gradient as described above.

Arctan density gradient

In my moonlet mod i had an idea to put positive and negative limits on 'grad', so that floatlands would continue to be generated throughout the atmosphere, and caves throughout the underground. These hard limits worked but the transitions sharp, i recently realised an arctan function is a smoothed version ideal for mapgen, near zero it is similar to the basic linear gradient, but then smoothly approaches the limits at roughly +/-1.5.

Image

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local grad = math.atan((TCEN - y) / GRAD) * 0.8
local density = nvals_terrain[nixyz] + grad

The * 0.8 can be adjusted to tune the number / size of the floatlands and caves.

PostPosted: Sun Feb 09, 2014 03:36
by paramat
Instead of separate code and extra perlin noises for floatlands, the normal mapgen creates floatlands as a seamless extension of the surface realm, with the advantages of simplicity and generation speed.

PostPosted: Fri Feb 21, 2014 08:16
by paramat
Version 0.2.0.
The stability table has been improved and now counts the number of consecutive stone nodes in a vertical column, and only places sand if there are 2 (or any other chosen number of) consecutive stone nodes below.
There are comments in the code to explain how it works.

PostPosted: Wed Mar 26, 2014 22:34
by paramat
Spillz, saw the discussion on IRC minetest about water, it might be because stability currently auto-sets water level to be on the edge of a 16x16x16mapblock, try changing the number at the end of this line
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
waty = (80 * math.floor((WATY + 32) / 80)) - 32 + 15

to something other than 15 or n*16 - 1. Perhaps if the water level is within a mapblock the surface might be drawn sooner.

I need to update this mod to use a dummy stone to avoid those aptched of grass and trees, i will also set water level within a mapblock.

PostPosted: Wed Mar 26, 2014 23:11
by spillz
Maybe. Dropping the underground filtering seemed to do the trick too.

http://irc.minetest.ru/minetest/2014-03-26#i_3630084

No obvious adverse effect on performance either (but maybe on network performance)

PostPosted: Thu Mar 27, 2014 00:02
by paramat
Okay i tried stability mod and got the same bugs as you: missing water surface with terrain behind. By looking down at the 16x16 areas of water animation i discovered the missing water surfaces are just over 64 nodes away from the player, as soon as you move within 64 nodes the surface appears, and the missing bits of underwater terrain appear too. Perhaps part of the problem is that the realm is at y = 7000?

PostPosted: Thu Mar 27, 2014 00:13
by paramat
Missing water surface is fixed for me by setting water surface to be within a 16^3 mapblock instead of at the mapblock border :) New version coming soon.

PostPosted: Thu Mar 27, 2014 01:10
by spillz
Your workaround does appear to fix the problem, but isn't this really an engine bug that should be fixed?

PostPosted: Thu Mar 27, 2014 01:12
by spillz
paramat wrote:Okay i tried stability mod and got the same bugs as you: missing water surface with terrain behind. By looking down at the 16x16 areas of water animation i discovered the missing water surfaces are just over 64 nodes away from the player, as soon as you move within 64 nodes the surface appears, and the missing bits of underwater terrain appear too. Perhaps part of the problem is that the realm is at y = 7000?


Btw, the 64 node limit is due to the below piece of code, which I dropped in my local copy and that made this issue much less prevalent too.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
                if(d >= 4)
                {
                    if(block->getDayNightDiff() == false)
                        continue;
                }
   

https://github.com/minetest/minetest/blob/master/src/clientiface.cpp#L279

PostPosted: Thu Mar 27, 2014 01:27
by paramat
So it seems a mapblock completely full of water has no 'daynightdiff' so is treated as underground and doesn't appear ... having air and water in the mapblock creates a daynightdiff so it appears. So yes this needs to be fixed, perhaps we could talk to hmmmm about it too, and whoever is the client/server dude.

EDIT
Version 0.2.1

PostPosted: Thu Mar 27, 2014 13:00
by pop_harte
i don't understand. what's that mod doing?

PostPosted: Thu Mar 27, 2014 13:02
by pop_harte
i don't understand. what's that mod doing?were.

PostPosted: Thu Mar 27, 2014 13:09
by spillz
Making a beautiful world of stone and sand (you need to teleport to elevation 7000 or thereabouts)

PostPosted: Thu Mar 27, 2014 22:07
by paramat
pop_harte, it's a simplified mapgen that is also a mapgen tutorial to show how this sand-stability system works, and also a mapgen framework that people (including myself) can use as a starting point, i actually use my 'noise23' mapgen as the starting point for many of my projects, because it has both 2D and 3D perlin noises.

PostPosted: Thu Mar 27, 2014 22:10
by spillz
Paramat: do you still have the grass generation issue if you use singlenode?

PostPosted: Thu Mar 27, 2014 22:48
by paramat
Haven't tested that yet, i expect singlenode would not add grass because default mapgen is disabled.

EDIT
The grass bug isn't much of a problem, as using the mod's own nodes is better mapgen practice anyway, it's just laziness that i use so many default: nodes.

Re: [Mod] Mudflow mapgen [0.3.0] [stability]

PostPosted: Sat May 21, 2016 08:11
by burli
Can someome please explain me what mudflow exactly is? I now it has something to do with chunk borders and moving dirt. But why and how?

Re: [Mod] Mudflow mapgen [0.3.0] [stability]

PostPosted: Sun May 22, 2016 03:29
by paramat
Mgv6 mudflow is different to this.

Re: [Mod] Mudflow mapgen [0.3.0] [stability]

PostPosted: Sun May 22, 2016 04:26
by paramat
Note with version 0.3.0 this mod has completely changed, see first post for details. All previous comments are not applicable to this code.