   Roads on Terrain
  Hi Do anyone knows or can give tips how to paint road on a terrain?Im thinking of using glTexSubImage2D to project subtextures directly on a big texture. But dont know if thats the best way.Or is it better to use tiles with differens textures?RegardsVoy   
  I'd say terrain and roads are 2 different things, unless you are talking about vague sand paths. Roads are "man-made" (including tracks from a horse&wagon), which makes them more detailed and therefore hard to draw on a terrain. Wether you use 1 big skin texture on the terrain or blending tiles.I would either modify the terrain mesh to keep 'ground' and 'road' seperated by letting them using different materials. Or if you have a heightMap kinda like terrain, calculate a road mesh that can be pasted on top of the terrain. Just like pasting decals, or letting a sheet fall on top of an object, it will nicely wrap upon the terrain. You can create this road mesh as a quadstrip, eventually subdivided into smaller quads to make sure the detail level of the road is at least the same as the terrain underneath. For each vertex of the road mesh, let it drop on the terrain. If its asphalt, you might want to give it a slight offset upwards. Now use a road texture on that mesh that follows the quad directions. If it was a sand path or just tire-tracks, make the material transaprent (use multply blending for example) to make it blend with the terrain underground. Basically its just a decal now.Greetings,Rick   ;  Thanks for answer!And you might have a good point here. I just got an idea here. Im using opengl in this case, and i found that glPolygonOffset could maby come in handy in what you are describing. Are you familiar with that? Quad strip is also what im thinking on right now.Or maby it is better somehow by self find the altitude and slop from the terrain data and try let the roads path be renderd little little above the terrain surface (triangle). But that would looks bad if its not fit.   ;  I use quad strips in my software Freeworld3D, and it works out pretty well.  I offset the height of each vertex in the road by some given amount to have it sit ontop of the terrain.  I don't bother with call glPolygonOffset though.   ;  Hi soconneI have look on your tool there, very impressive.So glPolygonOffset is an bad idea i would guess?Its maby better to calculate the altitude self directly from the terraindatainstead of bother with glPolygonOffset. But how are you handling with gapsthat would occur when the tracks don't match the triangle from the terrain ?Is it not better to use GL_Triangle_Strips instead?   ;Quote:Original post by voyager838So glPolygonOffset is an bad idea i would guess?Good and bad at the same time, like most things in life.It's a good idea because it usually "just works" for most most values by flipping a switch, whereas manually offsetting vertices to be aligned some value above terrain is more work and may more easily give you all kinds of artefacts in different situations.On the other hand, polygon offset disables early Z optimisations, which can be a major performance hit in some situations.   ;  You might look at the paper on rendering vector data on 3d terrains (google).   ;  http://smartech.gatech.edu/handle/1853/3219.In their method, they create two textures for the local terrain around the camera - one containing elevation data, and the other the appearance of the terrain (including grass/road).  The elevation and appearance textures can be created dynamically - so that the elevation on the road is flat, even if the resolution of the terrain data itself is not good enough to resolve the road features.  IMO, this is the foolproof method.   ;  While that method is extremely robust, from what i saw it was visually displeasing. It had poor texturing and lack of detail. The roads and terrain types were very unintersting. Maybe with some more creative height mapping and texturing they could have sold it better.I too am currently working on a roads over terrain system, but i dont want to give away all my secrets just yet (/ haven't figured them out yet :) ).About 3 or 4 times a day though i feel myself swinging towards purely artist created road segments, or at least where there are complex intersections. The connecting bits could easily be procedural. But i'm striving for high detail and fidelity, not flat road painting.   ;  Thanks all!I got an idea now how to perform this.Checklist:1. create the road-path with "spline" around the terrain2. Every single point on the spline check which points are near and smooth itso we could get a plane altitude3. Render the track with own texture onto the path, and little little above the terrain.Also find a good article how to carve in the terrain for river on gamedev,http://www.gamedev.net/reference/programming/features/randomriver/page2.aspThat might help to smooth the road-path a bit.Does this sound wrong? or have i miss something?