In my game, I have train track laid out over a height-mapped terrain. The problem is the train track is so close to the terrain that it causes z-fighting issues. Now, this isn't such a big deal because I can move the tracks slightly above the terrain so they do not occupy the same space.
However, I also have rocks, mountains, trees, and other props scattered on the terrain. For some models, like the tracks, I can elevate slightly above the terrain. But for other models, like the rocks, I can't simply elevate them because the rocks are placed on many differently shaped surfaces, there is no way to make a clear cut-off. (Tracks are always placed on only the flat parts of the terrain, where as the other props may not be).
Is there some way to give certain polygons a z-preference so the video card doesn't have to "guess" which is on top?
I read somewhere that I should use a depth-map, but they didn't explain how it would work. The only thing I can think of would be to render the scene into 2 separate depth buffers: once for the terrain and once for everything else. I would then have to compare the depth values and while rendering the scene for the final time, take preference on the non-terrain depth buffer. But this sounds grossly inefficient.



