Fractal terrain generation in 130 lines of Javascript

Hunter Loftis's Javascript-based fractal terrain generator produces absolutely gorgeous landscapes (reload for more) in just 130 lines. It's accompanied by a great explanation that reveals the sweet, underlying elegance of the process.

If you're anything like me, the results of this simple algorithm leave you itching to go build an online Terragen, a jetpack-based first person shooter, fishing simulator, MMORPG, etc. This single-cube, canvas-projected demo practically begs for extension.

Here are a few things I challenge you to try:

WebGL rendering

Variation by height, where lower altitudes are smoother (like sand) and higher altitudes are more rocky

Cast shadows instead of purely slope-based shading

A second pass that generates caves and tunnels

Realistic terrain in 130 lines

(via Kottke)