Wednesday, December 18, 2019

New Mountain Style (Part 4)

Recall that last time I worked on drawing the toplines for the new mountain style:
I'll start off this time drawing the ridgelines.  These are the lines that start at the peak of the mountain and come down towards the viewer:
Looking at how these lines are drawn, it seems that they're usually about the same weight and color as the toplines.  They often fade out and trail off at the end of the line.  Like toplines, they are often given extra weight near the peak on the taller mountains.  The actual ridgelines have already been created, so it's just a matter of drawing them in this manner.
Ridgelines can also have secondary toplines coming out of them.  Secondary toplines come out of angles on the ridgeline and run parallel to the topline.  These are drawn in the same way as the toplines but fade away more quickly.
The last element to draw on the mountains are the secondary ridgelines.  These are ridgelines off secondary peaks that define a mountain facet, as in these examples:
About 90% of the time these lines are drawn in, usually at about the same strength as the topline.
The biggest mountains almost always have these lines; other mountains have them occasionally.

This completes the outline of the mountains; let me move on to shading.
As this excerpt illustrates, mountains are shaded with a hatch pattern.  Most mountains have the area between the ridgeline, unlit side topline and baseline shaded in with hatched lines roughly perpendicular to the topline.

To start with, I'll construct a polygon using the unlit topline and the ridgeline to create the shading area.  I'll fill it with yellow to see if I've got it correct:
That looks right, but shows a different problem.  If I draw the shading last, it will go on top of the outline.  I want it to be under the outline, so I need to draw it first.
That looks better, but the secondary ridgeline areas are getting shaded, and they should be left out.  I can do this by using a boolean polygon operation to take the difference between the shading polygon and the secondary ridgeline polygon -- essentially cutting that out of the shading polygon.
This removed the shading from the secondary ridgelines on the unlit side.  Now I need to do the opposite and add shading to the secondary ridgelines on the lit side.  I didn't distinguish the secondary ridgelines on one side of the mountain from those on the other side, so I can't easily tell which ones to shade.  I could compare to the mountain peak, but it's probably better to go back and refactor the code so that I have them as two separate lists.  When that's done I can then iterate through the secondary ridgelines on the lit side of the mountain and add shading to them:
I now have the shading areas correct.  Next I will work on switching over to use hatching to shade the mountains.  Fortunately, I've already implement a hatching fill routine, so it's pretty easy to switch to hatching (at least with the default parameters):
This looks pretty good, but there are a number of improvements that I can make.  The first is to improve the mountain's baseline, which looks unnaturally straight.  To start with I can add a slight curve:
That helps the mountain look three dimensional.  Now I can perturb the line to make it look a little more natural.
The baseline will be less obvious when it isn't drawn in, but I want just enough perturbation to break up the straight line.  This mountain style is pretty graphical, and a heavily perturbed line would look out of place.

A subtle effect I can add is to sometimes start the shading line early or late, or end it early or late, so that the hatching doesn't always perfectly align with the outline.
This helps the shading look less mechanical.  A similar subtle effect is to trail off some lines by reducing their opacity:
The next thing to tackle is more substantial.  In certain situations, the direction of the hatching changes to distinguish two surfaces.  One situation is on either side of a secondary topline, as in this example:
This change of direction visually separates the two surfaces and helps create the 3D illusion.

To do this, I have to separate the single shading area into two areas along the secondary topline and rotate the hatching angle on the second surface.  Creating the shading areas requires a couple of fixes to my existing code.  First, I need the secondary toplines to come all the way to the baseline (even if I don't draw them all the way).  Second, I need to make sure the secondary toplines are always in order from the top of the peak downward so I can pick off the areas in the same order each time.  With that in place, I can try to limit the first shading area to the first secondary topline when it is present:
Here I've outlined the first shading area in blue, and you can see in the highlighted examples that it is limited by the secondary topline when one is present.

The second shading area is the other side of the first secondary topline, and gets a hatching that is parallel to the secondary topline:
A few mountains on the reference map have a third shading area when there is a second secondary topline on the unlit side, but I'm not going to bother with that.

That concludes drawing the individual mountains.  Next time I'll work on placing mountains in a group.

No comments:

Post a Comment