Page 1 of 1

A little demo of love.math.noise function

Posted: Tue Mar 18, 2014 1:16 am
by chezrom
Hello to all,

Here is a little demo of the love.math.noise function to generate background images. (left/right arrow to rotate, space to regenerate background)

Because I use scrolling, I need seemless image that I generate with the 3D noise function mapping the 2D surface on a donut that can create some stretching. I use a multi-octave noise (4 octaves) to have a 'pink noise' that seems more 'natural'.

A problem that I have is that the noise function use the same permutation and it is unable to define this permutation (and to change it) then to have different image, I use different origin, I don't know if another method can be used to do this.

Enjoy !

Re: A little demo of love.math.noise function

Posted: Tue Mar 18, 2014 1:56 am
by micha
Cool. Thanks for sharing.

Re: A little demo of love.math.noise function

Posted: Tue Mar 18, 2014 7:15 pm
by Germanunkol
I think using a different origin is perfectly fine - it's the way I'd do it as well. The noise function doesn't come with a "seed" value, so I think using a random origin is the way to go...

Re: A little demo of love.math.noise function

Posted: Tue Mar 18, 2014 8:23 pm
by micha
I just played a little bit with the noise. To randomize it, I see two possible solutions. Either move the origin:

Code: Select all

origin = math.random()*100
noiseDataAtX = love.math.noise(x-origin)
or introduce an additional dimension and pass a random number as additional argument:

Code: Select all

seed = math.random()*100
noiseDataAtX = love.math.noise(x,seed)
Both give similar behavior.
Here is an example for the latter one. Press any button to generate noise with a new "seed".

Re: A little demo of love.math.noise function

Posted: Tue Mar 18, 2014 9:44 pm
by chezrom
Thank you for your feedbacks and advice.

I don't think to use another dimension, thank micha, but the problem is that noise computation because slower (not so critical as for perlin noise, because simplex has been created to avoid explosion of computation time when the number of dimension increases).

Because I experiment in the noise usage, I post here another demo about planet 'avatar' in a space game for example.
Planet is without cloud here (I'm lazy, sorry), and with a random rotation (WARNING ! this code contains matrix porn).
The light comes from a very far star, and is the same for all planet. I use no shader (all is computed in the sprite).

Press [space] to regenerate planets.

An image
testnoise2.jpg
testnoise2.jpg (44.22 KiB) Viewed 3435 times
And the love file :
testnoise2.love
(4.43 KiB) Downloaded 208 times

Enjoy !

Re: A little demo of love.math.noise function

Posted: Tue Mar 18, 2014 9:49 pm
by DaedalusYoung
micha wrote:number as additional argument:

Code: Select all

seed = math.random()*100
noiseDataAtX = love.math.noise(x,seed)
You cannot do that when you're using all 4 dimensions in order to get seamless noise though, since love.math.noise only accepts up to 4 dimensions, so then the only way to go is the origin method.