Sign in to follow this  
roos

How to draw race track on terrain (decal)

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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.


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this