10
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\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\$ Commented Feb 5, 2016 at 21:28
  • \$\begingroup\$ FYI: In your quote & source, the term is 'damping', but later in your question you use 'clamping' instead. \$\endgroup\$
    – Pikalek
    Commented Feb 7, 2016 at 15:53

5 Answers 5

11
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\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\$ Commented Feb 6, 2016 at 8:08
4
\$\begingroup\$

I wanted to smooth out the edge between a terrace and its cliff and made this function for it:

sin((x - round(x)) * 2.45)^11 + round(x)

Here is a plot of the curve:
enter image description here

You can find an interactive preview on Wolfram.

The higher the exponent (eg. 11) the steeper is the cliff.

The constant 2.45 is empirically (trial and error) found value. Its purpose is to make the terraces connected. It depends on the exponent. I would be delighted if someone would figure out a way to exactly compute the value. I think it should be the x where first derivative of sin(x)^11 is one.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You can use the function round(x) + 0.5 * (2*(x - round(x)))^exponent to get a version that works for any positive odd exponent without an extra tuning constant to adjust. It also saves you a trig function so you can evaluate your noise a little faster. 😊 \$\endgroup\$
    – DMGregory
    Commented Jan 21, 2021 at 20:16
  • \$\begingroup\$ @DMGregory that is great improvement! thank you very much. \$\endgroup\$
    – Tomas
    Commented Jan 23, 2021 at 8:29
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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
else
  th = h

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

\$\endgroup\$
0
\$\begingroup\$

I'd like to add, Pikaleks response above mine is perfect but additionally you can use a "moisture map" calculated with a different noise seed and affected by your elevation/temperature maps, then use that moisture map to control the power of the terracing to introduce "ramps" between terraces with more realistic accuracy.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .