sbrl / Minetest-WorldEditAdditions

Extra tools and commands to extend WorldEdit for Minetest
https://worldeditadditions.mooncarrot.space/
Mozilla Public License 2.0
16 stars 3 forks source link

Noise fields #17

Open sbrl opened 4 years ago

sbrl commented 4 years ago

It would be very cool indeed to expose Minetest's inbuilt noise primitives in a practical worldeditadditions command.

The API documentation can be found here: https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L6305

We could have 2 commands: 1 that operates in 2D (e.g. a heightmap), and 1 that operates in 3d (e.g. caves / blobs / sky islands etc). It's probably best to consider them both separately.

Let's think about the 2D version first. We'd want to expose the all the interesting parameters in a command (maybe //noise? it would fit what we've done with //maze if we later added //made3d).

We'd also perhaps want to add the ability to perturb the existing heightmap by a percentage or something to allow for both altering existing terrain, and layering multiple different kinds of noise to make fractals.

Speaking of, if we design the syntax right we should be able to allow for defining multiple kinds of noise at the same time that we can layer together in a single command to allow for easier complex fractal noise.

In the future we might want to add new different noise functions too, so maybe adding room for that would be worth doing too (though we want to make the invocation concise, so specifying the noise function should be optional and default to the inbuilt Minetest perlin noise).

VorTechnix commented 3 years ago

The question is can you scale the 3d noise? If you want to use it for teeth of time then you want very fine noise to eliminate a few blocks here and there and not the cave generating scale of noise that would remove whole buildings at a time.

sbrl commented 3 years ago

Yeah, we should be able to. Minetest's inbuilt version definitely can, but unfortunately I can't make heads or tails of the documentation, so I'm having to look at sourcing a pure Lua version. I did this yesterday and committed it just now, but it's untested as I'm just taking my first proper forays into metatables to properly instance the generator.

It's really just a bunch of maths to scale it. If you've done algebra before, it's that kinda principle. I intend to implement a table of properties to control it.

Eventually I want to add noise implementations for a number of different noise functions (e.g. OpenSimplex, Worley, , but I'll probably have to port them from my earlier C♯ project NoiseBox I'd guess if I can't find an implementation elsewhere to steal borrow.

The current goal is to get the noise engine setup first and make sure it's functioning as intended. Then we can build it out.

sbrl commented 3 years ago

Ok, so we have a system that kinda works - realistically we need to port something like OpenSimplex to Lua to get anything that looks good. I suggest here that we first port it on it's own in isolation (like I did with the maze algorithm), and then once we've confirmed it works fold it into Minetest (it really is a pain how Minetest has so many restrictions such as the inability to use require(), and being stuck on Lua 5.1 when the latest version 5.4, etcc).

sbrl commented 2 years ago

//noiseapply2d is now a thing! Now for //noiseapply3d.....