easy roads in unity

Hi,

A while back I started experimenting with creating roads in unity. First the scripts only created the road asset using terrain height data. The road asset is automatically saved as .obj for uvmapping in my modelling app.

But adjusting terrain heights is quite a time consuming thing to do and then I still found it hard to get good results. So I tried to come up with something to make this easier.

I finally finished the hard part of it (it still needs some optimization) last weekend. The pics below show the original terrain, the terrain adjusted to the desired road and finally everything together including the road. All of this took about 5 minutes of which 3 minutes script processing to get accurate terrain heights.

As every now and then people ask about how to create roads in Unity I thought the above might be interesting for other unity users.

The whole system is now part of my scene editor but if there is enough interest in this for a small price ($20 or so) I could put everything in a seperate app

Anyway I am quite excited about this, it is a huge time safer.

Raoul


This is the very first EasyRoads3D thread. For the latest info regarding EasyRoads3D v2 and v3 check the links below!

[updated 04-01-2013] links to the v2 and final v1 threads

http://forum.unity3d.com/threads/82331-EasyRoads3D-v2-is-out–Road-rivers-procedural-geometry-for-Unity
http://forum.unity3d.com/threads/22097-EasyRoads3D-v1-0-for-Unity-Plugin-version-Online

[updated 07-10-2014] Check this thread for the upcoming v3:

Hmm… Did you adust the terrain in Unity yourself and make it that smooth? How’d ya do that? My roads never turn out that good! (Mostly too uneven, any advice?)

Seems like a good system.

Looks good! I’d pay $20 for that…

Um, yeah, looks good. Details please! :slight_smile:

I would pay you $20 immediately! and yes Details please…

Thanks guys,

Dakta, what I always did with the terrain tools when sculpting roads is use small brush sizes and low opacity. It takes a lot of patience but you can get similar results as in the pictures above.

Yes, the above is all done in unity. But instead of using the terrain tools, the terrain is sculpted automatically according the desired road layout. You can configure the road width (terrain is sculpted accordingly), quality of the road mesh and terrain smoothing level afterwards.

In the current state some minor work is needed using the terrain smoothing tool to make sure the terrain does not show through the road asset at certain spots and to smoothen some other spots but in the example above this took about 1 minute. This can probably be optimized further.

Raoul

Very nice.

Thanks DaveyJJ,

I am now working on steep curves like in the pictures and have the terrain more tilted upwards on the outside to make it more realistic.

Not to be picky, but how would you handle dividing lines or tire tracks? I tried this sort of method before, and it works great for plain dirt or one lane blacktop, however, if you use a texture with lines on it, the get messed up real quick when going around corners. :shock:

This would be a very usefull tool for terrain work, keep us updated.

Looks like a really handy script to make roads! I’ve encountered problems with making roads myself as they were too bumpy but with a script like this it would definitely solve my problem!

What is needed is an additional height edit brush that flattens by gradually flattening the brush area with a fade off towards the edge of the brush. With this you can sculpt ramps, slopes, paths, roads etc

Sounds like a great idea Raoul. Memories of Vue Infinite.

Once the road is modelled into the Terrain could the road just be textured using somehing like a Multi Layered masking shader to apply your materials to the terrain like this http://forum.unity3d.com/viewtopic.php?t=1335&highlight=terrain+shader instead of having a separate piece of geometry?

Fogiveness prease, :lol: I just noticed you said the “road asset” which would suggest the road itself is modeled ( and textured) elsewhere. :sweat_smile: In that case, this would be a nice tool to have in the arsenal.
I tried to do something similar, but had the aforementioned issue of trying to keep the terrain off the road. Very tricky. :?

That is on my list but more with the intention to add dirt and have a nice transition between the terrain and the road geometry. But yes, you could use a road texture on the terrain instead of a dirt texture and on top of it road geometry. It will require some splatmap manipulation.

The road geometry will be created instantly, no need for modeling it yourself. The texturing can be done elsewhere.

This is exactly what was missed in unity, great thing so we´re interested…

There’s a relatively easy way to accomplish this same feat in photoshop. I picked it up years ago from somewhere on the garage games forums.

  1. Open up the RAW file in photoshop.

  2. Create a new layer (let’s call it road for now)

  3. Use a solid black brush tool to draw the path of your road. Obviously the brush size controls the width of the road.

  4. At this point changing the opacity of the layer will control how deeply the road is carved into the underlying terrain. I’ve usually used between 5% and 10%.

  5. Save the RAW file and re-import into Unity.

Most of the code for terrain tilting in corners is finished, tilting level is configurable and so are start and end point of tilting.

(second pic has no tilting applied)

The code is also optimized. The whole process to create the road on above photos now takes about 30 secs to 1 minute.

Next is: tools to apply the terrain lightmap to the road for correct lighting and embed the road into the terrain splatmap.

I would be very interested in purchasing this tool for 20$. It just looks awesome - I say that after 48 hours manually adjusting a terrain to my streets!

Thanks photon!

I have been working on this today and will probably have a web demo ready in the next couple of days.