At a glance:
   Generating Complex Procedural Terrains Using the GPU

  - Read the Entire Chapter Online !
  - Download Demo & Shader Source Code (HLSL)
  - Download Partial Demo Source Code (MS Visual C/C++)
...the demo-specific parts; unfortunately, I can't share the underlying rendering engine code, but what is here should be extremely helpful.
  - Back to Geisswerks

I wrote this chapter & demo in 2007, for the Nvidia-published book, GPU Gems 3. It covers a set of novel techniques that I developed to use DirectX 10 and the GPU to create amazingly complex terrains purely on the GPU, on the fly, at interactive framerates. Note that these terrains can have plenty of overhangs - they're not just height maps!

In brief, the technique uses several octaves of noise (via 3D textures), the marching cubes technique, and the Stream Out functionality offered in DirectX 10 to create 3D blocks of terrain (at varying sizes and levels of detail, depending on where the camera is) to synthesize an entire fractal world - at interactive framerates, because the entire thing runs on the massively-parallel GPU.

There are no secrets here - the intent was to share this knowledge as completely as possible. Everything you would need to know to develop your own app (or game) based on this technology is right in the chapter (and in the source code above).

Also, this code was meant to run on a Geforce 8800; if you run it on a newer GPU, and tweak a few parameters (see bin\args.txt), you'll be able to fly through fractal worlds of even greater beauty and detail.

Required hardware: GeForce 8800 or better and Vista or later (for DirectX 10).

Some typical screenshots:

  This movie shows some more of the close-up details of the rock structures. (28 MB)
To the right is the best movie of the three; you can see how the LOD (level of detail) works, and there are good examples of the funky, alien shapes and the ambient occlusion (lighting). (33 MB)
  Short movie (quicker download - 5 MB)

Realistic lighting is very important. Below, ambient-occlusion-style lighting is generated (in realtime) for each vertex created, by casting a few dozen rays out in all directions, and seeing if they hit the terrain or not; the fraction that can escape determines how bright the pixel is. This image shows you just the ambient-occlusion lighting; there is no normal-based lighting, or texturing.

A distant view of the lowest-octave features of a fractal planet.