Page 1 of 1

Is "perlin:get2d({x = pos.x, y = pos.z})" from -1 to 1 or from 0 to 1?

PostPosted: Tue Dec 11, 2012 02:59
by paramat
Sorry to ask, i've searched online for hours.
If for example ...
perlin = minetest.env:get_perlin(SEEDDIFF, 3, 0.5, 150)
What range of values does ...
perlin:get2d({x = pos.x, y = pos.z})
... give? -1 to 1 or 0 to 1?

PostPosted: Tue Dec 11, 2012 10:38
by PilzAdam
Just add an math.abs() arround it and you can be sure its not under 0.

PostPosted: Wed Dec 12, 2012 03:36
by paramat
Okay thanks i appreciate a reply. I'm adapting the conifers mod to my needs by spawning by perlin not altitude, i eventually managed to have perlin value output to the terminal using print ... and yes it is -1 to 1 as i hoped.

EDIT hmmm ... actually i see it occasionally exceeds the -1 to 1 range.

Re:

PostPosted: Fri Jun 05, 2015 14:50
by Hybrid Dog
sorry for posting to an old topic

paramat wrote:hmmm ... actually i see it occasionally exceeds the -1 to 1 range.

Image

l've got a problem, it even exceeded to -1.7 (which remembers me to approximately sqrt(3)). And l use perlin noise for the top of the nether forest, so l need to know where it begins.
What is the range of perlin noise?

Re: Is "perlin:get2d({x = pos.x, y = pos.z})" from -1 to 1 o

PostPosted: Fri Jun 05, 2015 16:17
by srifqi
Looks like Minetest's PerlinNoise is buggy. You can use clamp function:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local function clamp(value, min, max)
    if value<min then return min end
    if value>max then return max end
    return value;
end

Re: Is "perlin:get2d({x = pos.x, y = pos.z})" from -1 to 1 o

PostPosted: Fri Jun 05, 2015 17:32
by Hybrid Dog
srifqi wrote:Looks like Minetest's PerlinNoise is buggy. You can use clamp function:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local function clamp(value, min, max)
    if value<min then return min end
    if value>max then return max end
    return value;
end

this would make a flat top, l currently use another fix
https://github.com/HybridDog/minetest-n ... 5c1dcdR486