Tuesday, December 31, 2019

New Mountain Style (Part 5)

In the previous posting I concluded the work on drawing individual mountains.  Now I'll work on drawing groups of mountains.

The current algorithm in Dragons Abound for drawing groups looks at each mountain location on the map in height order (tallest to smallest), draws an appropriately sized mountain there and then checks how much it overlaps previously drawn mountains.  If it overlaps too much, it's removed.  By tweaking the allowed amount of overlap, I can get different densities of mountains.  (Usually between 5-35% overlap.)
This creates a nice even density that is moderately attractive.  The main shortcoming is that it doesn't (except accidentally) give the impression of a mountain chain.  Often it produces what you can see in the example above, which looks like rows of horizontal mountains.

So how should I draw groups of mountains on a map?  I asked /u/greypawz (the author of the reference map I'm using) and he said this:
I generally start off with a line to draw around. In the case of western coast, the line traced a subduction zone I envisioned off the coast. It's really only a rough guideline. I fill in the area mostly randomly, trying to form parallel mountain ranges and/or perpendicular mountain ridges coming off of high peaks.
If I can project a bit from his description, it sounds like he uses parallel (and sometimes perpendicular) mountain chains to fill in an a mountain area.  You can see a little bit of this in parts of the reference map, as in this example:
Here you can see how roughly parallel mountain chains fill the mountain area.  (With some other mountains thrown in fill out the area.)  This is similar to the way parallel hatching lines fill in the shaded areas, except the hatching lines are mountain chains.

To try this out, I'm going to need the capability to draw mountain chains rather than just single mountains.  The reference map I'm using for this mountain style connects individual mountains in a number of ways to make a more coherent grouping.  I covered these in detail back in the post that started this series, so I'll just recap here.

One way to chain mountains is to connect the left end of a topline with the bottom end of the ridgeline of the mountain that is to the back and left of the front mountain:
This creates a chain of mountains going right and down across the page.  

The reverse of this connects the ridgeline of the rear mountain to the right topline of the front mountain:
This creates a chain of mountains going left and down the page.

Another way to chain is by connecting the end of a ridgeline to the peak of another mountain to form a continuous ridgeline across several mountains:
This creates a chain of mountains going straight down the page.

I'll begin by trying to draw mountains which connect the left end of a topline with the bottom end of a ridgeline to create a ridge of mountains going down and right.  I do this by drawing the mountains from back to front, and setting the origin of each mountain (which is the left end of the topline) to be the end of the previous ridgeline.
I had expected this approach to need some tweaking, but this looks remarkably good as is.  (Note that I'm just randomly selecting mountain sizes at this point.)

The flip of this approach connects the end of the ridgeline to the right sides of the topline, to create a chain that goes down and to the left.
Because mountains are broader than they are tall, this creates a line with a shallow slope.

One minor problem with drawing mountains this way is that the ridgelines and the toplines can fade out near the end.  When this happens the lines do not meet up to form a continuous line through the whole chain.  Visually this isn't a huge problem, but it's easy enough to turn off the line fade when I'm drawing a mountain chain:

The final chaining approach is to connect the end of the ridgeline to the peak of the next mountain to create a chain that runs roughly vertical.
This doesn't work as well, at least partly because the resulting spine down the chain of mountains looks too regular.  I can address that by using noise to snake the mountains a bit:
This looks better, but now the ridgelines don't always connect up to the following peak.  I can fix that by drawing in an additional line segment.
This is occasionally a little awkward when a small mountain is next to a big mountain.  I don't think that will happen a lot on the maps but we'll see.

So now I can chain mountains, but only in three directions: a slight slope left, a slight slope right, and vertically.  But there's an easily generalization of this chaining that allows other directions.  The key insight is that the chaining connects a point on the topline of the front mountain to the end of the ridgeline of the previous mountain:
To chain to the right you connect the left end of the topline to the previous ridgeline (red).  To chain straight downward, you connect the middle of the topline to to the previous ridgeline (blue).  And to chain  to the left you connect the right end of the topline to the previous ridgeline (green).  But you're not limited to connecting at those three points.  You can connect at any point on the topline to create an arbitrary direction for the mountain chain.

(Note that I'm straying from my “new" philosophy not to over-generalize all of the code.  In this case, I think it's necessary to make a more flexible routine to fill areas with mountains, but I recognize this is probably just justification for my natural inclinations.)

It's difficult to calculate where on the topline you should intersect to create a chain at a given angle, but extrapolating along the length of the topline gives a rough approximation.  For example, a 45 degree-ish angle:
This is not quite as visually pleasing as the three cardinal directions.  I suspect there are some ways to draw this that emphasizes the mountain chain more.  For example, I did a quick experiment where I eliminated the right top line after the transition to the ridgeline:
This makes the chain of mountains as a long ridge much more visually obvious.  It's getting close to a style of mountain illustration that uses long ridges rather than individual mountains.  This quick experiment has some obvious problems, but it's an idea that might be worth revisiting another day.

Arguably this method of creating a mountain chain is not much different/better than just overlapping mountains along the same angle, but I think the connection of the ridgeline to the following topline helps the chain look more unified than mere overlapping.

As I did with the vertical mountains, I can use some noise to perturb the line of the mountains slightly.  With the right parameters, this often creates mountain chains with a pleasing slight arc to them:
Or a slight S shape:
Although as with all uses of noise you're somewhat at the mercy of the random numbers.

Finally, here's an experiment where the mountains are higher in the middle of the chain rather than entirely random:
Perhaps that helps create the illusion of a connected range.  

For reasons that will eventually become apparent, it would be nice if I could extend this mountain chaining technique to follow a line.  This turns out to be considerably more difficult than the algorithm above.  As I place mountains along the line, I need to find the spot where the center of the next mountain is on the line *and* the end of the previous ridgeline touches the topline of the mountain.  Solving either constraint is easy, but solving them both simultaneously is very difficult. 

My solution was to place the new mountain on the line and then slide it back and forth on the line to find a spot where the end of the previous ridgeline just touches the topline of the new mountain.  An iterative and not particularly efficient approach:
The advantage of this approach is that the centerpoints of all the mountain lie along the line, so the mountain chain follows the line perfectly.  The disadvantage is that mountains don't always connect the same way, so there's some loss of visual continuity.  For example, in the vertical stretch of mountains above, they don't all connect ridgeline to peak, so there isn't as clear a “ridge" of mountains.

Now if I want to add some natural looking variation, I can use noise to perturb the line and the mountain chain will follow along:
Next time I'll experiment with using these mountain chains to fill in mountain areas on the map.

No comments:

Post a Comment