Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
    • p5.js Introduction
    • p5.js Variables
    • p5.js Random Numbers
    • p5.js SVG + Images
    • p5.js WebGL
    • p5.js Classes and Objects
    • p5.js Events and Functions
    • p5.js Loops
    • p5.js Coordinates
    • P5js Nested Loops
    • p5.js Animation Exercise 1
    • p5.js Animation Exercise 2
    • p5.js Conditionals
    • p5.js Arrays and Lists
    • p5.js Simple Collision Detection
    • p5.js Reactors
    • p5.js Tiling and Repetition
    • p5.js Vectors
    • p5.js Animation Solution with Objects
    • p5.js Easing
    • p5.js Perlin Noise
    • p5.js Particle System
    • p5.js Sound
    • p5j.s Typography
    • P5js Archive
  • Programming in Processing (java)

/
p5.js Perlin Noise
Published Aug 17, 2021

p5.js Perlin Noise

Analytics

Loading data...

Noise algorithms are used all over the place in generative content , but they are also useful for any kind of interpolation when selecting from a distribution of values over x and y-dimensions.

One of the most common type of noises is Perlin Noise, which offers a particular smooth, natural-looking randomness. Perlin noise enables us to exert some control over the randomness of our variables, and is widely used for creating realistic textures, generative art, AI motions, and many more applications. The output is particularly useful in computer graphics where it can be employed in textures, flames, smoke, particles, etc.  

To create noise in p5.js we can use:

noise(x, [y], [z])

where x is x-coordinate in noise space, y is y-coordinate in noise space and z is z-coordinate in noise space. p5.js can compute 1D, 2D and 3D noise, depending on the number of coordinates given.

 

function setup() { createCanvas(600, 600); ellipseMode(CENTER); fill(155, 150, 220); noStroke(); } function draw() { background(255); let n; for (let y = 15; y < height; y += 30) { for (let x = 15; x < width; x += 30) { n = noise(x * 0.002 + millis() * 0.001, y * 0.002); let diameter = n * 30; ellipse(x, y, diameter, diameter); } } }

 

To modulate time we can use z parameter. Here we keep the position of the Perlin space the same, but modulate the movement of each square via the 3rd parameter.

 

let t = 0; function setup() { createCanvas(600, 600); ellipseMode(CENTER); fill(155, 150, 220); noStroke(); } function draw() { background(255); let n; for (let y = 15; y < height; y += 15) { for (let x = 15; x < width; x += 15) { n = noise(x * 0.002 + millis() * 0.001, y * 0.002,t); let diameter = n * 30; ellipse(x, y, diameter, diameter); } } t += 0.2; }

Exercise

Using Perlin Noise recreate a movement and/or shape, which resembles a natural phenomenon (snow, wind, clouds etc.)

 

{"serverDuration": 16, "requestCorrelationId": "7444fd10178349a98f5575335c1172e6"}