Putting roads on a terrain

Started by
5 comments, last by Sages 19 years, 3 months ago
The easy way would be to just have the road included as part of the low-res texture that's stretched across the terrain, but that doesn't look very good. The idea I'm working with now is to make the road just a bunch of polygons sitting on the ground. The thing is that involves a lot of work to get those polygons to sit on the ground. I have to take the landscape into account when creating the road polygons, so they'd need to be split up properly. I'm not really sure how to do this. Anyone have any experience with something like this? Tips?
I like the DARK layout!
Advertisement
If you want kind of like a dirt track over the terrain, then you might want to consider using layers on your terrain. With layers, you couple a greyscale alphamap with a texture then make white areas of the alphamap (typically) represent the parts of the terrain where you want that texture to appear. The Unreal Engine has a really cool terrain system with layers and you can use it to put multiple textures on a terrain and control where you want those textures to blend in with eachother using the alphamap. Maybe this is what you want in your terrain system?
All you have to do is figure out the various cases, and then test for and handle them.

First, you'll need some way to test if a 2D triangle intersects with the road or not. Perhaps a pre-polygonization of the road will do.

Next, test each triangle in your terrain...
.. if the terrain tri is entirely inside the road, remove that triangle from the terrain, and add it to the road.
.. if the terrain tri does not touch the road, leave it be.
.. if the two intersect, remove the terrain one, add the triangle made from their intersection to the road, and add the one or more triangles it will take to cover the remainder back into the terrain.

RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
That sounds like it'd work, but it doesn't seem very LOD friendly. Wouldn't I have problems later on if I wanted to add geomipmapping or ROAM? Although I suppose with geomipmapping I could just calculate each different LOD for the terrain then add the roads to that. But I still might have problems with fixing the gaps across terrain block edges with roads since the neighboring block's triangls isn't in a predictable arrangement.
I like the DARK layout!
Any more thoughts??
I like the DARK layout!
I had the exact same problem very recently.

So... the ideal way to do it would be to find the "exact fit" of polygons that will match the road exactly to the terrain. Maybe the exact fit would be done with some code you write, or you could model the track and the terrain together in 3DS MAX or something... Personally I think this would be the best way to do it, although it would be a lot of work.

Other than that, you basically have 2 options, I think:
1) Make the road a part of the texture itself
2) Do an approximate fit of the track on to the terrain

Maybe there is some other very clever way to do it, but these are the two that I can think of :)

For my own project, I chose to go with #2, because I had a very limited timeframe for finishing my project. To be honest, my way is not a very robust way to do it at all, and personally I spent a lot of time tweaking it so that the terrain doesn't show through the track. Basically what I did was determine the track's vertices, using a 2D set of points describing the track curve and the terrain as input. The height of each of the track's vertices is simply the height at that point (x,z) on the terrain, plus some small delta. (This height is found by determining which triangle of the terrain mesh the point (x,z) is in and then calculating the y value for that point on the triangle).

The key to getting it working in this case is:

1. The terrain has to be pretty smooth otherwise it's very difficult to avoid little pieces of it popping up from the track. In my project, I did this by simply blurring the heightmap using a paint program.

2. The track needs to be rendered a little higher than the terrain (hopefully not so much that it's noticeable!) In addition, you can cheat a little: raise the distance to near clipping plane for the track, this messes w/ the Z-buffer to make it "higher" than the terrain

3. The track mesh must be very detailed

You can experiment w/ these 3 factors to get the right blend of performance and quality. The main disadvantage of this method is that you'll need a very detailed track mesh depending on the smoothness of your terrain. You can use tristrips to help a little and of course good frustum culling helps (divide the track into sectors), but it's still potentially a lot of vertices to be pushing around...

Here are a couple of screenshots from my game showing this method:

Screenshot 1

Screenshot 2

Note in the 1st screenshot, the sampling of the track mesh is slightly more detailed than the terrain.

Hope it helps,
roos
I've never actually added road networks to my terrain engine, however I have some friends at www.d-a-s.com that might be able to assist you further. I also might have a way for you to get the ideas mentioned above to work with LOD. I'm out of time for now but you can contact me through one of the methods listed on my site (in the signature).

Of course www.vterrain.org also has resources related to roads on terrains.
http://vterrain.org/Culture/Roads/index.html

[Edited by - Sages on January 4, 2005 12:18:20 PM]

This topic is closed to new replies.

Advertisement