Integrating Generated and Hand-Made Terrain

Building pads and other small stuff

By "small stuff" I mean terrain items that extend over a relatively small number of lowest-level squares, so that the terrain item can either be fully expanded or absent. I think buildings and small collections of buildings fall into this category. Cities may need special treatment, as we probably don't want to expand the whole thing at once; in fact, cities may need some sort of partial expansion of buildings, just like the terrain. On the other hand, if buildings are just oblong boxes with texture mapped windows and logos on the sides, we may be able to grind out the whole thing, or anyway enough that we can have a hard boundary of buildings appearing magically at a certain range, because things at the pop-into-existence radius are reliably obscured by closer stuff.

I will refer to the polygon that makes up the base of the structure as its "pad".

These pads can be handled by figuring out which triangle strips are overlapped by the edges, and creating new triangles to smoothly merge the edges of the pad with nearby strips. I talk about this in detail below. This feature, unlike some of the fancier ones discussed later, is necessary.

Frank Lloyd Wright buildings

Sometimes we want things to look like they were built around the terrain, rather than looking like the terrain was scooped out to accommodate the building. This is fairly easy: we just make it have a pad that we know is below terrain level, draw the structure first, and then drawn the terrain. This requires no additional bookkeeping other than deciding at what level of fractal expansion the structure should be drawn, and noting that it is the type of structure that is drawn before the terrain.

Rivers and roads

These are tricky. They are long enough that we don't want to expand them all at once, and we don't want to store them. They need to be generated, and their generation ideally should take into account terrain features at all scales.

I won't address the generation here. If we assume that at a given level of fractal expansion we also have some road/river fractals that expand into their own triangle strips, we can merge those strips in as polygons just like we merge building pads. This may be kind of slow, since a typical river may have quite a few more polygons that a typical pad - it could be possible to make a smarter algorithm for merging one triangle strip into another one. I'll work on this much later, if it turns out to be a problem.

Landscaping

In some cases, especially on Earth, someone will want to integrate some detailed handmade terrain into the fractal. This seems like the easiest of the problems discussed here to handle: we can just make a note in the planet's data file that square such-and-so should has the data in a given file, rather than generated. I think that it is not so bad to require that complete squares be designed at once.

The designed square should be specifiable at any level of expansion. Also, it would be nice if we could allow the fractal to "fill out" all or part of a designed square. I think this would be done by initializing a new fractal in the quadrants of the designed terrain in which you are not interested.

There is a potential problem of edge-matching, but when the designer is making his custom terrain square we can expand out the surrounding edges within the editor (we will need an editor) and he can match it himself.

Requirements for the terrain generating engine

I think I have listed the various distinct types of stuff that will need to be integrated in to terrain. This excludes things like spaceships and cars that sit on top of the terrain: in those cases, we don't need to alter the terrain at all. Now I need to figure out what the low-level requirements are on the terrain generator.

The lowest-level generated terrain element is a single triangle (although internally these are stored as strips of triangles.) We need to merge in pads which are polygons, and which can probably be restricted to horizontal planes. We can project the "pad" polygons onto the terrain triangles. The question is, how do we join the surrounding terrain triangles to these new polygons?

Some terrain triangles will be completely obscured by the pad. While it would be a nice luxury to identify and remove these, it probably isn't all that important. Since we are going to have to find the triangles in the strips that overlap the edges of the pad, it probably won't be significant additional work to block out the obscured ones.

We want to come out of the integration with a new set of triangle strips that, when drawn with the pad and anything sitting on the pad, looks good. Some sort of reasonably smooth merging with the pad edges is needed. A first approximation to this can be simply breaking up the cut terrain-strip triangles into mutliple smaller triangles with edges along the pad edge on one side and the next adjacent triangle strip on the other side.

This will allow some neat effects: to make a shored-up road, simply run the road a few meters above the surrounding terrain. To make a river canyon, run the river a few meters below the surrounding terrain.

Note that none of this pad-merging is that vital for cities, because we can use the Frank Lloyd Wright buildings. Alternatively, we could make a giant, buried concrete block that sticks up out of the earth a little ways, and slap the buildings down on top of that. It's more important for roads and rivers. It can probably be omitted until much later.

Home | Terrain Generation