I've got a 3D terrain that consists of many heightmap-based tiles. I need to render multiple roads over the tile. By now I simply subdivide road into tile pieces then generate a decal per each tile. But decals are pretty expensive on memory. Is there any better solution than using decals or baking roads into the tile texture? (Target application should work on mobile device with OpenGL ES 2.0 support)
An alternative to incorporating the roads into your terrain texture is to model them as separate geometry, for example as triangle strips. The problem with that is you want the road geometry to be very close to the terrain geometry, which leads to depth ambiguity. Sometimes the terrain will appear in front of the road, and that may change (flicker) as the camera moves. In some OpenGL applications it is possible to force one “layer” to be in front by drawing in two sequential passes, and turning off depth testing for the second layer:
// Draw terrain. [...] // Draw roads. glDisable(GL_DEPTH_TEST); [...] glEnable(GL_DEPTH_TEST);
However this may not work for you since you may have roads behind terrain that you do want to to be occluded. If so, baking your roads into the terrain textures may be the best approach. But then the road surface will always have slope parallel to the terrain. Or possibly, modeling the roads as separate geometry, and lifting them above the terrain by such a large amount that the depth ambiguity goes away.
A good solution is to use multi-texturing and a blend map to add road texture onto the terrain. Check out this excellent tutorial for further details