Imperfection
Algorithms produce output that is too perfect. Look at the colors and shapes in the renderers we've written. You can smell the math behind them. When we explore the physical world, we see splotches, cracks, and wobbles. How do we mimic these imperfections in our algorithmic output? With a careful application of randomness.
In this chapter, we explore two algorithms for generating random imperfections and several ways of applying imperfection to mimic natural phenomena. By its end, you'll be able to answer the following questions:
- If all we have is a random number generator that draws from a uniform distribution, how do produce coherent and organic randomness?
- What are the differences between value and gradient noise, and how are they computed?
- How do we extend noise into three dimensions?
- How do we apply noise to generate terrain and to simulate phenomena like clouds, wood, marble, and water?
The code provided in this chapter is written in pseudocode rather than TypeScript to avoid getting bogged down in details. If you find noise interesting, take ownership of these ideas and implement your own library.