Log In  

Cart #32443 | 2016-11-13 | Code ▽ | Embed ▽ | No License

Hi all,
I'm working on a space game with procedurally generated planets and thought others may benefit from the simplex noise functions I'm using.

This is ported the reference examples at:


The whitepaper can be found here:


Feel free to use. Be aware that perlin noise (predecessor to simplex noise) has a patent. Here's an alternative: OpenSimplexNoise


Edit: That patent is for simplex noise

P#32444 2016-11-13 16:15 ( Edited 2017-07-18 14:15)

"Be aware that perlin noise (predecessor to simplex noise) has a patent."

Other way around. The simplex noise algorithm is the one that is patented. (That's the patent you linked too) IANAL, but I think you only need to be worried about using it if you are making a commercial product.

P#32468 2016-11-14 12:51 ( Edited 2016-11-14 17:51)

Ah thanks for finding that. Yeah I agree it's probably not a problem if you aren't selling anything.

P#32536 2016-11-15 22:29 ( Edited 2016-11-16 03:29)

Awesome example, thank you! How could i tile it?

P#42462 2017-07-14 00:23 ( Edited 2017-07-14 04:23)
:: Felice

Pretty cool. Gonna borrow some of this. ;)

By the way, I notice you detest 1-based array accesses too. :) Here's a helper I use for declaring 0-based arrays without needing to have fixer code below the array:

Edit: disregard this solution, MBoffin offered an even better one in the next post.

function _0(a)
 for n=0,#a do a[n]=a[n+1] end
 return a

Note there appears to be an off-by-one overrun bug because I iterate 0..#a, but that's to make sure the final original entry is set to nil. Working as intended. :) Anyway...

Then, thanks to the features of the lua parser where it lets you skip parens in some function calls, you can say this:

powersof2 = _0{ 1, 2, 4, 8, 16, 32, 64, 128 }

> ?powersof2[0]
> ?powersof2[7]
> ?powersof2[8]

Saves a bunch of extra work, to be sure.

(#%! @ing lua, mutter.)

P#42583 2017-07-17 23:43 ( Edited 2017-07-18 14:17)

Someone else pointed out to me that you can just do this to make your arrays 0-based:


Super simple.

P#42589 2017-07-18 03:53 ( Edited 2017-07-18 07:53)
:: Felice

Oh, that's even better. I always wanted to do that with "0=..." but it didn't work. I didn't know you could bracket a numeric literal to allow its use as a key.


P#42593 2017-07-18 10:15 ( Edited 2017-07-18 14:15)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-03-06 16:33 | 0.033s | 2097k | Q:39