Yes, it's official, I'm now severely addicted to HLSL. The raw power that it opens up for Project: A New Reality is simply mind-blowing. Experimentation with all sorts of random ideas has led to some pretty cool-looking terrains, though I'm going to spare the blog from any further screenshot explosions until I have something really draw-dropping.

Here's an interesting example of a neat heightmap shader. The algorithm is as follows:

  1. Generate a Perlin Multifractal [1]
  2. Generate a Perlin Multifractal [2]
  3. Reduce the bit depth of (1) by using the function y = a * floor(y/a), where a is the number of discrete levels to allow [3]
  4. Generate a final heightmap by blending [1] and [3] with [2] as the blending function

Basically, that's a complicated way of saying take a heightmap, force it into discrete levels, then blend it back on itself with another fractal function.  This way, natural-looking terraces appear but blend smoothly back into the terrain.

This example heightmap is a little too aggressive with the terraces, but that can, of course, be easily modified by fooling with the blending function.