Perlin noise generation in Lua/Löve?

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.
User avatar
middlerun
Citizen
Posts: 64
Joined: Tue Nov 25, 2008 4:31 am
Location: Sydney, Australia
Contact:

Re: Perlin noise generation in Lua/Löve?

Post by middlerun »

Here's a thing I whipped up in the last few hours for generating terrain with 2D Perlin noise. Warning: pretty slow. Press r to regenerate terrain or p to see the unprocessed Perlin noise.

EDIT: Fixed bug.
Attachments
perlin-terrain.love
(2.23 KiB) Downloaded 564 times
Last edited by middlerun on Thu Jun 30, 2011 2:21 am, edited 1 time in total.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Perlin noise generation in Lua/Löve?

Post by kikito »

I always applaud all things procedural.

<aplause>

BTW, mddlerun's demo just gives me a black screen. LÖVE 0.7.2 stable, ubuntu.
When I write def I mean function.
User avatar
middlerun
Citizen
Posts: 64
Joined: Tue Nov 25, 2008 4:31 am
Location: Sydney, Australia
Contact:

Re: Perlin noise generation in Lua/Löve?

Post by middlerun »

Are you running on a slow computer or anything? It can take a long time to generate the Perlin noise, about five seconds on my computer. It's probably not the most efficient code.
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Perlin noise generation in Lua/Löve?

Post by slime »

It works for me.

You should use the simplex noise generator that works with LuaJIT though, it's much more efficient. :P
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Perlin noise generation in Lua/Löve?

Post by kikito »

middlerun wrote:Are you running on a slow computer or anything? It can take a long time to generate the Perlin noise, about five seconds on my computer. It's probably not the most efficient code.
I tried a second time and it worked. Mistery.

And for the record, my computer is a beast :cool: (bought it like 2 months ago)
When I write def I mean function.
User avatar
sentry
Prole
Posts: 8
Joined: Tue Mar 08, 2011 12:00 am
Location: Amsterdam

Re: Perlin noise generation in Lua/Löve?

Post by sentry »

wow.. Running "perlin-terrain.love" with LuaJIT makes you realise how fast it is compared to regular lua.
User avatar
Elvashi
Prole
Posts: 45
Joined: Sat Jul 04, 2009 9:17 am
Location: Australia

Re: Perlin noise generation in Lua/Löve?

Post by Elvashi »

sentry wrote:wow.. Running "perlin-terrain.love" with LuaJIT makes you realise how fast it is compared to regular lua.
actually, its just that this sort of thing is pretty much the ideal case for JIT in general. Other cases are sufficiently pathological that luaJIT's response is to...not jit them :3

iow, everything has its strengths and weaknesses, this happens to be JITs strength. :3
"We could make a program for doing this for you, but that is for the LÖVE IDE, planned to be released in March 2142." ~mike
Networking with UDP uLove Proposal CCG: Gangrene
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Perlin noise generation in Lua/Löve?

Post by slime »

Elvashi wrote:
sentry wrote:wow.. Running "perlin-terrain.love" with LuaJIT makes you realise how fast it is compared to regular lua.
actually, its just that this sort of thing is pretty much the ideal case for JIT in general. Other cases are sufficiently pathological that luaJIT's response is to...not jit them :3

iow, everything has its strengths and weaknesses, this happens to be JITs strength. :3
It would be much faster under LuaJIT if it used LuaJIT's FFI (like the one I linked). :P
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Perlin noise generation in Lua/Löve?

Post by Taehl »

Here's a very cheap-but-quick 1D implementation I just whipped up. It even lets you specify the granularity of each pass (the little tables I pass the function) (hence, each line has a different style) and whether to use linear or cosine interpolation. Hold any key except Esc to constantly churn out three 800-point lines at blazing speed.

http://dl.dropbox.com/u/3713769/web/Love/perlin.love
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Perlin noise generation in Lua/Löve?

Post by tentus »

You guys this is so cool. We need another procedural contest.
Kurosuke needs beta testers
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 150 guests