Roads in a 3D Heightmap - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Roads in a 3D Heightmap (/thread-6105.html)
Roads in a 3D Heightmap - Jake - Nov 13, 2004 06:40 PM
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)
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.
Do you have any ideas of how to get the road to "Cling" to the terrain?
Roads in a 3D Heightmap - DoG - Nov 14, 2004 01:26 AM
The hard way is to make one mesh out of the roads & terrain. Otherwise, did you play with glPolygonOffset() ?
Roads in a 3D Heightmap - Fenris - Nov 14, 2004 02:56 AM
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.
Roads in a 3D Heightmap - Jake - Nov 14, 2004 08:39 AM
I am clueless of what parameter values to use, I have tried about 6 combinations and haven't got the correct combo yet.
Roads in a 3D Heightmap - Fenris - Nov 14, 2004 12:24 PM
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);
Roads in a 3D Heightmap - DoG - Nov 14, 2004 04:01 PM
Also, make sure your roads are rendered after the terrain.
Roads in a 3D Heightmap - KenD - Nov 15, 2004 12:54 PM
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.
Roads in a 3D Heightmap - Jake - Nov 15, 2004 02:49 PM
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.
Roads in a 3D Heightmap - DanLab - Nov 15, 2004 03:22 PM
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
Roads in a 3D Heightmap - Jake - Nov 15, 2004 04:07 PM
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.
Roads in a 3D Heightmap - DanLab - Nov 15, 2004 04:36 PM
Jake Wrote:Danlab, have you ever played Road Rash 64?not this one
i found this pic of the game:
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
Jake Wrote:Its too late to change it now, so I may have to go with a less than optimal solution.sorry :-(
Roads in a 3D Heightmap - Jake - Nov 15, 2004 04:51 PM
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.