Roads in a 3D Heightmap

Member
Posts: 509
Joined: 2002.05
Post: #1
Here are some screenshots of my new game I am working on (unfortunately in these two you can't see multiple types (grass mud snow) blending)

[Image: newgamefar.jpg]
[Image: newgamefar.jpg]

Everything is going pretty good lately, but one thing I am stuck on is getting my roads to render the way I want them. Here are some of my options

1. Make the center of the road be .005 above the terrain its on. Parts of the road get stuck under the terrain because its normal is strain up

2. Do the same as 1 with the depth buffer disabled. Looks good close up in the screenshot below, but as you can see in the pink far away roads always show up when they should be blocked.

[Image: newgameclosepink.jpg]


Do you have any ideas of how to get the road to "Cling" to the terrain?
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #2
The hard way is to make one mesh out of the roads & terrain. Otherwise, did you play with glPolygonOffset() ?
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #3
Yeah, glPolygonOffset is the way to go here. In short, what it does is to shift the depth value of your triangles so that they "move" just slightly closer to the camera. This makes them go free of underlying geometry. Note that this isn't actually a geometric movement, but a movement of their depth value. It can take a lot of tweaking to get right, though.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #4
I am clueless of what parameter values to use, I have tried about 6 combinations and haven't got the correct combo yet.
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #5
First of all, brace your road-rendering code within glEnable/glDisable (GL_POLYGON_OFFSET_FILL). Since your roads are likely to be highly angled away from the camera (not facing it) you want a high value for factor. Try something like glPolygonOffset (6.0, 1.0);
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #6
Also, make sure your roads are rendered after the terrain.
Quote this message in a reply
Member
Posts: 79
Joined: 2002.08
Post: #7
The bad news is that the only good solution is to have the roads being a part of the terrain mesh. You can play with things like polygon offset but it won't look right in all cases. Some angles and distances will produce unwanted artifacts. The stencil bufffer can also be used.

KenD

CodeBlender Software - http://www.codeblender.com
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #8
I kept trying glPolygonOffset (6.0, 1.0); with different variables, but I keep getting worse results. When I made the first number bigger I actually saw less of the road. I enabled GL_POLYGON_OFFSET_FILL and am drawing the roads after the terrain too.

How would I go about using the stencil buffer? I read the NeHe tutorial on reflections and half of the shadow ones, so I think I should be able to try it if it sounds good.

As for weaving in the road to the mesh, its a height map of quads with level of detail so I can't really exchange normal polygons for it. Right now I have the center of the road segments take the height of the terrain under it. I tried making the other parts of the road take the height of the terrain under it too, but it the road would interfere with itself, I might have to try that if the stencil buffer or GL_POLYGON_OFFSET_FILL doesn't work out.
Quote this message in a reply
Member
Posts: 110
Joined: 2002.07
Post: #9
is an height map is good for a racing game ?
i think no, possible for some off road games, but for racing i dont think
its a little off topic, but i made some test with heightmap too before using my ring-engine for my current project
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #10
Danlab, have you ever played Road Rash 64? That is what I am trying to recreate, and how else am I going to make a level that is miles square? It is more of a long distance road race than a mario kart type game (like yours), so big vast terrain is important.

Its too late to change it now, so I may have to go with a less than optimal solution.
Quote this message in a reply
Member
Posts: 110
Joined: 2002.07
Post: #11
Jake Wrote:Danlab, have you ever played Road Rash 64?
not this one
i found this pic of the game:
[Image: ME0000008328_2.jpg]

Jake Wrote:it is more of a long distance road race than a mario kart type game (like yours), so big vast terrain is important.
if the car/bike dont go to far outside the raod its an engine who work like my engine.
its a ring/chaine engine with segment, you display only X segment in front off the vehicule and the road can be really long
here is some screen shot from my editor
[Image: engine1.jpg]
[Image: engine2.jpg]

Jake Wrote:Its too late to change it now, so I may have to go with a less than optimal solution.
sorry :-(
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #12
OK, after realizing some really dumb subdividing mistakes in my code I realized I actually don't need to change much at all. I will get another "fixed" screenshot up after I re-scale some things.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Rendering Heightmap using texture data ardowz 3 1,010 Feb 25, 2014 10:25 AM
Last Post: SethWillits
  Heightmap format? kelvin 6 3,752 Mar 24, 2005 02:40 PM
Last Post: arekkusu
  Best way to add roads/objects to a terrain engine? Jake 6 3,884 Sep 6, 2004 07:25 AM
Last Post: Jake