I'm looking to replicate a procedural terrain effect I found on a portfolio/blog site a few days ago.

Terraced terrain

Quoting the site, the terracing was generated through, "multiplying [the final height] by some damping value within a certain height range, to create beautiful canyon features."

I was wondering, would anyone be able to provide a more technical example or procedure for going about this? Over the past week, I've been researching and learning a lot about procedural terrain/texture methods and practices but I still haven't come across anything that explains in detail what 'clamping' is, and I'm starting to become frustrated.

  • \$\begingroup\$ Huh, that's really neat. I can't figure out what he means either. Have you tried sending the dude an email (it's available under "contact")? \$\endgroup\$ – Draco18s Feb 5 '16 at 21:28
  • \$\begingroup\$ FYI: In your quote & source, the term is 'damping', but later in your question you use 'clamping' instead. \$\endgroup\$ – Pikalek Feb 7 '16 at 15:53

I don't know what their project does but you can apply a reshaping function to height. Here's an example that takes h from 0.0 to 1.0 and returns a new height from 0.0 to 1.0:

function R(h) {
    var W = 0.4; // width of terracing bands
    var k = Math.floor(h / W);
    var f = (h - k*W) / W;
    var s = Math.min(2 * f, 1.0);
    return (k+s) * W;

It's a function that looks like this when plotted — the x axis is the original height and the y axis is the new height:

Height reshaping function

I applied it to my own code and got this:

Output of terracing function

You can put in any sort of reshaping function, or chain them together, to get neat effects. You get terraces when there are flat sections of the output.

  • \$\begingroup\$ I swear there's a smooth path in the asker's question that goes up a terrace, but looking at it again, I'm pretty sure its an illusion. But my eyes still insist that no, there's a height change there (center of the image to the top corner/top left edge). If there is no rise, then this answer is correct. \$\endgroup\$ – Draco18s Feb 6 '16 at 8:08

Damping is physics term for an influence within or upon an oscillatory system that has the effect of reducing, restricting or preventing its oscillations.

I suspect your source article might have a typo & have meant clamping, which generally refers to restricting a value to a given range.

As for achieving the visual effect, you might be able to get something similar by clamping bands of noise as the terrain is being built up, but the solution given by @amitp more closely matches the original description & is probably easier to implement & tune.

A third option might be to use erosion techniques. Here's one for creating a cliff & beach combination by dropping a section of sloped land. Here's another that can erode peaks into plateaus.


After a very long break, I now understand how the effect was achieved, and it's incredibly simple. There are 4 parts to this effect:

  • The initial heightmap of the terrain
  • Defining a terrace 'range', with the lowest height of the terrace being h1 and the highest height of the terrace being h2
  • A damping value that flattens out the ground within the range of the terrace height
  • A second, longer-range heightmap to modify the h1 and h2 values, which is how the continuous ramps between terraces are formed (a third heightmap could be used to increase or decrease h1 and h2 independent of eachother, creating larger or smaller terraces)

Here is the procedure to create the effect:

h1 = 1
h2 = 2
damp = .01

h = gen_noise(position)
hm = heightmod_noise(position)
if h1+hm <= initial_terrain_height =< h2+hm
  th = h * damp
elseif h2+hm < h
  th = h - (h2-h1) * damp
  th = h

(th, of course, is the height of the terrain after the terracing effect is applied)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.