simap / pixelblaze

Files related to Pixelblaze
https://www.bhencke.com/pixelblaze
233 stars 29 forks source link

Possibility to add native simplex/perlin noise functions? #18

Closed gabeschine closed 1 year ago

gabeschine commented 2 years ago

Greetings!

I'm wondering if you would be willing to provide native implementations of simplex 2d and 3d noise functions in the Pixelblaze function API. These functions are so useful for creating "natural" feeling patterns and randomness that are difficult to accomplish otherwise.

It would be possible to use a pure JS implementation, but performing, say, 3 calls to a noise function for every pixel for every frame, starts to get expensive for higher pixel counts.

Here is an example JS implementation: https://github.com/josephg/noisejs/blob/master/perlin.js Here is an example in C: https://github.com/smcameron/open-simplex-noise-in-c

Let me know your thoughts! I think it would be a great addition to the library.

Awesome work, by the way.

gabeschine commented 2 years ago

Even better (this is what I was originally looking for), FastLED library contains an integer-math-only implementation of simplex noise:

https://github.com/FastLED/FastLED/blob/master/src/noise.cpp

It's very fast.

simap commented 2 years ago

Thanks, will take a look. Jeff had posted some noise functions in PB a while ago, these are on the pattern site. APIs to a native implementation would be much faster of course!

gabeschine commented 2 years ago

Thanks!

I've now tested 3 different JS perlin/simplex noise implementations on a v3 pixelblaze. Calling the noise function once per pixel on a 648 pixel strip of APA102s resulted in a 10 FPS animation. So, the limits of doing this in JS are, realistically, no more than ~200 calls into the noise function per frame. I've done some really beautiful things with 3 noise calls per pixel per frame.

I believe the FastLED implementation (which is by far the most efficient on these microcontrollers) is MIT license, which I think allows you to use it directly without any issues.

Please let me know if I can help. I'm more than happy to contribute directly, as well. I have the necessary background & experience.

kendrick90 commented 2 years ago

Very much looking forward to this. It would be great if there was a 3d one too.

simap commented 1 year ago

It was added! See this post for details: https://forum.electromage.com/t/v3-30-release-palettes-perlin-noise-and-much-more/2562