Consider the code you would write to draw a colored square. Your code would require several values: horizontal position, vertical position, width, height, the RGB values.
Where do those values come from?
|Hard Coded||You want specific control of the value.|
|Parameters||You want to be able to control the value from a larger context.|
|You want random variation.|
|You want controlled variation.|
Often you use these in combination:
width = 100 + random(-10, 10);
random() is a good way to add variation to a value. The
noise(x) can often offer variation with greater control and consistency.
noise(x) function returns values sampled from Perlin Noise. Perlin Noise provides random values that are aesthetically arranged (band limited and visually isotropic) in space. These values are a useful basis for many applications that require natural-feeling variation.
Repeated variation is easy with
noise(x): every time you call
noise(x) with a particular argument, you get the same value back. This is often very useful. For example, in an animation you often need variation to be consistent from frame to frame.
random()requires no arguments and returns a different random value every time
noise(x)requires an argument and returns the same random value every time
xtakes some practice.
noise(x)is so useful.
By controlling what you pass to
noise(x), you can control the frequency of the random values returned. This can be used to control how quickly values vary in space and time. Like
random() values, you can scale and shift the values from
noise(x) to the range you need. You can also adjust the character of
noise(x, y, z)
When you call
noise(x) you have to pass in an
x value. This x value is the location in the Perlin Noise of the value to return. Choose
x based on how you want the value to vary. You can pass in
millis() to get values that change over time.
noise() actually takes up to three parameters:
noise(x,y,z) allowing you to receive values arranged in three dimensions (see below).
You can control how quickly returned values will vary over time and space by scaling the value you pass in for
n = noise(frameCount); // get a value that changes over time n = noise(frameCount * .1); // get a value that changes over time slowly n = noise(frameCount * 10); // get a value that changes over time quickly
noise(x) function returns values in the range of 0 to 1. Use multiplication and addition to shift this range to the range you need.
n = noise(frameCount) * 10 + 10; // values between 10 and 20;
You could also use
n = noise(frameCount); // 0 -> 1 n = map(n, 0, 1, 10, 20); // map to 10 -> 20
noiseDetail() function allows you to control the “roughness” or “detail” of the noise returned. See: p5 reference
By default, every time you restart your sketch the noise pattern will be different. The
noiseSeed() allows you to manually set the noise pattern seed. See: p5 reference
Ken Perlin on Procedural Textures
clicktorelease.com: Fireball Shiny Dynamics: Blender Wood Modo: Marble
OpenCL Perlin Particles from Eddie Lee on Vimeo.
Keep Sketching! This week, focus on using the
noise() function. Use
noise() in a variety of ways. Use 1D, 2D, and 3D noise. Try using high, mid, and low frequency noise. Try using noise to control different things: position, size, color, rotation, etc. Think about tile graphics,
random(), and parameters while you work. Consider combining these concepts with
Don’t forget to sign up for orientations for the Laser Cutter and 3D printer.
Make a program that generates treasure maps.
Your maps should:
Things to consider:
When posting your map: