Sunday, July 21, 2019

algorithm - Simple noise generation


I'm looking to generate noise that looks like this:


enter image description hereenter image description here


(images courtesy of Understanding Perlin Noise)


I'm basically looking for noise with lots of small "ripples". The following is undesirable:


enter image description here


Are there any simple ways to do this? I've been looking at perlin and simplex for a week now and I can't seem to ever get it to work in JavaScript, or when I do, I don't have the correct parameters to generate such images, or it is excruciatingly slow.


I understand that the 3 images I posted could probably be achieved by the same algorithm but at a different scale, but I don't need that algorithm. I just need a very simple algorithm to achieve something like in the first image ideally. Maybe some kind of blurring would do the job, but I can't manage to have results.


I'm developing this in JavaScript but any kind of code or even a simple and detailed explanation will work.



Answer




While the existing answers provide a good way to achieve what the images in the question show, the comments revealed that the goal is to generate an image as shown below:


perlin noise turbulence


This type of noise is quite different from the noise shown in the images of the question, as it forms close isolated blobs.


Turns out that this kind of noise is called turbulence which (according to this CPU Gems article) is implemented as follows (where noise is your Perlin-noise function returning values from -1..1):


double turbulence(double x, double y, double z, double f) {
double t = -.5;
for ( ; f <= W/12 ; f *= 2) // W = Image width in pixels
t += abs(noise(x,y,z,f) / f);
return t;
}


Mashing up this JavaScript Perlin-noise implementation with the turbulence function described above generates noise which is pretty similar to the image above:


turbulence noise


The JavaScript code that was used to generate the image above can be found in this jsFiddle.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...