Two dimensional love.math.noise with big values

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Niezborny
Prole
Posts: 1
Joined: Thu May 28, 2020 7:37 pm

Two dimensional love.math.noise with big values

Post 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)?
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

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

Post 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.
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

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

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 1 guest