Graphics Gems GLSL - Perlin Noise
Perlin Noise, introduced by Ken Perlin in 1985 and featured in Graphics Gems II, revolutionized procedural texture generation. This gradient-based interpolation technique creates seamless, natural-looking noise that has become the foundation for countless visual effects in games, films, and real-time graphics.
Interactive Demo
Move your mouse to rotate the camera and explore the 3D volumetric cloud. The cloud is generated using Perlin Noise with multiple octaves (Fractal Brownian Motion):
Mathematical Foundation
Perlin Noise works by:
- Grid-based gradients: At each integer grid point, assign a random gradient vector
- Distance vectors: For any point, compute vectors to the 8 surrounding grid corners (in 3D)
- Dot products: Compute dot product between each gradient and its corresponding distance vector
- Interpolation: Smoothly interpolate the 8 dot product values using a smoothstep function
The Algorithm
For a 3D point , Perlin Noise:
- Find the 8 grid corners: ,
- Get gradients at each corner:
- Compute dot products:
- Trilinear interpolation:
Where is the smooth interpolation factor.
Smooth Interpolation
The smoothstep function ensures continuity:
This creates a smooth S-curve that eliminates discontinuities at grid boundaries. The function satisfies , , and has zero derivatives at both endpoints.
Fractal Brownian Motion (FBM)
By combining multiple octaves of Perlin Noise at different frequencies and amplitudes, we create Fractal Brownian Motion:
Where:
- is the amplitude of octave (typically )
- is the frequency of octave (typically )
This creates natural-looking patterns with detail at multiple scales—perfect for clouds, terrain, marble, wood grain, and more.
Applications
Volumetric Clouds
The demo above uses FBM to create volumetric clouds:
- Multiple octaves create detail at various scales
- Density is computed from noise values
- Lighting uses noise gradients as normals
Terrain Generation
Perlin Noise excels at terrain:
- Use noise as height maps
- Combine multiple octaves for realistic landscapes
- Add domain warping for more complex patterns
Procedural Textures
Create endless variations:
- Marble: Use noise as a coordinate for sine waves
- Wood: Use noise along one axis for grain patterns
- Stone: Combine multiple noise layers
Performance
Perlin Noise is remarkably efficient:
- Runs at 60 FPS on modern hardware
- Even works well on mobile GPUs
- Can generate complex scenes in a single shader pass
The key is the grid-based structure, which allows efficient computation without expensive random number generation per pixel.
References
- Graphics Gems II (1991) - "An Image Synthesizer" by Ken Perlin
- Perlin Noise on Wikipedia
- Improved Perlin Noise - Ken Perlin's improved version
Related Articles
- Graphics Gems GLSL - Fast Noise Functions - Alternative noise implementations
- Graphics Gems GLSL Series Index - Return to series index