mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 07:23:00 +00:00
//erode river: Update docs,rename some parameters for consistency
This commit is contained in:
parent
af1c1decb0
commit
9b53b73bc9
4 changed files with 39 additions and 9 deletions
|
@ -15,6 +15,7 @@ Note to self: See the bottom of this file for the release template text.
|
|||
- `//torus`, `//hollowtorus`: Add optional new axes
|
||||
- `//torus`: Add optional hollow keyword
|
||||
- `//multi`: Add curly brace syntax for nesting command calls ([more information](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#multi-command_a-command_b-command_c-))
|
||||
- `//erode`: Add new `river` erosion algorithm for filling in potholes and removing pillars
|
||||
|
||||
### Bugfixes
|
||||
- `//overlay`: Don't place nodes above water
|
||||
|
|
|
@ -408,14 +408,17 @@ The sigma value is only applicable to the `gaussian` kernel, and can be thought
|
|||
//convolve gaussian 5 0.2
|
||||
```
|
||||
|
||||
## `//erode [<snowballs|...> [<key_1> [<value_1>]] [<key_2> [<value_2>]] ...]`
|
||||
## `//erode [<snowballs|river> [<key_1> [<value_1>]] [<key_2> [<value_2>]] ...]`
|
||||
Runs an erosion algorithm over the defined region, optionally passing a number of key - value pairs representing parameters that are passed to the chosen algorithm. This command is **experimental**, as the author is currently on-the-fence about the effects it produces.
|
||||
|
||||
Works best if you run `//fillcaves` first, or otherwise have no air nodes below the top non-air node in each column.
|
||||
|
||||
Currently implemented algorithms:
|
||||
|
||||
Algorithm | Mode | Description
|
||||
------------|-------|-------------------
|
||||
`snowballs` | 2D | The default - based on [this blog post](https://jobtalle.com/simulating_hydraulic_erosion.html). Simulates snowballs rolling across the terrain, eroding & depositing material. Then runs a 3x3 gaussian kernel over the result (i.e. like the `//conv` / `//smoothadv` command).
|
||||
`river` | 2D | Fills in potholes and lowers pillars using a cellular automata-like algorithm that analyses the height of neighouring columns.
|
||||
|
||||
Usage examples:
|
||||
|
||||
|
@ -431,7 +434,7 @@ Each of the algorithms above have 1 or more parameters that they support. These
|
|||
Based on the algorithm detailed in [this blog post](https://jobtalle.com/simulating_hydraulic_erosion.html) ([direct link to the source code](https://github.com/jobtalle/HydraulicErosion/blob/master/js/archipelago/island/terrain/erosionHydraulic.js)), devised by [Job Talle](https://jobtalle.com/).
|
||||
|
||||
Parameter | Type | Default Value | Description
|
||||
--------------------|-----------|-------------------|------------------------
|
||||
--------------------|-----------|-------------------|--------------------------
|
||||
rate_deposit | `float` | 0.03 | The rate at which snowballs will deposit material
|
||||
rate_erosion | `float` | 0.04 | The rate at which snowballs will erode material
|
||||
friction | `float` | 0.07 | More friction slows snowballs down more.
|
||||
|
@ -444,8 +447,34 @@ maxdiff | `float` | 0.4 | The maximum difference in height (between 0 and
|
|||
count | `float` | 25000 | The number of snowballs to simulate.
|
||||
noconv | any | n/a | When set to any value, disables to automatic 3x3 gaussian convolution.
|
||||
|
||||
Example invocations:
|
||||
|
||||
```
|
||||
//erode
|
||||
//erode snowballs
|
||||
//erode snowballs count 50000
|
||||
```
|
||||
|
||||
If you find any good combinations of these parameters, please [open an issue](https://github.com/sbrl/Minetest-WorldEditAdditions/issues/new) (or a PR!) and let me know! I'll include good combinations here, and possibly add a presets feature too.
|
||||
|
||||
### Algorithm: `river`
|
||||
Ever been annoyed by small 1 wide holes or thin pillars all over the place? This command is for you! Does not operate on the very edge of the defined region, because the algorithm can't see the neighbours of those columns.
|
||||
|
||||
Parameter | Type | Default Value | Description
|
||||
--------------------|-----------|-------------------|--------------------------
|
||||
steps | `integer` | 1 | The number of rounds or passes of the algorithm to run. Useful since if you have a 1x3 hole for instance, it will take at least 2 steps to fill it in - and more if it's deeper than 1 node.
|
||||
lower_sides | `string` | 4,3 | Comma separated list of numbers. Columns with this many sides lower than it will be lowered in height by 1 node.
|
||||
raise_sides | `string` | 4,3 | Comma separated list of numbers. Columns with this many sides higher than it will be raised in height by 1 node.
|
||||
doraise | `boolean` | true | Whether to raise columns in height. If false, then no columns will be raised in height even if they are eligible to be so according to `raise_sides`.
|
||||
dolower | `boolean` | true | Whether to lower columns in height. If false, then no columns will be lowered in height even if they are eligible to be so according to `lower_sides`.
|
||||
|
||||
Example invocations:
|
||||
|
||||
```
|
||||
//erode river
|
||||
//erode river steps 10
|
||||
```
|
||||
|
||||
|
||||
## `//count`
|
||||
Counts all the nodes in the defined region and returns the result along with calculated percentages (note that if the chat window used a monospace font, the returned result would be a perfect table. If someone has a ~~hack~~ solution to make the columns line up neatly, please [open an issue](https://github.com/sbrl/Minetest-WorldEditAdditions/issues/new) :D)
|
||||
|
|
|
@ -48,7 +48,7 @@ The detailed explanations have moved! Check them out [here](https://github.com/s
|
|||
- [`//layers [<node_name_1> [<layer_count_1>]] [<node_name_2> [<layer_count_2>]] ...`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#layers-node_name_1-layer_count_1-node_name_2-layer_count_2-)
|
||||
- [`//fillcaves [<node_name>]`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#fillcaves-node_name)
|
||||
- [`//convolve <kernel> [<width>[,<height>]] [<sigma>]`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#convolve-kernel-widthheight-sigma)
|
||||
- [`//erode [<snowballs|...> [<key_1> [<value_1>]] [<key_2> [<value_2>]] ...]`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#erode-snowballs-key_1-value_1-key_2-value_2-) **experimental**
|
||||
- [`//erode [<snowballs|river> [<key_1> [<value_1>]] [<key_2> [<value_2>]] ...]`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#erode-snowballs-river-key_1-value_1-key_2-value_2-) **experimental**
|
||||
|
||||
### Flora
|
||||
- [`//bonemeal [<strength> [<chance>]]`](https://github.com/sbrl/Minetest-WorldEditAdditions/blob/main/Chat-Command-Reference.md#bonemeal-strength-chance)
|
||||
|
|
|
@ -14,16 +14,16 @@ end
|
|||
function worldeditadditions.erode.river(heightmap_initial, heightmap, heightmap_size, region_height, params_custom)
|
||||
local params = {
|
||||
steps = 1, -- Number of rounds/passes of the algorithm to run
|
||||
remove_sides = "4,3", -- Cells with this many adjacent horizontal neighbours that are lower than the current pixel will be removed
|
||||
fill_sides = "4,3", -- Cells with this many adjacect horizontal neighbours that are higher than the current pixel will be filled in
|
||||
lower_sides = "4,3", -- Cells with this many adjacent horizontal neighbours that are lower than the current pixel will be removed
|
||||
raise_sides = "4,3", -- Cells with this many adjacect horizontal neighbours that are higher than the current pixel will be filled in
|
||||
doraise = true, -- Whether to do raise operations or not
|
||||
dolower = true -- Whether to do lower operations or not
|
||||
}
|
||||
-- Apply the custom settings
|
||||
wea.table_apply(params_custom, params)
|
||||
|
||||
params.remove_sides = parse_sides_list(params.remove_sides)
|
||||
params.fill_sides = parse_sides_list(params.fill_sides)
|
||||
params.lower_sides = parse_sides_list(params.lower_sides)
|
||||
params.raise_sides = parse_sides_list(params.raise_sides)
|
||||
|
||||
local timings = {}
|
||||
local filled = 0
|
||||
|
@ -80,14 +80,14 @@ function worldeditadditions.erode.river(heightmap_initial, heightmap, heightmap_
|
|||
local action = "none"
|
||||
if not isedge then
|
||||
if sides_higher > sides_lower then
|
||||
for i,sidecount in ipairs(params.fill_sides) do
|
||||
for i,sidecount in ipairs(params.raise_sides) do
|
||||
if sidecount == sides_higher then
|
||||
action = "fill"
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
for i,sidecount in ipairs(params.remove_sides) do
|
||||
for i,sidecount in ipairs(params.lower_sides) do
|
||||
if sidecount == sides_lower then
|
||||
action = "remove"
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue