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.
Perlin noise generation in Lua/Löve?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Perlin noise generation in Lua/Löve?
- Attachments
-
- perlin-terrain.love
- (2.23 KiB) Downloaded 598 times
Last edited by middlerun on Thu Jun 30, 2011 2:21 am, edited 1 time in total.
- 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?
I always applaud all things procedural.
<aplause>
BTW, mddlerun's demo just gives me a black screen. LÖVE 0.7.2 stable, ubuntu.
<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.
Re: Perlin noise generation in Lua/Löve?
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.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Perlin noise generation in Lua/Löve?
It works for me.
You should use the simplex noise generator that works with LuaJIT though, it's much more efficient.
You should use the simplex noise generator that works with LuaJIT though, it's much more efficient.
- 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?
I tried a second time and it worked. Mistery.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.
And for the record, my computer is a beast (bought it like 2 months ago)
When I write def I mean function.
Re: Perlin noise generation in Lua/Löve?
wow.. Running "perlin-terrain.love" with LuaJIT makes you realise how fast it is compared to regular lua.
Re: Perlin noise generation in Lua/Löve?
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 themsentry wrote:wow.. Running "perlin-terrain.love" with LuaJIT makes you realise how fast it is compared to regular lua.
iow, everything has its strengths and weaknesses, this happens to be JITs strength.
"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
Networking with UDP uLove Proposal CCG: Gangrene
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Perlin noise generation in Lua/Löve?
It would be much faster under LuaJIT if it used LuaJIT's FFI (like the one I linked).Elvashi wrote: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 themsentry wrote:wow.. Running "perlin-terrain.love" with LuaJIT makes you realise how fast it is compared to regular lua.
iow, everything has its strengths and weaknesses, this happens to be JITs strength.
- 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?
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
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+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- 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?
You guys this is so cool. We need another procedural contest.
Kurosuke needs beta testers
Who is online
Users browsing this forum: No registered users and 5 guests