Perlin noise exceeds -1/1 range

User avatar
burli
Member
 
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Perlin noise exceeds -1/1 range

by burli » Wed May 11, 2016 20:26

As far as I understand perlin noise the values should not exceed -1 or 1, but they do.

Code: Select all
local testparam = {
   offset = 0,
   scale = 1,
   spread = {x=80, y=80, z=80},
   seed = 1337,
   octaves = 6,
   persist = 0.6
}
perlin_map = minetest.get_perlin_map(testparam, map_lengths_xyz):get2dMap_flat(minp)

            pi = perlin_map[perlin_index]
             if pi < -1 or pi > 1 then
                minetest.chat_send_player("singleplayer", pi)
             end


This is a snipped of the code I use (based on the example from PerlinNoiseMap, which has also a bug) and I get a lot of values below -1 or above 1, lots of them more than +/-1.5.

As you can see on the screenshot lots of the numbers are equal and it looks like they have a pattern. Is this a bug?

Image
Attachments
screenshot_20160511_222308.jpg
(55.37 KiB) Not downloaded yet
 

User avatar
duane
Member
 
Posts: 1591
Joined: Wed Aug 19, 2015 19:11
Location: Oklahoma City
GitHub: duane-r

Re: Perlin noise exceeds -1/1 range

by duane » Thu May 12, 2016 01:43

burli wrote:As far as I understand perlin noise the values should not exceed -1 or 1, but they do.


Quoth the master (required reading on perlin noise):

https://forum.minetest.net/viewtopic.php?f=47&t=13278#p194281
Believe in people and you don't need to believe anything else.
 

User avatar
burli
Member
 
Posts: 1641
Joined: Fri Apr 10, 2015 13:18
 

User avatar
paramat
Developer
 
Posts: 3443
Joined: Sun Oct 28, 2012 00:05
Location: UK
GitHub: paramat
IRC: paramat

Re: Perlin noise exceeds -1/1 range

by paramat » Fri May 13, 2016 03:06

So it's possible to calculate the maximum range of a noise from octaves and persistence, then you can scale it down to compensate to keep it within -1 to 1 if needed.
 

Nore
Developer
 
Posts: 501
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

Re: Perlin noise exceeds -1/1 range

by Nore » Fri May 13, 2016 11:18

If that can help, perlin noise will always be less than (1-(persistance^octaves))/(1-persistance) in absolute value; however, it will very rarely get close to that value, if there are a lot of octaves, as it means that all octaves have to be close to 1 at the exact same place. Thus, if you want to rescale perlin noise to a [-1, 1] range, you should use functions such as math.atan to flatten it when the values are too large.
 

User avatar
burli
Member
 
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Perlin noise exceeds -1/1 range

by burli » Fri May 13, 2016 12:25

No, I don't want to rescale. I was just wondering because I thought that perlin noise just outputs -1 to 1. But thanks for explanation. Maybe this help others too
 


Return to Problems



Who is online

Users browsing this forum: No registered users and 4 guests