3
\$\begingroup\$

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)

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ You can also apply absolute and slope-based depth biasing, but yeah, it's fiddly to make it work perfectly at all distances & angles. \$\endgroup\$
    – DMGregory
    Dec 28, 2017 at 22:55
0
\$\begingroup\$

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

https://www.youtube.com/watch?v=-kbal7aGUpk

\$\endgroup\$
1
  • \$\begingroup\$ This answer would benefit from adding in the actual details on how to do this, without relying to an external link; this answer is borderline "link only". \$\endgroup\$
    – Vaillancourt
    Sep 22, 2021 at 18:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .