Perlin noise exceeds -1/1 range

User avatar
burli
Member
 
Posts: 1313
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.

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 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
screenshot_20160511_222308.jpg (55.37 KiB) Viewed 429 times
 

User avatar
duane
Member
 
Posts: 776
Joined: Wed Aug 19, 2015 19:11
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
 

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

Re: Perlin noise exceeds -1/1 range

by burli » Thu May 12, 2016 05:48

Thanks, this should really be copied to the wiki
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: 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
Member
 
Posts: 468
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: 1313
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 Minetest Problems

Who is online

Users browsing this forum: No registered users and 16 guests

cron