HeadlinesBriefing favicon HeadlinesBriefing.com

Perlin Noise Algorithm Explained

Hacker News •
×

Noise, a fundamental concept in procedural generation, is essentially a collection of random values generated by a function. This function takes N parameters and produces a value based on specific rules.

Noise can be classified by its dimensions (1D, 2D, 3D, etc.), and its output range varies by algorithm. 2D noise is particularly useful for implementation and visualization via textures. A basic pseudocode for generating a texture involves iterating through pixels, feeding normalized coordinates to a noise function, and setting pixel colors based on the output.

While a simple `rand()` function can produce noise, it often lacks discernible patterns. Coherent noise, a smoother version, exhibits features and patterns while retaining randomness. Key properties of coherent noise include consistent output for the same input, small output changes for small input changes, and random output for large input changes.

Ken Perlin developed his famous Perlin Noise algorithm in 1983 to overcome the "machine-like" appearance of early CGI. He formally described it in a 1985 paper and received an Academy Award for Technical Achievement in 1997. The algorithm works by considering the nearest integer grid points to an input point, calculating random unit vectors at these corners, and then interpolating the dot products of these vectors with vectors pointing to the input point. A disadvantage is that the algorithm relies on precalculated vectors and a permutation table (often of size 256), leading to repetition after this range.