overlay roads on terrain

I have a terrain which I’ve drawn using elevation data. Now I want to draw roads on top of it using 2d data, which gives me the coordinates of the center of the road & the road’s width. I can interpolate using the elevation data to get the z values of the coordinates but I want to use the road width to expand it & draw the whole road, not just a line. I need to find the coordinates of the road edges.
Any ideas on where I might find information on how to do this?

Any Linear Algebra text book should suffice.

Road Point
Road Direction Vector
Surface Normal
Road HalfWidth

your road edges can be found by crossing the direction vector with the surface normal and normalizing, then multiplying by HalfWidth and -HalfWidth respectively, and adding to RoadPoint.

Of course, if the terrain is undulating, this may put the edges inside or above your heightfield, so you probably want to raycast in the direction of the original surface vector to find the actual height of each edge. Or just run your favourite triangle clipper on the terrain mesh to generate the terrain-following-road mesh.

The fastest way is often to create an overlay texture out of the road data and then project that texture ontop of the ground. E.g. ig you have terrain that changes like roam or LOD levels this is the best way.


Unfortunately, your approach will stretch the road on sloped surfaces. Yes, it’s faster (especially on fill-rate capable set-ups) but the quality is less.

If you’re doing a game, it’s probably good enough. If you’re doing a GIS, it probably isn’t.