PDA

View Full Version : Procedural vector map elements -- some experiments

gilgamec
08-08-2009, 08:24 PM
As those who have seen my Challenge (http://www.cartographersguild.com/showthread.php?p=63881) entries (http://www.cartographersguild.com/showthread.php?p=67364) will know, I'm interested in creating procedurally generated maps, because:

I'm far too lazy to do a map manually, and
I have no artistic talent anyway.

This thread is for showing my experiments with procedurally-generated map elements, like forests, mountains, cartouche decorations, etc. -- mostly in a hand-drawn- or engraved-style.

First off, I'm looking at forests. I'm going to take the forest style from this tutorial (http://www.cartographersguild.com/showthread.php?t=5478) as a starting point, and see how far I can get completely procedurally.

The distribution of trees in the forest is pretty simple. I take a Poisson point distribution, drop a circle at each point, and take this as a first step.
15671
The actual shape of trees is going to be more irregular than just circles, of course. First, the general shape shouldn't be a circle, but more of an egg shape. I can alter a parameter and get shapes of greater or lesser egginess.
15672
Next, to create lobes, I'm going to make the tree silhouettes the overlap of a bunch of circles. First, I put a Poisson point distribution inside the general tree shape. Second, I put a circle around each point, then take their outside boundary as my tree boundary. (I'm not drawing all of the circles here, only the ones that actually contribute to the boundary.)
15673
Replacing the circles in the forest with these shapes already greatly improves the forest.
15674

gilgamec
08-08-2009, 08:37 PM
If you look back at the tutorial I'm cribbing from (http://www.cartographersguild.com/showthread.php?t=5478), you'll notice that the shading on the trees is an integral part of the overall effect. In this post, I'm talking about getting a similar effect.

First, I tried a sort of drop-shadow effect. (Actually, the outline is stroked with a rotated elliptical nib, but the result is pretty much the same.) I don't really like it -- it looks too uniform. In the second test, I tried a different tack.

I went back to the circles that create the outline. I want to locate the circles on the bottom left of the tree, so I shift the general tree shape (red) up and to the right; the circles whose centers are in the shifted shape (black) form the "lit" section, while the other circles (blue) are the "shaded" section.
15678
We can shade the trees in the forest scene and see that it's much improved.
15679

Another nice factor in the original tutorial is the "ground", which is hatch-shaded. I can create a similar effect with straight lines deformed a little bit by random control point rotations.
15680

Of course, one of the nice things about procedural generation is that I can generate this pattern at any scale and size.
15681

ravells
08-08-2009, 08:48 PM
Great stuff!

Will you be working on tree trunks in the next bit?

I'm amazed, with depth of your observation as to the shape and underlying form etc, you should be able to draw with ease.

töff
08-08-2009, 10:04 PM
Ya, they want trunks ... and that would make it a home run!

gilgamec
08-08-2009, 11:17 PM
Thanks for your comments! Trunks should be pretty easy; I don't think they need any kind of wiggliness (though it wouldn't be too hard to add):
15691
And you're right; it improves the look considerably. Great!
15692
15693

On a related note: does anyone have any suggestions for software for converting from vector (in this case, PDF) to raster images? I'm using ImageMagick here (which farms it out to Ghostscript, I think), and while it looks fine on coarser images, it does terribly on the finer detail (like the hatching); those images I've had to convert manually in Illustrator.

töff
08-08-2009, 11:58 PM
Home run! Maybe ...

Can you feed a shape into your procedure, and generate complete trees within that shape? I mean, so the trees on the edges don't get cropped.

What software are you using to generate trees with your procedure?

töff
08-08-2009, 11:58 PM
Oh, ImageMagic, sorry, didn't read your whole post. (I *rock* at that).

(edit) ... Oh no, wait, did you mean you were rasterizing with ImageMagick?

ravells
08-09-2009, 12:00 AM
That looks fantastic!

töff
08-09-2009, 12:00 AM
any suggestions for software for converting from vector (in this case, PDF) to raster imagesOf course, Photoshop will rasterize vectors and PDFs. (Remember that a PDF is just a containter for vectors and/or rasters of any resolution(s) and/or type.)

Koor
08-09-2009, 10:43 AM
Can you add a chance of a dead tree or stump being generated into the product? Also random generation of a glade or underbrush could add to the end product.

gilgamec
08-09-2009, 11:59 AM
Can you feed a shape into your procedure, and generate complete trees within that shape? I mean, so the trees on the edges don't get cropped.I'm not certain what you mean about edges getting cropped; I can't see any of that in the examples above. Are you talking about an arbitrary forest shape, or an arbitrary tree shape? Both should be quite possible (and the edges should never be cut off); an arbitrary tree shape would be easier than fitting exactly to an arbitrary forest shape, if only because the shapes of the trees varies more than the shapes of component circles.

What software are you using to generate trees with your procedure?I'm using Asymptote (http://asymptote.sourceforge.net), which is designed for making technical diagrams, but can be coerced into doing stuff like this.

Of course, Photoshop will rasterize vectors and PDFs. (Remember that a PDF is just a containter for vectors and/or rasters of any resolution(s) and/or type.)I'm sorry, I should have been more specific; Asymptote is giving me PDF-encapsulated PostScript, which I want to rasterize in some automatic fashion. Photoshop would, of course, work; I'm currently using Illustrator (they probably use the same engine, anyway). However, this means that I have to manually load and save every time; if I could use ImageMagick for the conversion, I could just put the final rasterization into my toolchain and have it done automatically at the end.

In the end, it's not so much of an issue, I was just hoping that someone here might have some suggestions.

Can you add a chance of a dead tree or stump being generated into the product? Also random generation of a glade or underbrush could add to the end product.Hmmm... Could you suggest some examples of dead trees? I'm not certain how to express that in 2D. As for underbrush, though, that might be an idea. I'll have to look at it....

töff
08-09-2009, 12:06 PM
I'm not certain what you mean about edges getting cropped; I can't see any of that in the examples above. Yes but you just filled a square with trees. Can you fill a circle ... or an arbitrary forest outline that you can feed into the procedure?

Otherwise, the user will have to generate a big square full of trees, and then cut out his forest shape, carefully not cutting any trees in half.

I'm thinking, here I am in Photoshop or Illustrator or whatever, and I need a forest. So I draw a vector path for the forest border, copy or save it, and then fire up your tree-pattern generator and give it that vector path. Then, voila, the procedure makes me the exact forest I need, full of (uncropped) trees, which I then drop into my map.

töff
08-09-2009, 12:14 PM
Asymptote is giving me PDF-encapsulated PostScript, which I want to rasterize in some automatic fashion. Photoshop would, of course, work; I'm currently using Illustrator (they probably use the same engine, anyway). However, this means that I have to manually load and save every time;

If you're in Illustrator, you're saving as .EPS anyway, which is vector, though it might have raster elements in it like PDF. Either way, if you want a raster, Illustrator will not give you one, except by export, which I find usually doesn't give as good results as rasterizing in Photoshop.

In Ill. & PS both, you can place linked files, which will update on file open. I'm fuzzy on your workflow toolchain, but maybe links would be the answer ... get it, chain, link?

I know how you feel, though. I love to automate stuff. But I often spend more time building automators than I save in doing it manually. :roll:

gilgamec
08-09-2009, 01:23 PM
Yes but you just filled a square with trees. Can you fill a circle ... or an arbitrary forest outline that you can feed into the procedure?Sure.
15712
It's difficult to get a tight fit to the boundary; as I said in my last post, this is largely because trees aren't uniform in shape (so some are narrower, and thus too far away from the edge; if you account for this, the wider ones will intersect it). Also, the area I'm hatching is harder to compute (as it's no longer convex).

Either way, if you want a raster, Illustrator will not give you one, except by export, which I find usually doesn't give as good results as rasterizing in Photoshop.I'm using Illustrator's "export for web" function. I'm still not certain that it's any worse than Photoshop's save functions; it's better for my purposes, though, because the procedure is just load-export; with Photoshop, vector images load with no background, and don't use the bounding box in the PDF, so I have to manually reposition them and add a background before saving.

In Ill. & PS both, you can place linked files, which will update on file open. I'm fuzzy on your workflow toolchain, but maybe links would be the answer ... get it, chain, link?I hadn't thought of that; it may not be a bad idea. I'll look into it.

gilgamec
08-09-2009, 01:43 PM
If you're in Illustrator, you're saving as .EPS anyway, which is vector, though it might have raster elements in it like PDF. Either way, if you want a raster, Illustrator will not give you one, except by export, which I find usually doesn't give as good results as rasterizing in Photoshop.I tried a direct comparison. On the left, exporting directly from Illustrator. On the right, the same image after loading into Photoshop, adding a white background, resizing to the same size as the Illustrator export (with bicubic sampling), and saving as a PNG. The only substantive difference that I can see is in the hatching; the darker one (Illustrator) certainly seems closer to what I see in my PDF viewer!

töff
08-09-2009, 02:10 PM
Sure. 15712 It's difficult to get a tight fit to the boundary

AWESOME. Perfect! Exactly what I was hoping you could do. A tight fit is not necessary IMHO.

msa
08-09-2009, 03:25 PM
Thanks for posting more of your work on this! I just adore your procedurally generated map techniques, and I can imagine this making it very useful in producing quick maps for a D&D game or something. Really great work here.

dragonwolf
08-10-2009, 06:03 PM
Excellent job gilgamec. This is really cool. If you can generate trees, couldn't you also generate buildings for a town. What if you created a vector outline of a town and where you want buildings to be placed have filled with black. Could your generator then replace those black areas with a random assortment of building shapes like you've got for your trees? That'd save a lot of folks from having to draw town and city buildings or using mosaic filters which give you funky shaped buildings.

gilgamec
08-10-2009, 08:37 PM
Excellent job gilgamec. This is really cool.Thanks!

If you can generate trees, couldn't you also generate buildings for a town. What if you created a vector outline of a town and where you want buildings to be placed have filled with black. Could your generator then replace those black areas with a random assortment of building shapes like you've got for your trees? That'd save a lot of folks from having to draw town and city buildings or using mosaic filters which give you funky shaped buildings.There's two problems with trying to use a similar technique for towns:

How do we draw buildings? It took quite a bit of time to get a tree that looked like an actual tree, even a stylized one; I'm not certain how to visualize them. This is the lesser of the two problems, though.
The harder problem is to capture the actual arrangement of buildings in cities. There's two things here, really. First, the arrangement of trees in the forest isn't meant to represent the actual spatial arrangement of trees in the actual forest; in fact, we intentionally try to space the trees out to give an impression of continuous tree-ness (actual forests, at least in my experience, are much more clumpy). In a city, on the other hand, we want to capture the actual spacial arrangement of the buildings. This means that we have to have some idea of the logic of building placement, whereas we can abstract out the logic of tree placement in a forest. In the case of cities, buildings are on streets, aligned with the street; they never overlap (or, if they do, they must follow some kind of architectural rules); there are rules about shapes and setbacks and yards and fences; and so on.
Basically, there's a lot more that you have to know about the placement of buildings in cities that you don't need for trees in forests. (And I had to withdraw from the last Challenge because I couldn't figure out building placement. Cities are my kryptonite.)

I suppose that if you could figure out a good way to draw varied buildings, and you already had a street plan, and if the placement rules could be explicitly described ... then you'd be ninety percent of the way there. But in that case, there'd be very little left for me to do.

ravells
08-15-2009, 08:47 AM
Gilgamec...is there any chance you can make a tiling version of this? I'd love to use it as a tiling texture.

Jykke
08-15-2009, 09:34 AM
This procedural mapping thing is really interesting. I am testing few scripts at the moment to see if I can get medieval style 3d cities generated with them. I don't really have that much knowledge about programming / scripting, but I'll see what I can do x) Btw, here's a render of 3d city (quite simple) generated with suicidator city engine.

gilgamec, have you ever tried creating procedural 3d cities ? :S would be nice to know if someone had any experience with them.

gilgamec
08-15-2009, 12:13 PM
gilgamec, have you ever tried creating procedural 3d cities ? :S would be nice to know if someone had any experience with them.
For a recent Challenge, I tried implementing the method from this paper (http://www.procedural.com/company/publications/urban-simulation.html), but it didn't turn out so well (more my fault than the method, though). (On a side note, that company makes some of the nicest procedural cities I've seen; their program is a touch out of my price range, though.) A couple of issues I discovered:

You have to understand the forces which cause people to move to a specific location. The above method is for a modern city; everything is predicated on fast transport (cars), real estate pricing, and zoning. In a medieval city, of course, the pressures will be different, and I haven't yet figured out a good set of replacements.
If you're going for a 3D city (as opposed to just a street plan), you have to understand the architecture of the building you're going to have in the city. Modern city elements are very modular: rows of windows, uniform stories, and so on. In a medieval city, the architecture is a great deal more idiosyncratic, and hence harder to make procedural. I don't really have any experience with that.

So, no, I don't really know a lot about getting procedural city creation to work; but I'd like to!

Jykke
08-15-2009, 03:15 PM
I know that procedural mapping might be the only way that doesn't take hundreds of hours of time to create a 3d city for a map.. but getting the scripts etc right, it's not an easy task at all. I know that the house & road network can be easily done with image maps, so that's not a so big an issue than creating good looking medieval buildings is. :)

gilgamec
08-15-2009, 05:48 PM
Gilgamec...is there any chance you can make a tiling version of this? I'd love to use it as a tiling texture.
Sure. Here's both hatched and not-hatched versions. The hatching is on a different scale than the trees, so it doesn't match up perfectly left-right; this may not be a concern.

If you're going to use them, they're licensed CC-BY.

Redrobes
08-15-2009, 07:20 PM
I am testing few scripts at the moment to see if I can get medieval style 3d cities generated with them.Dont forget to look at the Thatching for Dummies thread where we talk about making random 3D shaded cities. We pretty much have it all sorted except that we need something to place 2D footprints down in a sensible city like manner.

Jykke
08-16-2009, 02:01 AM
Dont forget to look at the Thatching for Dummies thread where we talk about making random 3D shaded cities. We pretty much have it all sorted except that we need something to place 2D footprints down in a sensible city like manner.

The problem is that I would like to have the city in full 3d, have it be shaped according to terrain altitudes etc. Being able to export the models to various formats (.obj, .3ds) is a must. :S Actually I have found a proper program to do that , but I just have to figure out how I get it to make non-flat roofs :)