A little demo of love.math.noise function

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
chezrom
Citizen
Posts: 59
Joined: Tue May 28, 2013 11:03 pm
Location: France

A little demo of love.math.noise function

Post 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 !
Attachments
testnoise.love
(8.23 KiB) Downloaded 388 times
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

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

Post by micha »

Cool. Thanks for sharing.
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

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

Post 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...
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

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

Post 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".
Attachments
randomizeNoise.love
(389 Bytes) Downloaded 164 times
User avatar
chezrom
Citizen
Posts: 59
Joined: Tue May 28, 2013 11:03 pm
Location: France

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

Post 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 3318 times
And the love file :
testnoise2.love
(4.43 KiB) Downloaded 202 times

Enjoy !
User avatar
DaedalusYoung
Party member
Posts: 407
Joined: Sun Jul 14, 2013 8:04 pm

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

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

Who is online

Users browsing this forum: No registered users and 197 guests