Random Values
We can generate random values using a pseudorandom number generator: Example
X | 1 | 2 | 3 | 4 | ... |
rand(X) | 28 | 21 | 96 | 96 | ... |
Visualization
Code
import random
randX = [random.randint(0, 100) for x in range(0, 50)]
print(randX)
Noise
Many areas of procedural generation require random values, but the randomness needs to look more organic: Visualization
This is the job of a noise function. It produces random data, but the data has an underlying organic nature.Higher Dimensions
- The above examples were in one dimension
- X is an array of numbers, for each number in X there is a corresponding value.
- However it is often useful to generate noise for 2 or more dimensions:
- In the above example a random value is assigned to each (x, y) coordinate pair:
- 2D noise functions are often used to generate terrains in which the height values are the result of the noise function applied to each point.
- Noise functions can be extended into 3 or more dimensions:
- For example, a 3D noise function could be used for modelling gas. The random value at each 3D point could describe its density.
- 3D noise functions can also be used to animate 2D noise functions:
- A 3D array of data is produced and then cut into a series of 2D slices.
- You can then convert each slice into an individual frame of an animation.
- This can then be used for when you need 2D noise that changes over time, such as when animating the formation of clouds.