I would like to add roads to the terrain in Panda, I have thought about it and I would be sure I am not going in the wrong direction.
Here follows the specs I have.
1/The terrain is generated from a heightfield image and is for now a regular grid (no mesh simplification). It is split in medium-sized square blocks for frustum culling.
2/The Terrain is dynamic, some objects have the ability to modify it.
3/The road are built (and destroyed) at runtime. They are a sort of decal and as such they follows the terrain curves…
I see two path possible :
- Multitexturing : i.e having texture stages dedicated to roads. But I am not sure I could have road continuity, without a lot of texture stages/layers.
- Geometry : adding some quad and texturing them. due to difference of sampling between the terrain and the decals I may have to tesselate the quad to follows properly the terrain. (for example, one point of the terrain may be inside the road, if the point is a peak, the peak will be visible, the road won’t cover it.)
any ideas ?
Make a texturestage with an asphalt texture on it, and blend it on the terrain using an alpha map? Same as you would do for multitexturing?
Your would imply that the road texture has no orientation, wouldn’t it ? If I understood correctly, a road texture with a central yellow band would have the same orientation whatever the road orientation. A shame don’t you think.
Still, i am not sure other ways exist.
If you can afford $30 U.S. try out Freeworld3D (http://www.freeworld3d.org/). It can import or create heightmaps and help you texture them in great detail with many, many layers of textures. Textures can be applied according to height intervals and slope intervals as well. It even will let you design a road system and specify the base texture for the road. Another cool feature is that it can calculate baked-on light maps and add the map as a texture layer. When you are done you can collapse all of the textures into one single texture (32x32 up to 4096x4096) and export the resulting texture. If you want to see an example PM me and I’ll email one to you.
I’ve quickly tested Freeworld and it’s very good tool. I think we will buy it to have better terrain but it won’t help in this case.
The road are build at runtime by some road-builders thus we need to implement our own road-rendering scheme.
( By the way, a linux version would be nice (we work on linux) although i know it could be a lot of work. There are very few good terrain editor on linux )
In fact in think I have found the solution, i don’t know if it’s doable in Panda.
the key word : clipping. The idea is to clip the part of terrain the road is on, get the trianglles resulting from the clip, copy them and then texture the copy)
I will ask if it is possible in another thread.
An alternative would be to set a pixel shader. but i must admit I am completely newby when it comes to shader (except the general principle).