10

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

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

Enjoy!

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)

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 end ```

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] 1 > ?powersof2[7] 128 > ?powersof2[8] nil ```

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)
1

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

 ```powersof2={[0]=1,2,4,8,16} ```

Super simple.

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

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.

Cheers!

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