I think I understand Noise - here is my description
Tags: noise, generativeart, zimjs, processing
Published: 2020-11-27 02:27:43

Noise is an equation that can be used to make art with code.  Here are a couple examples:

https://codepen.io/zimjs/pen/XWjrmoQ 
https://codepen.io/zimjs/pen/LvGqgB

Noise is a random-like bumpy equation but if you zoom in on it then it gets smoother.  We are using Simplex Noise - another common one is Perlin Noise.  

---
<h2>1D NOISE</h2>
With 1D noise we can imagine a bumpy curve.  You pass in one parameter - the position along the curve and you get back the height at that position as a number between -1 and 1.  Sometime this is between 0 and 1.  It does not matter... you can just multiply this by a factor to increase the range.

If we do this for ten positions, stepping by 5 each time, then we will get ten heights back.  We can plot these to see the shape of the noise equation.  Here is an plot with more than ten lines - this looks like NOISE - very random!

![bumpy noise](https://dev-to-uploads.s3.amazonaws.com/i/3g1gikq2cto7ousy4j4k.jpg)

If we zoom in on the equation by stepping by 3 in position then the curve becomes smoother.  You can try this here: https://codepen.io/zimjs/pen/KKKeGZg by adjusting the Dial at the top left.

![medium noise](https://dev-to-uploads.s3.amazonaws.com/i/vo879cuc5icqr7wafagj.jpg)

Stepping by 1 each time might make it smoother still:

![smooth noise](https://dev-to-uploads.s3.amazonaws.com/i/e82j12p57zqcmiykir6a.jpg)

---
<h2>2D NOISE</h2>

With 2D Noise, we can look at it in two ways.  The same as 1D noise but the second parameter moves us along the equation.  For instance, here we see the same smoothness as above but we have changed the second parameter so the curve is farther along the equation:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rpaft8j5vpunvrosqjnf.jpg)

OR - we can visualize 2D Noise as a wiggly plane where we get the height of the wiggly plane (between -1 and 1) at an x and y position.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/p2n4no71ig36hhhm8tur.jpg)

If we take a cross section across this wiggly plane and turn any value greater than 0 to white and less than 0 to black (with a small blended range near 0) then we get the image above - although this has been repeated.  And if we zoom out on that by taking inputs that are farther away from one another we start to see the familiar Noise pattern arising!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ld4bl7i7ir87h1u0ikc0.jpg)

Or we can draw beautiful meshes:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/unbavd3eb977jdz5naav.jpg)

These older examples can be found here: https://zimjs.com/noise but just be warned, the code is old ZIM.

---
<h2>3D NOISE</h2>

3D Noise allows us to pass in a third parameter and animate the 2D Noise patterns. If we change the third parameter by a large amount each time then the patterns will animate fast. If we pass in a smaller value each time for instance .01 then the patterns will animate slower.  If we pass in -.01 they will go in reverse.

In the Bloob example at https://codepen.io/zimjs/pen/XWjrmoQ we use the first two parameters to get a value for the radius of the lines we are drawing.  These are affected by the curve Dial (C) to determine how smooth the blob will look.  The third parameter is the speed which can be controlled by the speed dial (S) and even go backwards - very cool!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4p02rlwnhyhcty611kjd.jpg)

---
<h2>CONTROL AND SEEDS</h2>

For any given seed, passing in the same values a second time will result in the same output.  This might allow the user to pick a mountain range just based on a seed and for the app to replicate that mountain range based on one number!  Amazing. All that data from just one seed number.

In the BLOOB example, we make the radius follow the Noise equation but somehow seamlessly loop it back around to the start.  How do we do that?  Firstly we use just one seed - this is often the case.  Secondly, if you recall, for a given seed, the value is the same for the same inputs.  So we need to start at a number and then arrive back at the same number.  Using inputs from a periodic function will give us this.  

So, we can use the SINE function.  Unfortunately, as the sine goes up, it has the same value coming down and this gives us a symmetrical blob about the vertical axis.  So we can pass a SINE in for one parameter and a COSINE in for another parameter and these both come back to the same number and has the effect of circling around the wiggly plane getting heights as we go and arriving back at the start!

---

If you have not checked out the Canvas recently - you simply must!  Here is the [ZIM&nbsp;Dev&nbsp;Site](https://dev.zimjs.com) and some [In-depth&nbsp;Guides](https://drabstract.medium.com/) by Dr&nbsp;Abstract including [Your Guide to Coding Creativity on the Canvas](https://drabstract.medium.com/your-guide-to-coding-creativity-on-the-canvas-ada0996298f6).