hi,
I would like to add roads to the terrain in my game, I have thought about it and I would be sure I am not going in the wrong direction.
Here follows the specs I have.
1/The terrain is generated from a heightfield image and is for now a regular grid (no mesh simplification). It is split in medium-sized square blocks for frustum culling.
2/The Terrain is dynamic, some objects have the ability to modify it.
3/The road are built (and destroyed) at runtime. They are a sort of decal and as such they follows the terrain curves...
I see two path possible :
- Multitexturing : i.e having texture stages dedicated to roads. But I am not sure I could have road continuity, without a lot of texture stages/layers.
- Geometry : adding some quad and texturing them. due to difference of sampling between the terrain and the decals I may have to tesselate the quad to follows properly the terrain. (for example, one point of the terrain may be inside the road, if the point is a peak, the peak will be visible, the road won't cover it.)
any ideas ?
roads on dynamic terrain. ideas ?
Started by lionel_b, Jun 02 2007 08:57 AM
4 replies to this topic
#1
Posted 02 June 2007 - 08:57 AM
#2
Posted 02 June 2007 - 01:05 PM
I would suggest that you use some kind of spline system to create the roads, and seing as you can modify the terrain you could flatten the space around the roads to keep them level.
"Stupid bug! You go squish now!!" - Homer Simpson
#3
Posted 02 June 2007 - 03:19 PM
I use a fast sutherland Hodgman clipper on my decals from a single insertion
vertex to generate the additional triangles.
My polygon edges are based on the texture width and height from that vertex.
I also generate the geometry at startup including a rotation.
When I render I simply offset it by using glEnable(GL_POLYGON_OFFSET_FILL);
Since your initial surface upon which you want to overlay this is dynamic, might
introduce some difficulties in matching edges between individual decals with rotations combined.
Now of course I hope you meant road and not path, in which case this approach would not be ideal.
I will add that I have not tried this method on a large scale and therefore cannot comment on its
efficiency/inefficiently in a real-time scenario.
vertex to generate the additional triangles.
My polygon edges are based on the texture width and height from that vertex.
I also generate the geometry at startup including a rotation.
When I render I simply offset it by using glEnable(GL_POLYGON_OFFSET_FILL);
Since your initial surface upon which you want to overlay this is dynamic, might
introduce some difficulties in matching edges between individual decals with rotations combined.
Now of course I hope you meant road and not path, in which case this approach would not be ideal.
I will add that I have not tried this method on a large scale and therefore cannot comment on its
efficiency/inefficiently in a real-time scenario.
Nicholas Christopher
Architecture software development, and modeling
http:\\www.arconovum.com
Architecture software development, and modeling
http:\\www.arconovum.com
#4
Posted 14 June 2007 - 09:50 PM
Sorry to answer with such delay, last week was hectic.
@Kenneth : yes, spline are on the way but remember that so far, the road don't flatten the terrain. Other objects do. ths is this way to avoid the following infinite loop : object A modify the land, the road doesn't like the modifs (it's not flat anymore) and flatten the zone, object A updates itself modify again the zone to fit his objectives.
@Nicolas : Yes, I think that the (fixed-pipeline) way to go.
Someone told me that a (pixel)shader would be an alternative. But frankly I don't see how (I am no shader expert)...Any idea ?
@Kenneth : yes, spline are on the way but remember that so far, the road don't flatten the terrain. Other objects do. ths is this way to avoid the following infinite loop : object A modify the land, the road doesn't like the modifs (it's not flat anymore) and flatten the zone, object A updates itself modify again the zone to fit his objectives.
@Nicolas : Yes, I think that the (fixed-pipeline) way to go.
Someone told me that a (pixel)shader would be an alternative. But frankly I don't see how (I am no shader expert)...Any idea ?
#5
Posted 15 June 2007 - 10:27 PM
Heyo there :)
What kind of roads do you have in mind ?
Multitexturing (especially texture splatting) might still be an approach you'd want to look into.
Basically, if you anyways have several layers of texture on your terrain (which simply make the terrain look good :) ) you can always add another layer for roads. Generally, since roads are pretty sparse, this shouldn't cause too much of a performance penalty.
The only problem with this appropach is that roads are restricted to quite structureless textures, since there is no way to add direction-specific detail without too much trouble (maybe, except for pixel shaders...) If you only have planned for pebbles, dirt and cobblestone, you'll be fine. Those freaky white guide lines that tell you where to drive and where to score (how do you call these again ? ) will not be as easy to get with a multitexturing approach.
Another alternative for roads would be to use a variable, terrain-adapting crossection. The easiest way for this is to consider an inverse U-shaped block, with the edges pointing to the bottom. Place a lot of these at a fixed interval alongside your road spline (which, in this case, needs to contain height, and perhaps rotation as well) Link each two of these U's by three quads on each side. Now you've got a large extrusion object around our track. Finally, it's time to merge this with the terrain: pull the U tips down until they are well below the terrain height at their respective positions.
This alternative would probably be better for more advanced roads (highway, etc), you can even add a pavement to the crossection if you're ambitioned...
Rendering performance might be better than for multitexturing (since you can possible reduce the required crosssections on straight parts of the road), but initial setup costs are higher.
Hope this helps,
Cheers,
- Wernaeh
What kind of roads do you have in mind ?
Multitexturing (especially texture splatting) might still be an approach you'd want to look into.
Basically, if you anyways have several layers of texture on your terrain (which simply make the terrain look good :) ) you can always add another layer for roads. Generally, since roads are pretty sparse, this shouldn't cause too much of a performance penalty.
The only problem with this appropach is that roads are restricted to quite structureless textures, since there is no way to add direction-specific detail without too much trouble (maybe, except for pixel shaders...) If you only have planned for pebbles, dirt and cobblestone, you'll be fine. Those freaky white guide lines that tell you where to drive and where to score (how do you call these again ? ) will not be as easy to get with a multitexturing approach.
Another alternative for roads would be to use a variable, terrain-adapting crossection. The easiest way for this is to consider an inverse U-shaped block, with the edges pointing to the bottom. Place a lot of these at a fixed interval alongside your road spline (which, in this case, needs to contain height, and perhaps rotation as well) Link each two of these U's by three quads on each side. Now you've got a large extrusion object around our track. Finally, it's time to merge this with the terrain: pull the U tips down until they are well below the terrain height at their respective positions.
This alternative would probably be better for more advanced roads (highway, etc), you can even add a pavement to the crossection if you're ambitioned...
Rendering performance might be better than for multitexturing (since you can possible reduce the required crosssections on straight parts of the road), but initial setup costs are higher.
Hope this helps,
Cheers,
- Wernaeh
Some call me mathematician, some just call me computer guy. Yet, I prefer the term professional weirdo :)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











