[Question] Decorations: fill_ratio vs noise_params [Answered]

Post Reply
User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

[Question] Decorations: fill_ratio vs noise_params [Answered]

by sirrobzeroone » Post

Hopefully a quick question

Decorations can be specified with either a "fill_ratio" running from 0 to 10 (can go above 10 but 10=100%) or with "noise_params" directly.

I've tried doing some testing and I cant visually detect much difference between the two when the decorations are placed ie fill_ratio seems to be using some form of randomised seed behind the scenes (I did try trawling the C code but no handy file named "*schematic*" I could skim (https://github.com/minetest/minetest/tree/master/src) to confirm if this was the case?

I noticed in MTG most trees use the "noise_params" setting except jungle trees who use "fill_ratio". I'm fairly sure jungle trees were added later to MTG and I tried trawling change logs to confirm this but my guess is that fill_ratio was added later to the decoration api spec?

Is one different to the other? or technically speaking are they the same from the view of "I just want decorations placed randomly" or are schematics better to use noise_params and simple decs fill_ratio as fill_ratio does have a limited seed value?

Just trying to work out if I can stop specifying "noise_params" directly as those are more difficult for me to conceptualize mentally as an approximate coverage % for an area of the decorations. Where as fill ratio is far simpler and requires less trial and error to get the coverage I was going for.

Thanks again for the help :)

edit: located this file - https://github.com/minetest/minetest/bl ... coration.h it references fill_ratio being a float but way beyond me to interpret much further as I think i'd need to drill down into a lower function?
Last edited by sirrobzeroone on Thu May 06, 2021 06:54, edited 1 time in total.

User avatar
Skamiz Kazzarch
Member
Posts: 613
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: [Question] Decorations: fill_ratio vs noise_params

by Skamiz Kazzarch » Post

My understanding of this was always that 'fill_ratio' creates a roughly even distribution everywhere the decorations can be placed and 'noise_params' makes it so they are bunched up in some places and sparse in other.

Here is an interesting thread where decorations with noise params are used to create rivers:
viewtopic.php?f=47&t=23287

User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

Re: [Question] Decorations: fill_ratio vs noise_params

by sirrobzeroone » Post

Skamiz Kazzarch wrote:
Wed May 05, 2021 04:56
My understanding of this was always that 'fill_ratio' creates a roughly even distribution everywhere the decorations can be placed and 'noise_params' makes it so they are bunched up in some places and sparse in other.

Here is an interesting thread where decorations with noise params are used to create rivers:
viewtopic.php?f=47&t=23287
Thanks Skamiz Kazzarch, Spot on, I tested and looked more closely and noise is more clumpy/thin type distribution and fill more even across the area. Had to fly around more broadly and use a node that was a little more noticable.

Even using the info from the other thread its still unclear how values affect number of tree's for noise I did do some more testing and scale and offset intercat with each other but also totally swamp the other if you set the value high enough

If I set values as:

Code: Select all

			offset = 0.1,  
			scale = 0.00,
			spread = {x = 250, y = 250, z = 250},
trunk spacing in a dense patch is about 2-3 nodes with some slightly further and others closer. Setting offset to "1" results in an almost solid block of wood, conversly 0.001 results in about 1 tree per sidelen (in my case 16).

If I set values as:

Code: Select all

			offset = 0.0,  
			scale = 0.1,
			spread = {x = 250, y = 250, z = 250},
The overall average spacing is the same as offset 0.1 ie spacing of 2-3 nodes with some slightly further and others closer. However they are more clumped inside that so lots of trees 1 apart or touching but then mini clearings of 10 nodes. 1 again results in a near solid block and 0.001 about 1 tree every sidelen (in my case 16) although the trees maybe slightly more evenly spaced?

Adjusting spread is about what you would expect small number eg 50 and you get smaller clumps of tightly packed trees. Spread of 1000 and its pretty even across the whole area even right to edge. 250 appears to be a sweet spot were you get clumping but not to thin in between so it still feels like a continuous forest.

Not sure any of that helps me much as I'm trying to come up with some standardised numbers for:
  • Light
  • Medium
  • Heavy
I guess I could use acacia settings = light, coniferious or maybe a bit less = medium and heavy as a bit less than jungle. I was hoping there was a rough rule of thumb I could just easily apply.

eg (offset + scale)*spread = number = approximate density as a % or something but not sure thats achievable and blind trial and error starting from the current MTG settings might be abetter way to go.

User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

Re: [Question] Decorations: fill_ratio vs noise_params

by sirrobzeroone » Post

Skamiz Kazzarch wrote:
Wed May 05, 2021 04:56
My understanding of this was always that 'fill_ratio' creates a roughly even distribution everywhere the decorations can be placed and 'noise_params' makes it so they are bunched up in some places and sparse in other.

Here is an interesting thread where decorations with noise params are used to create rivers:
viewtopic.php?f=47&t=23287
Thanks Skamiz Kazzarch, Spot on, I tested and looked more closely and noise is more clumpy/thin type distribution and fill more even across the area. Had to fly around more broadly and use a node that was a little more noticable.

Even using the info from the other thread its still unclear how values affect number of tree's for noise I did do some more testing and scale and offset intercat with each other but also totally swamp the other if you set the value high enough

If I set values as:

Code: Select all

			offset = 0.1,  
			scale = 0.00,
			spread = {x = 250, y = 250, z = 250},
trunk spacing in a dense patch is about 2-3 nodes with some slightly further and others closer. Setting offset to "1" results in an almost solid block of wood, conversly 0.001 results in about 1 tree per sidelen (in my case 16).

If I set values as:

Code: Select all

			offset = 0.0,  
			scale = 0.1,
			spread = {x = 250, y = 250, z = 250},
The overall average spacing is the same as offset 0.1 ie spacing of 2-3 nodes with some slightly further and others closer. However they are more clumped inside that so lots of trees 1 apart or touching but then mini clearings of 10 nodes. 1 again results in a near solid block and 0.001 about 1 tree every sidelen (in my case 16) although the trees maybe slightly more evenly spaced?

Adjusting spread is about what you would expect small number eg 50 and you get smaller clumps of tightly packed trees. Spread of 1000 and its pretty even across the whole area even right to edge. 250 appears to be a sweet spot were you get clumping but not to thin in between so it still feels like a continuous forest.

Not sure any of that helps me much as I'm trying to come up with some standardised numbers for:
  • Light
  • Medium
  • Heavy
I guess I could use acacia settings = light, coniferious or maybe a bit less = medium and heavy as a bit less than jungle. I was hoping there was a rough rule of thumb I could just easily apply.

eg (offset + scale)*spread = number = approximate density as a % or something but not sure thats achievable and blind trial and error starting from the current MTG settings might be abetter way to go.

Edit: Just been mulling this over and maybe you can roughly calculate a % at least when either scale or offset = 0 assuming spread remains at 250. the 0.001 case results in 1 tree per sidelen

16x16 = 256
(1/256)*100 = 0.4% coverage per sidelen of dense areas, what Im seeing about 1 tree per 16x16 area

User avatar
Skamiz Kazzarch
Member
Posts: 613
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: [Question] Decorations: fill_ratio vs noise_params

by Skamiz Kazzarch » Post

Code: Select all

        sidelen = 8,
       	-- Size of the square divisions of the mapchunk being generated.
        -- Determines the resolution of noise variation if used.
        -- If the chunk size is not evenly divisible by sidelen, sidelen is made
        -- equal to the chunk size.
        
        -- A noise value is calculated for each square division and determines
        -- 'decorations per surface node' within each division.
Haven't tried it myself but my understanding of how it works is this: For each sidlen*sidelen area one noise value is retrieved and then the same algorythm which places decorations when you just use 'fill_ratio' uses that value to place decorations in that area.
sirrobzeroone wrote:
Wed May 05, 2021 09:27
If I set values as:

Code: Select all

			offset = 0.1,  
			scale = 0.00,
			spread = {x = 250, y = 250, z = 250},
trunk spacing in a dense patch is about 2-3 nodes with some slightly further and others closer. Setting offset to "1" results in an almost solid block of wood, conversly 0.001 results in about 1 tree per sidelen (in my case 16).

Code: Select all

noise = offset + scale * (octave1 +
                          octave2 * persistence +
                          octave3 * persistence ^ 2 +
                          octave4 * persistence ^ 3 +
                          ...)
What happens here is that by setting 'scale = 0.00' you completely eliminate the noise component, what remains is the 0.1 so the algorythm places a tree on average on one in ten nodes. When you rise offset to 1 it tries to place a tree on every node.

As for the other example, each octave can have a value between 1 and -1, so by setting 'scale = 0.1', assuming only one octave, the noise value is at most 0.1 which is the same result as having offset at 0.1 and scale at 0.

You will probably want to do some reading about how noise works to figure out how to get values which are usefull to you:https://github.com/minetest/minetest/bl ... .txt#L3430

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [Question] Decorations: fill_ratio vs noise_params

by ShadMOrdre » Post

I use fill ratio in my geology and ecology mods. Specifically, in the add_trees and add_plants functions, here.

The third column, here, defines the actual value. Notice how small the values are, and how little the difference is for any given decoration across the various ecosystems represented. Please excuse the obvious copy/paste data set, in general.

I chose fill ratio over noise because I wanted more control over the density of any given decoration within the represented biomes / ecosystems. The differences are subtle, but recognizable in-world.

A bonus was the performance boost. Each noise requires its own memory. A fill ratio is simply a value. I do find a performance hit when using noises, thus restrict my uses of noises to ores and my custom lua mapgen. At this point in my lua mapgen, I've even limited noise usage for the performance boost.

It really boils down to your preference for a consistent vs. variable spread, and any performance considerations.

Hope this helps as well.


Shad

User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

Re: [Question] Decorations: fill_ratio vs noise_params

by sirrobzeroone » Post

Thank you both, as always very helpful info :).

Edit: For a future person who may stumble on this, hopefully the below might give start for noise/tree cover :)

Code: Select all

tree_ cover = {["lvl1"] = {["offset"] = 0.000, ["scale"] = 0.001},   -- Super light <1 tree per 16x16 area
	       ["lvl2"] = {["offset"] = 0.000, ["scale"] = 0.005},   -- Light 1-2 trees per 16x16 area
	       ["lvl3"] = {["offset"] = 0.001, ["scale"] = 0.01},    -- Mod Light 3-5 trees per 16x16 area
	       ["lvl4"] = {["offset"] = 0.004, ["scale"] = 0.02},    -- Moderate 7-9 trees per 16x16 area
	       ["lvl5"] = {["offset"] = 0.007, ["scale"] = 0.035},   -- Moderatly Heavy 10-12 trees per 16x16 area
	       ["lvl6"] = {["offset"] = 0.01,  ["scale"] = 0.05},    -- Heavy 15-18 trees per 16x16 area
	       ["lvl7"] = {["offset"] = 0.015, ["scale"] = 0.07}     -- Very Heavy 20-22 trees per 16x16 area		       
		       }

-- example dec
minetest.register_decoration({
	name = "my_mod:awesome_tree",
	deco_type = "schematic",
	place_on = {"default:dirt_with_grass"},
	sidelen = 16,
	noise_params = {
			offset = tree_cover.lvl4.offset,
			scale = tree_cover.lvl4.scale,
			spread = {x = 250, y = 250, z = 250},
			seed = 2,
			octaves = 3,
			persist = 0.66
		},
	biomes = {"grassland"},
	y_min = 0,
	y_max = 31000,
	schematic = my_mod.awesome_tree,   --assumes lua schematic stored in a global table
	flags = "place_center_x, place_center_z",
	place_offset_y = 0,
	rotation = "random"
})

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests