2D Fractal Terrain discussion

I’m playing around with an idea for a 2D fractal terrain engine. My current methodology, is to do standard fractal subdivision to generate a heightfield, and then generate a mesh using different layers. This works great for stacked terrain featuring underground layers of dirt and rock, and differing layers of stone, etc. However, there is a bit of a problem with how I plan to handle a dirt layer.

The dirt layer itself, is generated at a certain thickness, and then dropped onto the terrain. It prefers to flow downwards, and any slope greater than 1/2 (22.5 degrees) will attempt to smooth itself. This is done by continually finding slopes in the dirt layer that are greater than the specified degrees, and flowing the dirt “downhill” until it is smoothed. I then take the height data and convert it into a mesh.

The problem is, if there is a rock spire, I will not have a continuous heightmap for the dirt layer. It will actually split into multiple triangle regions, having a big gaping hole where the rock pokes through it. I am looking for clever ways to handle this behavior. I realize that I can just skip creating any vertices/faces that have a depth of zero, and generate a new mesh region, and that will work fine, but I’m also curious about a few other approaches.

I also looking at ideas for generating resources within the rock layers that wouldn’t be terribly cumbersome. Veins of ore will have to be textured meshes, given the system’s implementation, but I’m unsure how to proceed with creating ore veins within the terrain. These are going to be generated in lines and patches using a limited cellular automata.

Currently, I store terrain data by storing two numbers (in some cases) the height of the terrain from the base point (a float value, which I multiply by the size of the world “grid”, and the depth, which stores how thick this bit of terrain is. My rock layers actually connect themselves to whatever is below them using their height values, and the depth value of the entire terrain to determine where the layer floor is, but for ore, I wouldn’t have a method of calculating this without storing it explicitly.

Ore veins would store their areas as perimeters, and then generate faces to connect the hulls using a simple algorithm, but essentially, the way this would be stored, would be the top of the ore vein, followed by the thickness of the ore vein at the given point. The only problem with this, is that it would not allow an ore vein to have any concave regions. Can someone point me to a method for generating convex and concave shaped meshes using only their perimeters?

A screenshot would help.

Unfortunately, I’m mobile at the moment, thought just struck me while I was at work. I’ll have to post the screenshot in a few hours, when I manage to get home… I’ve got a working version of this in flash, just haven’t completed the mesh builder in Unity.

You could maybe lay a thin layer of earth across the whole landscape with no sliding/falling behavior, like it just stucks where it lands, and then apply a second layer of dirst and let it slide and fall so you’ll get thicker parts in valleys. At least then everything would be minimally covered.

The problem isn’t so much with the method of laying the dirt, the problem lays in the method of building a mesh from the dirt layers. I like the fact that steep mountains have a little dirt on the top, and a lot of exposed rock faces. It looks good, and mirrors reality, and I’m going to test my new method of closing the vertices, as the dirt will never create concave hulls, so it won’t be at all difficult to manage. I guess I thought wrong on that bit.

The real issue though, is the ore. The ore itself is going to be problematic because of the fact that it can and will create concave hulls, which I’m not sure how to generate faces from those.