Processing’s noise implementation has many issues:
Repeats after a very small cycle in the x and y axes.
Strange repeating motion in z axis.
Block-like pattern/artefacts
Normally distributed (bell-curve distribution). Sometimes this is good, but I’d say this is generally undesirable in creative coding, and particularly undesirable for color generation (as exemplified below).
Solution
To mainly solve the fourth point, I created a small library that outputs noise values that are uniformly distributed between [ 0, 1 ]. In most of my use-cases (in creative coding and elsewhere) this distribution is much more desirable. Not only that, the library wraps FastNoiseLite providing “much better quality” noise compared the abysmal offering in Processing.
Comparison
Images showing Processing’s noise() on the left verrsus UniformNoise on the right.
The uniform noise is clearly the winner here, but OpenSimplex2 is an improvement over the processing “perlin noise”. There is even a variation that is more suitable for creating terrains.
This is immensely useful to me. Thanks for writing the library and sharing it. Now, pardon me being a total Java n00b, but how do I install UniformNoise in my Processing 4 library folder? Can’t seem to find it via the Contribution Manager. Thanks!
I really appreciate your fast response, @GoToLoop. I have dragged all the .java (no .jar file AFAIK) files to the root folder of my sketch. They show up as separate tabs, and the sketch compiles and runs just fine, but I’m not sure what to do from here. Attempting to call uniformNoise(1.0, 1.0) returns an error stating that "The function uniformNoise(float, float) does not exist." Am I missing an import statement here, or do I need to make an instance of the UniformNoise class?
Follow up: I commented out the package part of the .java files, and successfully called uniformNoise() from a manually created instance of UniformNoise.
So for now I got it to work. Great. But I might have violated a few conventions and good practice norms in the process. Please let me know if there’s a more common approach that I should follow.
YA follow up: So, it appears my “hack” doesn’t work with Processing’s Tweak Mode, which I am very reliant on. The code in the imported .java files throws a "tweakmode_int cannot be resolved to a variable" error when I attempt to run the sketch in Tweak Mode. I suspect replacing the imported .java with a .jar would fix this issue. Trouble is, I have absolutely ZERO clue on how to compile .java files into a .jar that’ll work with Processing. Any takers on this one?
Classes & interfaces within files w/ extension “.java” needs to be imported before usage.
You should keep the package statements.
Within file “UniformNoise.java” we have package micycle.uniformnoise;
That means in order to import its public classUniformNoise in our “.pde” file we do: import micycle.uniformnoise.UniformNoise;
Which is the combination of package path + class name:
Thank you for the clarification @GoToLoop. I followed your advise and it works like a charm despite throwing an initial “No library found for micycle.uniformnoise” error.
There’s still an issue with me not being able to run the sketch in Tweak Mode, but I’ll work out a way to circumvent this.
Thanks for chiming in on this thread and thanks for making the library @micycle! I might have missed something, but I can’t find a .jar file in zip I download from your Github repo. Where did you get the .jar file from?
These are basically all the same and relate to the functions periodicity. I wouldn’t call them “issues” exactly. The period isn’t really a problem and, in fact, it can be useful.
If you want to avoid repetition (or extend the period) the way to do it is with your scaling factor(s). Most of the examples you’ll find will use scales of something like 0.02 or 0.05 or 0.1… and these will extend the period, but not really by that much. If you want much longer periods, use a scalar that doesn’t easily divide into the period lengths (which are powers of 2, btw.) So… instead of 0.02 pick 0.0217 or instead of 0.05 pick 0.493 or something.
However, isn’t noise most often used as a form of randomness, in which case the periodicity would be generally regarded as an unfortunate artifact, even though it might sometimes be useful?
Looks like we are having this conversation in two threads now. As I said above and in the other is that I believe you can essentially extend the period (and possibly make it very long indeed) by using a noise scale that doesn’t divide into the period… like choose 0.0217 instead of 0.02.
Can you demonstrate what you mean by this? Using any scaling factor (whether an irrational number or not) simply zooms/scales the noise and doesn’t alleviate the problems I listed.