How to draw race track on terrain (decal)

Started by
2 comments, last by Phillip Martin 19 years, 5 months ago
Hi, I'm trying to display a race track on top of some terrain, so basically this is a question about decals. The problem is that, the race track and the terrain are at the same height, so sometimes the terrain shows through the track. Does anyone know of any good way to make the track "stay on top"? I could try adding some offset to the height values of the track, but this isn't too elegant, and also I would have to make the offset pretty large (like 1 foot high) for this artifact to be fixed... The reason is basically because the points which are sampled from the terrain to generate the track are not at a very high frequency compared to the detail of the terrain, so sometimes a planar portion of the track might be covering a "bump" in the terrain and so the bump shows through. Hope that wasn't too confusing! :) If anyone has any good idea, I'd appreciate it much Thanks!
Advertisement
The way I would do it is probably to include the actual track in the terrain texture (if possible with your setup), then just use "guideposts/checkpoints" to make sure you are staying on the track. That way, it the track was physically part of the terrain. there wouldn't be any artifacts...
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute
Thanks for the suggestion, I didn't think of that. Unfortunately it wouldn't really work with this setup though; the terrain is big enough (2 miles x 2 miles approx.) that this approach would require probably gigabytes of texture memory :)
Your best bet is to actually carve out the track of the terrain. If your terrain is just a heightmap, its fairly striaghtforward to cut pieces out of your triangles and ust slot your terrain in.

The biggest benefits is that
a) It solves your problem
b) Is really beneficial, as you can extend your algorithm to deform the terrain to make the track fit better. e.e Slope the nearby terrain away from teh road imitating real road works.

The cons is:
a) Its harder to do
b) Makes the rendered landscape not just a straight rectangular grid any more.


Another alternative:
1. Algorithmically make the landscape's vertices near vertically near the road or underneath it
2. Render the world like this:
a) for each grid of landscape that has a road on it, draw the road first enabling stencil writes, then draw the landscape only using failing on stencil test.
b) For every other grid on the landscape, render the ground as per normal.


This topic is closed to new replies.

Advertisement