PDA

View Full Version : May/June Lite Entry: Gulf of Malabor



gilgamec
05-21-2009, 08:06 PM
Hi, all! Long time lurker, first time poster here. This month's Lite Challenge seems like as good a time as any to try my hand (as well as forcing me to actually make progress!)

My main problem is that I can't draw; no, not at all. I'm also not especially artistic. Fortunately, I have a degree in computer graphics, so I can play to my strengths and try to make a map completely procedurally. Ideally, I'll be able to press a button and get a new map every time. I'm going to have to sacrifice some niceties, of course, but hopefully I can design around that too.

So, I'll try to develop a reasonable procedural style over the next month, and hopefully post some WIPs here as I go.

First things first. We need coastline and islands. Let's try a sea basin, surrounded by the mainland, a couple of islands, and a peninsula. I pulled out the ol' tablet and sketched a simple outline:
13513

Now to make it a little more rugged, we add a little fractal noise to get
13514

Looks decent enough for a first start. Add a little splash to get my first checkpoint.
13515

Gandwarf
05-22-2009, 05:18 AM
Welcome Gilgamec, good to see you delurking for a challenge.

Steel General
05-22-2009, 07:09 AM
Fresh meat!!!! :D

msa
05-22-2009, 08:27 AM
Gil! Glad you delurked, and nice start! I might recommend making the lines a little thinner... I did my first few maps with very thick lines but grew to dislike it quickly.

PS. Kudos on using the word 'checkpoint'

gilgamec
05-23-2009, 12:55 AM
Thanks everybody for your kind welcomes!

The biggest problem I had with creating the last checkpoint was speed. Going from smooth curves to fractal coastlines takes about a minute for a 2kx2k image ... but rendering just a simple version (like the colored image above) with coastline impressions is s.l.o.w. ... over an hour for 2kx2k. I can get (or at least fake) the same thing in Photoshop in a couple of seconds, so clearly I'm doing something wrong.

So, rather than reinvent the wheel (not that that's not fun sometimes!), I'm going to move as much of the rendering as possible into a dedicated program. Parentheses make me nauseous, so it looks like I'm doing Photoshop scripting.

The biggest thing I'm losing is that everything takes place at a fixed resolution. Before, everything was in vector format and so resolution-independent. Illustrator- or Inkscape-scripting may be possible, but I'll leave them for the next Challenge.

Scripting Photoshop is not too bad, though the less-often-used commands have to be accessed through the general event system, which is cryptic to say the least. Finally, though, I've managed to get the hang of the system. For a quick example, I've recreated ... err, stolen the land and sea styles from RobA's regional map tutorial (http://www.cartographersguild.com/showthread.php?t=1142):
13560

Time to build from scratch: about a minute. (Mostly in the coastline-building step, like above. I'll improve that soon, hopefully.)

gilgamec
05-26-2009, 12:58 PM
Even though I'm using Photoshop for compositing and special effects, I'm still going to keep as much computation as possible in my own code. This has several advantages:


Flexibility - most of what I can do easily myself isn't offered in stock Photoshop filters. There might be custom plugins to do these things, if I could find them and were willing to pay for them.
Controlability - The parameters used by both the basic Photoshop filters and other plugins are designed to be used interactively, and so they don't suit my purposes very well.
Reproducibility - Photoshop's built-in Clouds filter, for example, provides quite nice fractal noise. However, besides the problem of controlability (how do I change fractal dimension, scale, or any number of other parameters?), there's the matter of reproducibility: it's different every time I call it. Within the context of one image, this is fine: I can save it and use it again. But what if I want to render a version in higher resolution? Since my coastline is based on fractal noise, it would change every time I change resolution (and have to rerender the noise).

For all of these reasons (plus, it's more fun this way!), I'm keeping everything I can out of Photoshop. For instance, here's a version of the map with coloration by altitude. The altitude in this case is created by a multifractal, which increases fractal dimension (makes the terrain spikier) at higher altitudes.
13641

I've also moved what lighting effects I can into my own code. For instance, rendering the above with Lambertian lighting on the terrain gives:
13642

(I've also done some work on rivers, which I'll leave for the next update.)

gilgamec
05-29-2009, 09:27 PM
Now that I've got a height map, making rivers is simply a matter of following the slope of the terrain. First, though, I have to fill up basins in the terrain. In nature, basins could fill up with either sediment or water; to make things simpler, I fill them up with sediment, which turns them into gently sloping plains. Running rivers from each point in the direction of greatest downhill slope gives a first approximation at the river systems:
13765

It looks cool, but it's a bit ridiculous. To improve on this, I calculate a graph of river connectedness instead of an image. Then I can do a few things to make the rivers look nicer:


Decimate the rivers, i.e. remove most of the points. This cuts back on the high-frequency wiggles and makes the rivers look more map-like.
Connect the remaining points with smooth curves, rather than straight lines. This makes the rivers look smoother and more undulating.
Don't draw all of the rivers. I'm only drawing the "major" rivers; in this case, those whose drainage basin is sufficiently large, at least 1/3 the size of the largest. I then only draw "major" tributaries, which in this case is those which make up at least a third of the river's total flow at that point. I then stop rivers when they get too small.

I then stroke the rivers with a pen whose width depends on the size of the river at that point, and get something like
13766
which I like very much.

I'm still not crazy on the distribution of rivers, though. I'm probably going to work on that next.

msa
05-29-2009, 10:18 PM
You are as awesome as you are insane for doing this in code. I can't wait to see how this works out. I have a secret (or not so secret) obsession with randomly generated maps from playing too many roguelikes.

In any case, consider yourself reped, you crazy freak.

Regarding the reproducibility point, the solution is to generate your noise and save it in a layer, and then just duplicate that layer over and over. I'm not saying that invalidates your mad designs, but its at least how you address that problem.

Good luck!

ravells
05-30-2009, 05:55 AM
I can't believe this is mostly done in code! This is tremendous and one of the most exciting things I've seen on the Guild for a long time. Repped!

Steel General
05-30-2009, 11:17 AM
Very cool - not something I would even think of attempting to program. *thumbs up*

gilgamec
06-02-2009, 07:20 PM
The biggest problem I have with my last version (13766) is that the rivers on the eastern side of the Gulf don't run through the thin strip of mainland shown on the map; instead, they all originate in the low hills about 100 miles inland. I was hoping for more of a sense that there's a huge continent off to the east of the map we see, so we might get something like a Mississippi running through the hills and into the Gulf of Malabor. This turns out to be harder than I'd like. I've spent the last five days on this, and haven't really been able to get the kind of effect I like.

First, I'm going to separate the "hills" I'm looking for on the northern arm of the mainland from the "mountains" I want to get in the south. The only way to do this is to specify the general course of the mountains in my original sketch:
13876
This gives a lot more heterogeneity in the heights, which looks much better.

I've also settled on simulating the continent to the east by generating a random terrain, running rivers through it, and recording the sizes of these rivers at the edges of the terrain. I then use these rivers as "seeds" for the rivers on the map itself. This gives us something like
13877
I'm still not entirely happy with this. With only a week to go in the Challenge, though, I'm going to have to move on to other things, like the (required) forests and settlements, along with labels and the like.

I'd still like to revisit the rivers at some time in the future, but it might be with the next Challenge, or as a general WIP.

Redrobes
06-02-2009, 08:42 PM
This is some great stuff. I was wondering how far you could take it. I was interested in the basin filling bit mainly as I think that can be quite hard to do.

I was wondering whether it might be better to model the area to the east to get a river in and then once it was there then focus on the map with it already seeded. Is that an idea that might work with your technique ?

gilgamec
06-02-2009, 09:41 PM
This is some great stuff. I was wondering how far you could take it. I was interested in the basin filling bit mainly as I think that can be quite hard to do.
If you're only filling it with land, then it's pretty easy; I think I'm using the same algorithm as Wilbur, and it is simple to implement and quite fast. If you're going to have basins with water in them, it's substantially harder. I haven't really thought about what would be needed in that case.


I was wondering whether it might be better to model the area to the east to get a river in and then once it was there then focus on the map with it already seeded. Is that an idea that might work with your technique?
Right now, I've put a "dummy" chunk of land to the east to start the large rivers, and you can see that with the two rivers that flow from the edge of the map to the sea. The height field of the add-on, though, doesn't match the mapped bit, and I think that's part of what's causing problems. I'm loath to model the off-map stuff in any detail for the Challenge, though in the future it may be necessary. I suspect that the only way I'm going to be able to get reasonable-looking rivers is to have at least a low-resolution model of the entire continent.

Hmmm...I just realized that part of the problem with the current version is that even the large rivers don't have deltas. Hopefully, if things go well with the other elements (I'm working on naming now), I'll be able to revisit the rivers before next week.

waldronate
06-04-2009, 06:27 AM
http://www.ridgenet.net/~jslayton/FunWithWilburVol5/index.html has some suggestions for routing rivers through basins with water.

For accurate river routing and basin filling, you need to have the entire watershed in your simulation.

In my experience, upscaling from a lower-resolution to higher-resolution DEM while maintaining the river network requires the participation of the river network in the upscaling process.

Deltas require sediment transport and water table maintenance. It's an ugly problem to get to look right because the rules aren't completely scale-free. If you take a simulation designed for 1 meter per grid box and scale it to 10 meters per box it starts to look odd, 100 meters per box looks wrong and 1000 meters per box resembles no reality with which I am familiar.

gilgamec
06-04-2009, 06:25 PM
In my experience, upscaling from a lower-resolution to higher-resolution DEM while maintaining the river network requires the participation of the river network in the upscaling process.
This doesn't surprise me at all. There's probably a lot of higher-level processes that you'd need to take into account: not only hydrology, but climate and ecology too. I hope, though, that you'd only need to simulate them at a fairly coarse level to get a decent-looking local area.


Deltas require sediment transport and water table maintenance. It's an ugly problem to get to look right because the rules aren't completely scale-free. If you take a simulation designed for 1 meter per grid box and scale it to 10 meters per box it starts to look odd, 100 meters per box looks wrong and 1000 meters per box resembles no reality with which I am familiar.I've already got lots of scale-free processes, so another one wouldn't be a problem. Anything with multiple z-levels, though, is going to be extremely nasty. In any case, I'm probably still not going to get to it in the next six days.

gilgamec
06-04-2009, 10:18 PM
I've done some fiddling with forests to see if I can get a representation that I can live with, and I haven't been able to so far. More work is needed on that.

In the meantime, I've been looking at labels. This is a threefold problem: what features are worthy of labeling, what do we call them, and how do we arrange the labels? For this checkpoint, I'm punting on the third, and just manually arranging them.

Now, the first problem, what features are labeled? So far, I'm labeling only the Gulf itself, the major cities, and prominent mountains. The label for the Gulf is (for now) manually placed. The major cities, right now, are just placed at the mouths of the major rivers. The prominent mountains are found by computing the topographic prominence of each point on the terrain; this essentially gives us the highest "independent" peaks. (This last bit took far longer than I'd like to code up.)

And what names do we give them? Since, as I've already said, I have no real artistic ability, even literary, so I'm not going to try to make up names. Instead, I'll do it procedurally! I grabbed a gazetteer of the world from the Net. The name "Malabor" sounds kind of South Indian to me, so I extracted all of the place names from South India from the gazetteer. I then use them as inputs to a Markov chain name generator. This gives me about a million words, which are chosen (more or less) at random. Short, frequently-chosen words are made "translations" of geographic terms, like "river", "mountain", "city", and so on. Longer words are proper names.

Drawing names on the map gives us
13933
It's not great yet; in particular, the relative font sizes and the rendering need to be substantially improved. Hopefully, I'll have forests going ahead before the next checkpoint.

Steel General
06-05-2009, 06:36 AM
When it comes to labeling a lot for me depends on the scale of the map. With this kind of scale I usually just go with major geographic items, important cities/towns/etc. and other major places of interest.

I think what you've done so far is fine, except maybe reduce the glow on the labels a bit.

gilgamec
06-06-2009, 11:29 PM
Not much done in the last couple of days, but I figured I might as well post what I have. I've put names on the landmasses and rivers, and removed them from the peaks. I've also added a graticule (from a simple polar projection), and reversed the rendering of the names (it's much better now, I think). Still no forests, though. *sigh*

Gandwarf
06-07-2009, 07:10 AM
Looking nice though!

silverhead
06-07-2009, 01:21 PM
Wow. Really impressive. I like very much how the rivers are done.

gilgamec
06-07-2009, 11:31 PM
Well, I've finally got forests looking acceptable. (But not perfect. I still don't think the colour fits.) Basically, I add green shapes to the sketch:
14010
then use the same technique as I use for generating the coastline to create the outlines of forests. I then place points according to a Poisson process, drawing them as lit spheres, and render them just like the mountains (but in green).

gilgamec
06-09-2009, 11:00 AM
Well, I'm not going to be able to do any more work on this before Wednesday, so I'll post my final version here now. I didn't get as far as I had hoped, but I'm not entirely embarrassed by the final result, so I'll consider it a success.

I tried to rerender it at 4k x 4k, and discovered two things:


Some of my code is exorbitantly inefficient. The entire map takes less than five minutes to create from scratch at 1k x 1k, but at 4k x 4k, it took over four hours. As nearly as I can tell, none of the procedures should take that much time, so I must have messed something up along the way.
I haven't caught all of the scale dependencies. At 4k x 4k, the height map is pretty much the same, but the river systems are wildly different. (And for the worse.) This is why I decided to stick with the 1k x 1k version for the final, even though it shows some less-than-pleasant aliasing on the text.

To fix #1, I'll have to look over my code before the next Challenge. For #2, I think that I'm going to have to place coordinate systems on a firmer footing - this might mean explicitly grounding everything geodesically, or handling more chaotic systems (like the rivers) at multiple scales at once.

Anyways, this was fun. Hopefully next month's Challenge will be something equally nice to sink my teeth into.

waldronate
06-09-2009, 12:01 PM
From 1kx1k to 4kx4k and the rendering speed goes from 5 minutes to 240 minutes? That's about a 50x increase in time for 16x the number of pixels. Processes like river finding and random Poisson fill aren't exactly linear in scaling so that's not too bad.

I would recommend using a slightly smaller font on the map description. It looks very cramped in there.

Steel General
06-09-2009, 02:19 PM
I agree with Waldronate... reduce the font size and maybe even put it in its own little 'box' rather than expanding the border.

gilgamec
06-10-2009, 12:02 PM
From 1kx1k to 4kx4k and the rendering speed goes from 5 minutes to 240 minutes? That's about a 50x increase in time for 16x the number of pixels. Processes like river finding and random Poisson fill aren't exactly linear in scaling so that's not too bad.
It's not quite as good as it sounds. A lot of my processes are linear; they take up quite a bit of the 5 minutes but very little of the four hours. The most time-consuming part of the 1k x 1k run is calculating the initial coastline which (for legacy reasons) I was never able to optimize away; it's linear and goes from about two minutes to just under an hour. The Poisson fill places the same number of trees at any resolution, so it's linear (and only a fraction of a second in any case). The basin-filling is slowed down the most by far. I do two passes, as recommended in one of your Wilbur tutorials, the first taking more time; at 1k x 1k, the longer of the two takes about twenty seconds, but at 4k x 4k, it's over two hours. (Basin fill should be about cubic in linear resolution, or about 64x for this increase, not 320x.)

gilgamec
06-10-2009, 12:23 PM
Looks like I got in before the contest closed. As suggested above, I've reduced the size of the text in the cartouche. There's probably all sorts of other tweaks I could make, but I think I'll leave it at this.

Thanks again to everyone who offered praise and criticism. This map isn't quite of the level of the others in the Challenge, but it'll certainly not be my last.

Immolate
06-10-2009, 05:10 PM
I love the simple style of this map, with hints of sophistication (the mountains!) lurking here and there. When the task at hand is presenting information clearly and deliberately, this map gets it done very well. Good job!