Search Unity

easy roads in unity

Discussion in 'Assets and Asset Store' started by raoul, Mar 18, 2009.

  1. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    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:
    http://forum.unity3d.com/threads/easyroads3d-v3-the-upcoming-new-road-system.229327/














     
    Last edited: Jan 7, 2015
  2. Dakta

    Dakta

    Joined:
    Apr 8, 2008
    Posts:
    492
    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.
     
  3. sbuchbinder

    sbuchbinder

    Joined:
    Apr 4, 2008
    Posts:
    53
    Looks good! I'd pay $20 for that...
     
  4. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Um, yeah, looks good. Details please! :)
     
  5. dingosmoov

    dingosmoov

    Joined:
    Jul 12, 2005
    Posts:
    559
    I would pay you $20 immediately! and yes Details please...
     
  6. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    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
     
  7. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Very nice.
     
  8. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    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.
     
  9. Ayce

    Ayce

    Joined:
    Jun 8, 2008
    Posts:
    101
    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. :eek:
     
  10. GusM

    GusM

    Joined:
    Aug 27, 2005
    Posts:
    585
    This would be a very usefull tool for terrain work, keep us updated.
     
  11. Zylex

    Zylex

    Joined:
    Nov 25, 2008
    Posts:
    238
    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!
     
  12. chadchat

    chadchat

    Joined:
    Apr 5, 2008
    Posts:
    154
    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
     
  13. artzfx

    artzfx

    Joined:
    Apr 28, 2008
    Posts:
    572
    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?
     
  14. Ayce

    Ayce

    Joined:
    Jun 8, 2008
    Posts:
    101
    Fogiveness prease, :D I just noticed you said the "road asset" which would suggest the road itself is modeled ( and textured) elsewhere. :oops: 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. :?
     
  15. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    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.
     
  16. slashdotray

    slashdotray

    Joined:
    Dec 3, 2006
    Posts:
    77
    This is exactly what was missed in unity, great thing so we´re interested.....
     
  17. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    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.
     
  18. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    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.
     
  19. azeitler

    azeitler

    Joined:
    May 14, 2008
    Posts:
    162
    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!
     
  20. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Thanks photon!

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

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    I put a simple web demo online at:

    http://www.andasoft.com/temp/easyroads.html

    It only shows the basic terrain deformation and road geometry. Splatmap manipulation, terrain lightmap support on the road, terrain edge smoothing and road tilting which is being rewritten (it will give full control over tilting per road marker) are not included.

    Note that there are quite some issues with the scene navigation and the web demo. Safari seems to work best. I tried to built standalones but the size is big (over 50mb). Not sure why this is?
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    looks very promising and of course there are 100 things i would like to have added to the fuctionality but first: I guess you will have to write a special shader to make sure that the road always is drawn on top of the terrain – due to the terrain’s lod system (see picture attached).
    nevertheless it is a great start and might become a very interesting and useful tool.
    lars
     

    Attached Files:

  23. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Very fun, very strong, so that the official integration of the Unity tool bar. Ha, ha, ha :D
     
  24. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    A quick way around that is to paint the same road texture on the ground underneath. It bleeds on the edges but when it pokes through like that its not as noticeable.

    I wonder how you'd do a shader like you're describing? What happens when the road is behind a mountain? You don't want to see it then!
     
  25. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    How to beautify the road map?

    Road Mapping in the editor? Will be saved into what format? Fbx? :?:
     
  26. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Thanks guys,

    Yes, the terrain lod system will result in situations like your screenshot. I have not much experience with shaders but, just like what Duke already wrote I wonder if it is indeed possible to create a shader for this without having the road pop through the terrain when not wanted?

    I use a lod system in my own project. The road is broken apart in segments and raised above the terrain when away from the cam. When you set the road indent value correctly I found that not more then 30cm is needed to avoid situations like in your screenshot. Road segments are repositioned depending on their distance to the cam. This works quite well. Besides that the lod system will allow high quality roads and disable rendering when not needed.

    This is the current feature list:

    - unity editor script for terrain export
    - assetbundle import
    - unity terrain import editor script (to do)
    - splatmap manipulation, with smoothing levels
    - road geometry optimized for terrain lightmap usage
    - low poly road export (to do)
    - high poly road export
    - edge smoothing
    - save/load project (to do)
    - add waypoints
    - remove waypoints
    - Insert waypoints (to do)
    - waypoint properties (working on):
    * soft selection
    * soft selection distance
    * position
    * left tilting
    * right tilting
    * left indent
    * right indent
    * left surrounding distance terrain deformation
    * right surrounding distance terrain deformation
    - helpers for smooth curves (to do)

    Let me know if there is anything missing you had like to have and I will see if I can add it.

    Yes, it is saved to .obj optimized for the terrain lightmap.
     
  27. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Fork in the road, this tool can do it?

    Only $20? Now it can be applied to it? :wink:
     
  28. Yann

    Yann

    Joined:
    Oct 20, 2007
    Posts:
    432
    Will buy it too ! :D
     
  29. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Thanks guys!

    It will be saved as .obj which should be fine for import in your modelling app. Sidewalks and road intersections are a bit out of scope at this stage. But you can do that in your modelling app. For the sidewalks, just use an indent which is bigger then your sidewalk and the terrain will be deformed accordingly so it will look nice.

    About the $20, the more I work on this the more ideas I get and it is already getting far bigger then the original idea so I think it will be slightly more then $20 but not much. And as I initially mentioned $20, you will get it for $20 (and anyone else who is interested and reading this now), just send me a PM or so if you are interested so I know.
     
  30. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    PM for you~~~ :p
     
  31. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    I already put you on the list Minevr, thanks!

    Some screenshots with the node based control system:





     
  32. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Great update!!! Very inviting!! I want to use it as soon as possible, when can I get my hands on it?:D :D :twisted:

    ps:What do you mean you have added me to your list? I didnt receive any invitation.
     
  33. english10

    english10

    Joined:
    Mar 16, 2009
    Posts:
    26

    Finally a very good look, I have the same problem has plagued me to see the results you really are so excited. :p :p :p
     

    Attached Files:

  34. english10

    english10

    Joined:
    Mar 16, 2009
    Posts:
    26
    Bump....
     
  35. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    What problem are you referring at? I can´t see from your image what the problem is unless you mean the terrain slightly going through the path geometry. If it is this and you are referring to the problem raised by Larsbertram then they are not related. The image that Larsbetram attached shows a cam position far away from the ground which triggers the terrain lod system which makes the terrain pop through the road at areas with reasonable height differences close to each other.

    I don´t think your issue is related to this as the cam is nearby. Did you try using the terrain smoothen tool on these problem areas? It gives more control and you may get slightly better results.
     
  36. english10

    english10

    Joined:
    Mar 16, 2009
    Posts:
    26
    :D
    I make a road in 3dmax,import unity3d later,
    I can not deal with a very good relationship between the road and terrain
    (the road are Ups and downs)

    so.....
     
  37. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Nice work here, looks fantastic and I'm excited to see people helping push our tool's abilities with great add-ons like this. :)
     
  38. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    @raoul:

    I want to enjoy it as soon as possible. :p
     
  39. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Thanks Tom for the nice comments, Unity rocks, this will save me so much time in the future!

    english10, that is exactly what made me start working on this project. Looking at your pic, your road (laid down in the terrain) is slightly different from my case. But this tool will be able to handle it.

    Minevr, if no drawbacks there will probably be a first version within the next 2 weeks.
     
  40. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    Thank you, I will patiently wait for her. Expected :D
     
  41. english10

    english10

    Joined:
    Mar 16, 2009
    Posts:
    26
    english10, that is exactly what made me start working on this project. Looking at your pic, your road (laid down in the terrain) is slightly different from my case. But this tool will be able to handle it.


    :D
    All that ends well is well,
    I am waiting for your tool 8)
     
  42. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    I have a few questions:-

    -Can you turn the mesh creation on/off - in case all you want is the terrain altering?

    -Does this alter the splatmap of the terrain?

    -Does this/how does it handle road intersections?
     
  43. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi Duke,

    1. yes, mesh creation is optional

    2. Altering the splatmap is optional too and at this stage only works directly for terrains with equal x,z sizes. However it will support export of the road to png. In your modelling app you can then easily resize the saved png according your splatmap dimensions and apply the modified splatmap to you terrain through untiy scripts that come with the tool. The splatmap with the road will fit exactly on the modified terrain.

    3. Viaducts/ bridges are supported by disabling terrain deformation for the specific control points. On these segments, the road geometry will follow the path of the control points but the terrain will not be deformed. Crosspoints, etc will generally just look fine on the average not to hilly landscape. If not, then you can control terrain deformation exactly how you want to using the positioning tool. Road geometry on crosspoints will have to be corrected manually in your modelling app at this stage.
     
  44. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Sounds great Raoul! Maybe a tool you consider in the future, based around similar technology, would be something that automatically finds the intersection between a water plan and terrain, and makes a mesh there for the surf foam material :)
     
  45. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    In a way you can already do that with the first version I will release. Just get the correct height of the water in the Unity and position the road controls at that height and only export the "road geometry", no terrain altering. If you have pro and import an assetbundle with the water included, this will be easy to do. But with indie it is also doable.

    This is not exactly what you wrote but probably a lot faster then by modelling the foam completely in your modelling app.
     
  46. english10

    english10

    Joined:
    Mar 16, 2009
    Posts:
    26
    :D :D :D
    I am waiting..
     
  47. english10

    english10

    Joined:
    Mar 16, 2009
    Posts:
    26
    Bump......
     
  48. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi,

    Update:

    http://www.andasoft.com/temp/easyroads.html

    I am currently doing the last bit of testing. The update above shows current gui layout and supports modification of waypoint properties. Please, read the instructions on the webpage, there are quite some limitations in the webbrowser version but you will be able to get a good impression of the capabilities of this tool.

    The $20 step in version (available very soon) includes:
    - terrain import for indie users
    - assetbundle import for pro users
    - simple demo scene like in the webplayer
    - export: terrain, high poly road, low poly road, support for terrain lightmap on road geometry, road texture export for terrain splatmap.

    The tool comes with the following Unity Editor scripts:
    - export terrain
    - import terrain
    - export splatmap
    - import splatmap
    - accurate road geometry positioning

    It will also include a basic manual on how to use the tool + instructions on how to embed the road texture in the terrain splatmap (which basically is a matter of opening the exported terrain splatmap in your paint program and pasting the road texture in it) and how to use the terrain lightmap on the road geometry.

    The full version (free upgrade for step in version users) will include:
    - undo/redo
    - remove/insert waypoints
    - support for multiple roads
    - nicer gui
    - improved gizmos
    - splatmap import, this will give more control on how to layout the roads for indie users.
     
  49. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Hi Raoul,

    This is looking very interesting, but I'm having a lot of trouble getting it to work. I'm using FireFox and there seem to be conflicts with your choice of keys and mouse buttons for input. Whenever I try to pan or zoom it triggers the Unity right button menu. I tried using full screen mode, but your GUI doesn't work properly in that mode. I couldn't get it to draw roads at all, but then realized that I need to hold the "a" key while using the left mouse click, but unfortunately it always draws the same road position and completely ignores my mouse position.

    Edit: I just tried it again in full screen, which although the GUI windows are in the wrong spots at least I can navigate a little better. I'm still not able to add points for my road properly. I'm able to add my first and second points OK, but when it comes to the third it won't add it. I tried positioning the camera in different locations and when it finally added a point, it went to the extreme upper left corner of the terrain... not where I was clicking.

    May I also suggest that you modify your mouse / keys for navigation so they are the same as Unity? I'm used to using the ALT key with LEFT / MIDDLE / RIGHT mouse buttons to do all my navigation. I really got confused with the system you have.

    This has a ton of potential, but I think there's either something wrong with how it's picking up mouse clicks or I just haven't been doing this correctly.
     
  50. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,735
    Hi bigkahuna,

    Yes, it is a shame that the webplayer causes those conflicts. If you want, I can prepare standalones for download but the file size are 35mb+.

    Did you read all the instructions? It addresses most of the issues you have. With regard to the navigation controls I will have a closer look to all the options in Unity. I myself, always use the right mouse button for panning and the alt key for rotating. Then also implemented are the apply key for zooming.

    In the first version I had lots of issues with Firefox. Before uploading this morning I did a quick firefox test and it seemed to act better. Not sure what the problem is with adding points, I didn´t have this problem in Firefox. Is the sphere representing the mouse position blue or red when you add points?