## Saturday, December 3, 2016

### The Shape of Things To Come

In a couple of previous posts, I described how Dragons Abound makes "hand-drawn" lines and fills areas with scribbles.  These are some of the basic functions I need to create "hand-drawn" illustrations of mountains for maps, similar to these sorts of examples:
In this posting, I'm going to look at how to draw the shapes of the individual mountains and their shaded areas.  (In a later posting I'll look at how individual mountains are combined into small groups.)

The basic mountain shape is a triangle.  In my hand-drawn examples, there's quite a bit of variance between the two sides in slope and starting point:
To capture this, I'll add some code that will make the basic triangle shape vary in both ratio and slope of the sides:
Another feature of the hand-drawn examples is that the mountain sides are bumpy rather than straight lines:
In some cases the silhouette appears to be several mountains merged together -- and I'll get to that eventually -- but even the single mountains have irregular sides.  Following the example from /u/negative34 over on Reddit, I'll try using some gradient noise to displace the mountain sides.

My first attempt is to re-use the code that perturbs lines to make them look hand-drawn.  I'll also use a line-drawing routine that produces sharp corners rather than smooth curves, and make the mountains a little broader.

Sometimes this looks okay -- the first mountain here is not bad.  But often the mountains have odd spikes/bumps "sticking out", as in the second two examples.  I think the problem is that I'm adding perturbations at right-angles to the lines.  In the hand-drawn examples, the perturbations are almost always in just the height (Y axis) -- the bumps point up, if you will.   Here's what that looks like:
That looks much better to my eye.  I'll try twice as much perturbation:
That also looks pretty good to me -- some interesting silhouettes there.  (But notice something broke my scribbles on the first mountain.)  Doubling again:
That's perhaps a little too jagged for my tastes, and this is starting to look like a whole collection of smaller mountains than a single mountain.  There's also some breakdown in the actual polygon, where the perturbation has caused a piece of the polygon to "reverse".  A value somewhere between the first and second values seems about right to me.

Another adjustment to look at is how "curvy" to make the mountain outline.  I don't like the way the mountains look with significant curves:
But a small amount of softening of the vertices seems good:
One area where these mountains are still sadly deficient is the the shadow line down the center of the mountain.  In the hand-drawn examples, this line is usually wavy to suggest a ridge line:
To make the shadow line wavy, I'll perturb it using noise the way I did to the mountain outline itself.  But in this case, I'm perturbing in the X axis, to make the line curve back and forth, rather than up and down.  After playing around a bit to get a good level of noise, I have this:

This immediately makes the mountains look considerably better -- although perhaps I've just been staring at the straight shadow line so long it seems like a bigger change to me.  Human artists often draw a line down the ridge, so let me try that:
That looks okay, too, although it gives a kind of two-dimensional quality to the images.

Another thing I've noticed looking through the human-drawn examples is that the sides of the mountains are more often concave than convex:
Arguably this is because real mountains tend to have this sort of curve due to mass wasting, where the slopes of the mountain collapse downhill due to gravity.  The perturbation of the sides of my mountains sometimes produces this sort of profile, but I can help that along by making the starting point be a gentle concave curve:
The amount of curve here might look drastic, but seems to work pretty well once the mountain sides have been perturbed:
Now I want to look at the proportions of the mountain.  Looking at the human-drawn examples, it is striking how often the mountain (or mountain cluster) fits the golden ratio:
The golden ratio is said to "...yield pleasing, harmonious proportions" and is often seen in nature, so it's not surprising that it should be an intuitive choice for illustrating a mountain.  I'll take advantage of this to size my mountains (with some variation) around the golden ratio.

Using everything I've developed so far, let's compare the current mountains with the original:
Okay, pretty good progress!  :-)  Next time I'll continue refining these mountains, but here's the quick and dirty version of a mountain range: