Skip to main content
GameDev.net gamedev.net
🔒 Locked

How to render a road in terrain imlpemented in height map?

Started by pcwlai Jul 8, 2010 at 11:15 AM 17 replies 13k views
Original Post
pcwlai
pcwlai
I would like to know how to render (or blend nicely) a road or some other details on a terrain using height map implementation.

The best exampple is those in WoW. After using tools to turn WoW into wire frame mode, you will find there is only triangles (forming squares) for terrain and no other polygons rendering the roads and so on.

Maybe there are multiple rendering of the terrain meshes, first with the low frequency basic land type and then the high frequency road? But if so, then, this seems better to render with only detail textures as the terrain is already streammed in?
The poorest programmer in the game industry!!
crucifer
crucifer
Shader's Multi texturing is the #1 way to go.


#2 way to go would be to have LOTS of different textures (one texture per "block")
pcwlai
pcwlai
Wouldn't it be too costly to store so many detail textures as there are so many blocks on screen at the same time?
The poorest programmer in the game industry!!
crucifer
crucifer
Using multitexturing, it is very cheap :
1-Use a few high rez images (ie : grass, rocks ... etc) that you will be reusing on hundreds of terrain blocks
2-Use a different low-rez texture that says how much of each texture to use for a pixel (ie : each channel of this texture will tell how much of "grass" or how much of "rocks" that pixel will have).

Multitexturing will be very memory friendly. It will obviously cost more GPU, but this cost is still pretty damn low.




The second solution; having a different texture for every terrain block; will cost a LOT in memory. Both storage memory AND video memory. But at least :
-it is very GPU friendly
-it will allow you to draw whatever you want on the terrain
pcwlai
pcwlai
Thanks for the reply! I have been curious on how to create terrains with high details.

There are many articles on terrain generation and rendering methods but a lack of how to texture them especially when artificial items and regular items are to be painted on the terrain.
The poorest programmer in the game industry!!
solenoidz
solenoidz
Maybe you should consider using a separate mesh for the road(curved over and bellow the terrain) and then align the terrain mesh to that road.
Something like this ?
http://vimeo.com/9122230
Zemedelec
Zemedelec
Quote:
Original post by solenoidz
Maybe you should consider using a separate mesh for the road(curved over and bellow the terrain) and then align the terrain mesh to that road.
Something like this ?

+1.
Here is another example of a road made by mesh: http://pc.ign.com/dor/objects/14327511/tropico-3/images/tropico-3-screens-20090610000645685.html?page=mediaFull

solenoidz
solenoidz
Yep. Looks like a Crysis editor. It would be nice if you say few words of how exactly you model the road mesh around the spline, and is there any difficulties with the UV generation. I tried Tropico game demo once. Good job.
Emergent
Emergent
I've also seen this done in screen space with a fragment shader, surprisingly... Very crisp road. You lose AA though, and it doesn't seem like the most flexible solution. But very nice for what it does.
programmer_tom
programmer_tom
if you add geometry, it will z fight like a bastard at distance, and you will fight with that forever, until you wished you had done it all in the shader.
szecs
szecs
Actually, if you want a smooth road, you have to use geometry. You can't just project some road on the terrain, because it won't be smooth. And the road needs to be smooth for rendering and physics too.

So +1 for Solenoidz: the terrain mesh should be modified to fit the road, or the road should be a completely separate mesh.

Rendering is another question. There are many possibilities.
Atrix256
Atrix256
I'm currently working on something where i paint roads on terrain via a decal type system.

it's working ok, but im doing this because roads can be built as the game progresses, as opposed to roads being static from the beginning.
KOzymandias
KOzymandias
Quote:
Original post by programmer_tom
if you add geometry, it will z fight like a bastard at distance, and you will fight with that forever, until you wished you had done it all in the shader.

But when the road mesh is always on top, do you even need to z test ?
Zemedelec
Zemedelec
Quote:
Original post by solenoidzIt would be nice if you say few words of how exactly you model the road mesh around the spline, and is there any difficulties with the UV generation.


The mesh is a Bezier spline, subdivided regularly along its direction. Vertices are laid over the terrain, the terrain is smoothed also, so its vertices go below the road.
UV coords are computed from the spline length, then there is a relaxation process along the spline ends, so there is no UV stretching/shrinking.
Rendering is done right after the terrain, with relatively big depth bias + world space prespective bias (which gets bigger, depending on the distance of the vertex from the camera). No depth writes. After the road, all objects are rendered.

The rendering is an order of magnitude simpler, compared to all other code that computes road-related stuff - sidewalk rasterization into the pathfinder weight table, road construction in realtime (while game is running), traffic system, terrain flattening - which care about buildings and other roads around, etc. etc.

In was heaviest engine feature in the Tropico 3...
szecs
szecs
Quote:
Original post by KOzymandias
Quote:
Original post by programmer_tom
if you add geometry, it will z fight like a bastard at distance, and you will fight with that forever, until you wished you had done it all in the shader.

But when the road mesh is always on top, do you even need to z test ?


Of course. What happens, if the road is occluded by a mountain?

I think if you have a separate mesh, you'd better remove the mesh under the road m to avoid Z-fighting. Or if it's problematic, make a "trench" under the road (hmmm... it's a hack). But I say (what others say as well) smooth and match the terrain under the road, and maybe you can get away with a a depth bias too (as already suggested, so I say nothing new, I'd better shuddup)
KOzymandias
KOzymandias
Of course indeed, I forgot those damn mountains !
JPulham
JPulham
Try this paper here. The whole site is worth a read. This guy has papers on ocean, terrain, vegetation, atmosphere, rivers, clouds, etc: http://www-evasion.imag.fr/Membres/Eric.Bruneton/.

The paper describes rendering roads, lakes, etc. on terrain with a height map. In preprocessing you render a strip of polygons following your road spline into 3 'feature' textures: colour, height and blend factor. When rendering the height map you then blend between the terrain colour/height and feature colour/height with the blend factor you rendered earlier.

The paper explains it more fully.

*edited for clarity
pcwlai
pcwlai
Thanks for all the information. Though, what interested me most is how WoW did it. They may not have the best visual quality for if for creating the solution for a vast open scene with many in door areas, I trust their solutions.

I used tools to convert many games into wire frame mode and those WoW model and map loaders to view and learn from it.

After these many years, how terrain like WoW is rendered still bothers me as I cannot recreate the level of performance I need even when hardware performance upgrades are factored in.

Now, I am concentrating on implementing those features and elements needed for games instead of heading for the best graphics quality seen in Crysis. Game play is more important even for a programmer.

From the wire frame mode and, there seems only 1 terrain mesh (comprised by many chunks of course) being rendered. And there is no separate mesh for roads. What makes me wonder is, if just detail maps for each triangle is used, there will be many to be used which seems requires a lot of GPU RAM even at the time when the game is released.
The poorest programmer in the game industry!!
Zemedelec
Zemedelec
Quote:
Original post by pcwlai
Thanks for all the information. Though, what interested me most is how WoW did it. They may not have the best visual quality for if for creating the solution for a vast open scene with many in door areas, I trust their solutions.

I used tools to convert many games into wire frame mode and those WoW model and map loaders to view and learn from it.

After these many years, how terrain like WoW is rendered still bothers me as I cannot recreate the level of performance I need even when hardware performance upgrades are factored in.

Now, I am concentrating on implementing those features and elements needed for games instead of heading for the best graphics quality seen in Crysis. Game play is more important even for a programmer.

From the wire frame mode and, there seems only 1 terrain mesh (comprised by many chunks of course) being rendered. And there is no separate mesh for roads. What makes me wonder is, if just detail maps for each triangle is used, there will be many to be used which seems requires a lot of GPU RAM even at the time when the game is released.


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.