Page 1 of 1

Two dimensional love.math.noise with big values

Posted: Thu May 28, 2020 8:01 pm
by Niezborny
Hi,

I started playing with noise - mainly 2D. From what I read for generating 2D noise LOVE uses simplex noise algorithm. Playing with different values I noticed that for values of (x, y) which are close to 0 or are very big or very small love.math.noise() returns .5. By very big and small I mean above 10000000 / below -10000000 and close to zero [- .000000001, .000000001].
I would say that the function looses its usefulness for those numbers and the wiki does not mention that the values of (x, y) are restricted.

Could someone please explain what is going on here? Is it the property of the algorithm or its implementation?
Any solution how to manage this if I want to generate noise form unknown values of (x, y)?

Re: Two dimensional love.math.noise with big values

Posted: Fri May 29, 2020 10:08 am
by pgimeno
Hello, welcome to the forums.

Quite unfortunately, Löve is using single precision to generate noise, which intrinsically has that limitation on big values. Here's a representation of the range 1999999.5 to 2000000.5 in both dimensions, showing the loss of precision in the coordinates (it gets worse in the range you've indicated):

Image

For small values, the same applies. Since you're zooming in on a very uniform area, the returned values are going to be extremely close together. So close, that you won't be able to distinguish them with a single precision number. I don't think this last one is a problem. Single precision for the returned value is OK. Single precision for the coordinates is a mistake.

Re: Two dimensional love.math.noise with big values

Posted: Fri May 29, 2020 2:50 pm
by slime
There's a report in the issue tracker about it: https://github.com/love2d/love/issues/1579

We'll have to look into what can be changed in the noise library we're using.