[Mod] Mudflow mapgen [0.3.0] [stability]

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

[Mod] Mudflow mapgen [0.3.0] [stability]

by paramat » Post

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.
Last edited by paramat on Mon Feb 16, 2015 23:57, edited 4 times in total.

User avatar
Casimir
Member
Posts: 1207
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

by Casimir » Post

Fascinating. So little code and it works like a charm.

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

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

by paramat » Post

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.

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

by paramat » Post

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.

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

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.

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

by paramat » Post

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.
Last edited by paramat on Mon Feb 16, 2015 23:57, edited 1 time in total.

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

by paramat » Post

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.

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

by paramat » Post

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

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.
Last edited by paramat on Wed Mar 26, 2014 22:36, edited 1 time in total.

spillz
Member
Posts: 138
Joined: Thu Feb 13, 2014 05:11

by spillz » Post

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)

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

by paramat » Post

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?

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

by paramat » Post

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.

spillz
Member
Posts: 138
Joined: Thu Feb 13, 2014 05:11

by spillz » Post

Your workaround does appear to fix the problem, but isn't this really an engine bug that should be fixed?
Last edited by spillz on Thu Mar 27, 2014 01:10, edited 1 time in total.

spillz
Member
Posts: 138
Joined: Thu Feb 13, 2014 05:11

by spillz » Post

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.

Code: Select all

                if(d >= 4)
                {
                    if(block->getDayNightDiff() == false)
                        continue;
                }
    
https://github.com/minetest/minetest/bl ... e.cpp#L279
Last edited by spillz on Thu Mar 27, 2014 01:13, edited 1 time in total.

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

by paramat » Post

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
Last edited by paramat on Thu Mar 27, 2014 01:39, edited 1 time in total.

User avatar
pop_harte
Member
Posts: 27
Joined: Sun Mar 23, 2014 07:39

by pop_harte » Post

i don't understand. what's that mod doing?

User avatar
pop_harte
Member
Posts: 27
Joined: Sun Mar 23, 2014 07:39

by pop_harte » Post

i don't understand. what's that mod doing?were.

spillz
Member
Posts: 138
Joined: Thu Feb 13, 2014 05:11

by spillz » Post

Making a beautiful world of stone and sand (you need to teleport to elevation 7000 or thereabouts)

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

by paramat » Post

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.

spillz
Member
Posts: 138
Joined: Thu Feb 13, 2014 05:11

by spillz » Post

Paramat: do you still have the grass generation issue if you use singlenode?

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

by paramat » Post

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.
Last edited by paramat on Fri Mar 28, 2014 02:03, edited 1 time in total.

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

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

by burli » Post

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?

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

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

by paramat » Post

Mgv6 mudflow is different to this.

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

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

by paramat » Post

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.

User avatar
Codesound
Member
Posts: 365
Joined: Thu Jun 09, 2016 14:56

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

by Codesound » Post

paramat wrote: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.
Beautiful, I love this mod!!!!

thanks for all your work!

R

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 26 guests