How to create roads on the ground

Like the picture of this road, can not unity3d directly on the topography of this road map »how operation?

Another problem is in my 3 dsmax in the establishment of a terrain game objects, I can be converted to unity3d it in the terrain, can be drawn directly above the trees or plants?



other



other



No… from my experience and as far as I know Unity’s terrain engine cannot do anything as pixel perfect as those kinds of roads. The roads like you showed and from games like Crysis are done by projecting meshes onto the terrain with a slight offset and most likely forcing them to draw after the terrain so there’s no z-fighting. If you want a dirt path-ish type road or concrete that has grass or dirt up over the edges of it so there aren’t any straight and hard edges between the two, then that Unity’s terrain can do.

I believe that you can create any mesh from a 3D program and then apply the terrain shader to it. I haven’t tried this though and am not sure how the resulting texturing affects it, but I’d assume that it would end up being the same as a Unity generated terrain where even if you modeled in hard seams, the splat map that determines the texturing for the terrains will not give you the same resolution.

I’m currently working on adding some roads to my terrain using this suggestion i made on another post, i’ll post a method if i get it working.

http://forum.unity3d.com/viewtopic.php?t=13374

You have to create the triangles for the road yourself, and then adjust the terrain to match the edges.

You can make a script that will turn an animation curve or path into a road mesh on the terrain, without seams.

The trick is to apply the terrain’s lightmap to the road and make the color of the edge of the road the same as the dirt on the terrain.

Here is an example from my project:

89732--3519--$picture_4_205.png

Are you talking about a script in Unity that makes the animation path follow the terrain makeing the road mesh from that? or are you manually makeing the animation path follow the terrain?

Sounds like a good idea either way.

I will be probably making an animation path in an external program (Lightwave) roughly follow the terrain, then extract a heightmap from that and incorporate it into the heightmap from Unity with a paint package, maybe using an alpha’d map on the edges and a decal shader to stop the depth fighting.

This is an untested theory tho.

kinl

Hey, Forest, that’s pretty slick! I guess you do a few raycasts along a line perpendicular to the path at points along the path and then build the UVs to repeat the road texture?

Forest and I actually made the road mesh in Maya and created the terrain around it. The main trick is the lighting… the trick to doing that can be found in this thread.

Yeah we sort of made the mistake of starting before really thinking a lot about it, so we actually made the road mesh in maya and painted the terrain to fit it. A lot of painting, hehe.

What I was talking about was a script in Unity that does it all.

  1. translates an animation path onto the surface of the terrain
  2. generates a road mesh from the path.
  3. sets the terrain heights around the road mesh so that they line up.

It would be a complicated script to make but surely it would be possible and very useful. However it doesn’t solve all problems: roads will be overlapped by terrain in low LOD areas.

Wow that pic looks very good, can’t help to ask could that be a new racing game demo for unity you guys are working on?
I sure wish we had one…

Forest, yea that’s what I thought you meant about the script, I just thought you had it done already. :smile:

hey guys i relise this post hasn’t been replyed to in a while, but on the road issue, how do stop your terrain mesh from poking through the road mesh, or z fighting i guess it is. I have tried applying the decal shader to it, but without any effect, if anything it made the z fighting worse.
But i guess the first question should be, at what height above the terrain should the mesh be placed .?

Anybody figure out the z-fighting issues with roads above terrains or a way to make the terrain draw before the road?

Seems like one way would be to use two cameras at different Depth Draw Orders and then use Culling Masks to draw only the terrain in one camera and the rest of the scene in the other camera. We’re creating a large scene with many cars, buildings and effects so I’m wondering what kind of performance cost there is to using two cameras like this?