Advertise here with Carbon Ads

This site is made possible by member support. โค๏ธ

Big thanks to Arcustech for hosting the site and offering amazing tech support.

When you buy through links on kottke.org, I may earn an affiliate commission. Thanks for supporting the site!

kottke.org. home of fine hypertext products since 1998.

๐Ÿ”  ๐Ÿ’€  ๐Ÿ“ธ  ๐Ÿ˜ญ  ๐Ÿ•ณ๏ธ  ๐Ÿค   ๐ŸŽฌ  ๐Ÿฅ”

Fractal Terrain in Javascript

Hunter Loftis has built a terrain rendering engine in only 130 lines of Javascript. Here’s what the output looks like:

js terrain

Programmers tend to be lazy (I speak from experience), and one nice side effect of laziness is really brilliant ways to avoid work. In this case, instead of spending mind-numbing hours manually creating what would likely be pretty lame rocky surfaces, we’ll get spiritual and teach the computer what it means to be a rock. We’ll do this by generating fractals, or shapes that repeat patterns in smaller and smaller variations.

I don’t have any way to prove that terrain is a fractal but this method looks really damn good, so maybe you’ll take it on faith.

You can try it out here…reload to get new landscapes. Callum Prentice built an interactive version. This obviously reminds me of Vol Libre, a short film by Loren Carpenter from 1980 that showcased using fractals to generate terrain for the first time.