Here are the new noise sections in doc/lua_api.txt:
*****
Noise Parameters
--------------------
Noise Parameters, or commonly called NoiseParams, define the properties of perlin noise.
- offset
Offset that the noise is translated by (i.e. added) after calculation.
- scale
Factor that the noise is scaled by (i.e. multiplied) after calculation.
- spread
Vector containing values by which each coordinate is divided by before calculation.
Higher spread values result in larger noise features.
A value of {x=250, y=250, z=250} is common.
- seed
Random seed for the noise. Add the world seed to a seed offset for world-unique noise.
In the case of minetest.get_perlin(), this value has the world seed automatically added.
- octaves
Number of times the noise gradient is accumulated into the noise.
Increase this number to increase the amount of detail in the resulting noise.
A value of 6 is common.
- persistence
Factor by which the effect of the noise gradient function changes with each successive octave.
Values less than 1 make the details of successive octaves' noise diminish, while values
greater than 1 make successive octaves stronger.
A value of 0.6 is common.
- lacunarity
Factor by which the noise feature sizes change with each successive octave.
A value of 2.0 is common.
- flags
Leave this field unset for no special handling.
Currently supported are:
- defaults
Specify this if you would like to keep auto-selection of eased/not-eased while specifying
some other flags.
- eased
Maps noise gradient values onto a quintic S-curve before performing interpolation.
This results in smooth, rolling noise. Disable this for sharp-looking noise.
If no flags are specified (or defaults is), 2D noise is eased and 3D noise is not eased.
- absvalue
Accumulates the absolute value of each noise gradient result.
*****
PerlinNoise: A perlin noise generator
- minetest.get_perlin(seeddiff, octaves, persistence, scale) or minetest.get_perlin(noiseparams)
*****
If you want to calculate noise at point using minetest.get_perlin() you can now either use the old single-line format:
Code: Select all
minetest.get_perlin(seeddiff, octaves, persistence, scale)
(which confusingly uses the word 'scale' for what is actually 'spread') or the table format shown below. If you have noiseparams already defined in a mapgen mod for creating perlin noise maps you can now input those noiseparams directly into minetest.get_perlin().
Two new optional noise parameters have been added to the table format: 'lacunarity' and 'flags'.
Lacunarity has in the past always been set to 2.0, and will be set to that value if the line is left out.
Lacunarity is the ratio of the 'spreads' of adjacent octaves, up until now each additional octave created detail on a scale half as big (1/2.0), now you can control that. for example a lacunarity of 3.0 will create a wider range of detail for the same number of octaves, or, the same range of detail for a smaller number of octaves, both at the expense of noise quality. If in doubt leave it at 2.0.
Flags allows you to ease 3D noise, un-ease 2D noise, and get the absolute value of noise.
Interestingly 2D noise has in the past always been eased, now you can un-ease it to make it more spiky.
Noise parameters format for 2D or 3D perlin noise or perlin noise maps:
Code: Select all
np_terrain = {
offset = 0,
scale = 1,
spread = {x=384, y=384, z=384},
seed = 5349,
octaves = 5,
persist = 0.63,
lacunarity = 2.0,
flags = "eased"
}
Therefore a single noise parameter table can be used to get 2D or 3D noise, when getting 2D noise spread.z is ignored.
Further explanation by hmmmm on IRC:
Code: Select all
<hmmmm> leave flags blank for noise just like you're used to, eased/non-eased is determined by the type of noise it's being used for
<hmmmm> 2d noise uses eased by default
<hmmmm> 3d noise uses non-eased by default
<hmmmm> this is needed for backwards compatibility
<hmmmm> if you want to do something a little different though... you need to specify the flags field
<hmmmm> 2d noise with the "eased" flag does nothing really because it's already eased by default
<paramat> 2d noise has always been eased then?
<hmmmm> yup
<hmmmm> if you specify "noeased" though, or just have the flags field present without "eased" present, it'll disable easing on 2d noise
<hmmmm> if you specify "eased" on 3d noise, it'll ease your 3d noise
<hmmmm> if you specify "noeased" on 3d noise or leave nothing at all, it'll be regular 3d noise
<hmmmm> let's say you want absolute noise but you don't want to specify eased or not eased
<hmmmm> you'd specify defaults instead
<hmmmm> flags = "defaults, absvalue" would make the noise eased or not eased based on if it's being used for 2d or 3d noise
<hmmmm> by the way, you understand the flags specifier format, right?
<hmmmm> there's the comma-delimited string format, and then there's the table format
<hmmmm> "flag1, flag2" sets flag 1 and flag 2
<hmmmm> "noflag1, flag2" specifically unsets flag1 in case it's set by default, and sets flag2
<hmmmm> flags = { flag1 = true, flag2 = true } in table format
<hmmmm> or...
<hmmmm> flags = { flag1 = false, flag2 = true } which is equivalent to flags = { noflag1 = true, flag2 = true }
<paramat> and luaperlinnoise [in the C++ code] is the lua wrapper around the new noise stuff?
<hmmmm> LuaPerlinNoise has been around since forever... I just updated it so that it can take advantage of the new parameters
<hmmmm> also you weren't able to specify coordinate-specific spread factors
<hmmmm> the (250.0, 250.0, 250.0) thing
<hmmmm> how much the noise is spread out by :)
<hmmmm> celeron seems to have previously called that "scale", but i use the word scale for what the end result is multiplied by
<hmmmm> which is usually what scaling represents...
<paramat> yeah scale is the old wordage for spread
<hmmmm> i didn't realize my terminology was conflicting until i read LuaPerlinNoise's ctor
<paramat> so now for getting perlin noise at point in lua we can use the same noiseparam format that's used for getting lua perlinmaps?
<hmmmm> yea
<paramat> great i have been wanting that
EDIT Corrected some details and added content to this post.