Tuesday, January 7, 2020

New Mountain Style (Part 6)

Now that I'm able to draw mountains in the new style and piece them together to make mountain chains, I want to work on using them on maps.

In the current approach Dragons Abound uses, mountains are drawn by looking at all the locations in the world from highest to lowest and trying to draw a mountain in each location.  If a mountain is drawn and it overlaps too much with mountains that have already been drawn it is rejected and the next location is tested.  With proper tweaking, this produces areas of mountains that are nicely filled with a pleasing amount of overlap that visually connects the individual mountains into a mass:
But as noted previously, this doesn't create mountain chains except accidentally.

Using mountain chains on the map requires a different approach to drawing mountains.  Rather than looking at individual map locations,  I will have to identify areas of mountains and then try to use mountain chains to fill in those areas.  Fortunately I already have a routine that subsets the map and draws polygons around the identified areas:
Here the red line (somewhat relaxed) circles groups of map locations with mountain height.  I've excluded smaller areas, since they're likely too small to fit a mountain chain.

Once I have a mountain area, how do I fill that with mountain chains?  My initial approach is to find the long axis of the area and run mountain chains parallel to that axis:
This is very similar to the way I add hatching to an area of shadows.

To figure this out, let me first set up a test polygon:
Now I'll re-purpose the shading code to identify some lines for mountain chains:
Here I just picked an arbitrary slope for the lines.  Let me find the longest chord for the polygon and use that as the slope instead:
So now I can use my line-following routine to draw mountains along those lines.
One thing to note is that the lines are inside the polygon, and the mountain centers are on the lines, but the mountains themselves may stray outside the polygon.  Generally I don't think this will be a problem on the map, because there's no indications of the areas other than the mountains themselves.  

In the above example, the mountain chains are too obviously regular, so let me add some noise to the lines:
Here I'm using the same noise source for all the chains, so the perturbations are somewhat correlated.  Note that this worsens the problems of straying outside the polygon, because perturbing the lines can cause them to be outside the polygon.

When filling in an area with mountain chains like this, not all mountains should be so obviously part of the chain, so I can put in some more mountains to fill out the area.  To do this I'll use Poisson disc sampling (which I described here) to fill the polygon with a psuedo-random locations:
And then I'll try putting a mountain at each blue dot and if it doesn't overlap too badly with an existing mountain, I'll keep it:
Here I've drawn the fill mountains in red.  One problem with filling in after the chains are drawn is that the fill mountains aren't drawn from the top to the bottom, so they overlap incorrectly.  At the end of all mountain drawing, I need to go through the list of all mountains from top to bottom moving them up to the top of the drawing.  This puts them all in the correct order.
It doesn't take many fill mountains to break up the uniformity of the mountain chains, but by looking at more points and accepting more overlap, I can make it more dense:
Although I think even here the mountain chains are evident.

Next time I'll try the mountains out on a map.

2 comments:

  1. I check for updates almost every day, glad to see this project is still going strong! Great Stuff!

    ReplyDelete