Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Public Procedural Roads/Paths Tool

Discussion in 'Made With Unity' started by Chris Morris, Apr 30, 2010.

  1. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Hey guys,

    I'm with Six Times Nothing, an indie development team, and we have decided to release public versions of some of the tools we are using to develop our current game project, Dawn of the Tyrant. We are releasing the Road/Path Tool today,and will release more tools in the near future.

    On our website you can find our other tools - the Terrain Toolkit and River Editor.

    The tools are free but please feel free to donate (at the bottom of the tool's page) if you find these tools useful or are using them commercially.

    View a video of the tool here: http://www.youtube.com/watch?v=_si61-MF3O8

    You can read more and download it here: http://www.sixtimesnothing.com/road-path-tool/

    For updates, follow my newly created Twitter account http://www.twitter.com/_chris_morris

    Note: If you have any problems or feedback, let me know - this public version hasn't been thoroughly tested. Also, check the Usage and Tips section of the website.

    Hope you enjoy!

    - Chris

     
  2. Ramen Sama

    Ramen Sama

    Joined:
    Mar 28, 2009
    Posts:
    561
    Good stuff! Thanks for giving away free. Would make a good addition to the wiki as well!
     
  3. aksdad

    aksdad

    Joined:
    Apr 6, 2010
    Posts:
    36
    Wow!
    Thanks for this amazing tool.
    I've been following your project for quite some time.
    great job!
     
  4. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Hello, Chris! I have this functionality too in Antares Project.
    Forgive for an "intersection of our roads".
    My project is Open Source. May be we can cooperate?
     
  5. skynet

    skynet

    Joined:
    Feb 9, 2010
    Posts:
    3
    Thnks for release. It looks good )))
    Yeah, can we use\change\add\modify or add some other stuff to your scripts. Off course then if all will work fine share it with other.
    To Neodrop, i wrote you a message to ICQ (from 2257998).
    To Chris. Are you have a plan to add terrain changing like it is in EasyRoads3d?
     
  6. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Awesome. Thanks for this great tool :)
     
  7. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Hmm, i have some issues with this tool. Hope you don`t mind :)

    It happened twice now that the created road simply disappears. Repeatable with creating the mesh in Textured view, then switching from Scene view Textured to Textured+Wire. What`s left is the nodes. The mesh cannot be convinced to come back.

    The blob shadow doesn`t "shine" at the created road. The diffuse road shader doesn`t receive shadow it seems. I switched to the normal diffuse shader. Problem solved. Still, the advantage of the detail texture is lost then.

    What disturbs a bit is this triangle at the beginning of the road. Is there a way to get rid of it?
     
  8. expressionforge

    expressionforge

    Joined:
    Mar 17, 2010
    Posts:
    217
  9. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    I must be doing something wrong. I download the zip file, but when I unzip the file by double-clicking (OS X) it is just a folder containing folders like the internal tracking of assets done by Unity. Any suggestions?
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Unzip using some other unzip tool (e.g., using Terminal you can type "unzip path/to/file.zip"; there are various GUI tools of course). Ideally the file should be zipped by placing it in a folder first, so this doesn't happen.

    --Eric
     
  11. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Thanks for the heads up, the issue should be fixed now
     
  12. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    That fixed it, thanks!:)
     
  13. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    The road texture seems to be missing in this new version :)
     
  14. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Tiles - Double check, it should be in the /materials folder after importing the package. I just checked myself and it was there
     
  15. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Double checking as adviced. Hmm, this time the texture arrived. Scratch that. My fault it seems. Sorry for the confusion :)
     
  16. scarpelius

    scarpelius

    Joined:
    Aug 19, 2007
    Posts:
    966
    Tried 3 times now the river tool and the resulted river is always created under the terrain.
     

    Attached Files:

  17. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    The River is created below the terrain because a River doesn`t flow above the terrain. There is the river depth settings to change how low compared to the terrain it should be. Standard is -12

    This thread is about the Roads and Paths tool, which is another script. So just to be sure, you really talk about the River tool, and not about the Roads and Paths tool, do you? When we talk about the Roads and Paths tool instead, check if your terrain is in positive range. That would be my advice for the River tool too ...

    While posting here, any news how i can convince the diffuse road material to retreive the blob shadow? Tests showed me that the other shaders like the simple diffuse shader receive the shadow, but unfortunately they also clip into the terrain. Which makes them a bit useless for your roads :)
     
  18. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Scarpelius - Are you creating your river at height 0 of your terrain? If so, the terrain cannot go below 0 so when the script tries to carve the terrain down, it won't be able to.

    Also make sure your terrain object is at position 0,0,0.

    Tiles - The line of code that forces the road to be above the terrain at far distances (low LODs) is a slight offset property added in the shader

    Offset -8, -8

    You can use any shader you want, just make sure this depth offset is added to your shader code. You can view this if you edit the included shader - you will see this property set early in the code

    Let me know if this helps
     
  19. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Ah, i see. Great tip, thanks. This could come in handy for more than just the road :)

    Problem is, the other shaders doesn`t allow me to edit them. Unity free here. It would end in a disaster anyways, i have no clue about shaders, hehe. That`s why i ask how i could convince your shader to accept to retreive the blob shadow. Looks a bit odd when the environment receives the shadow, and the same shadow disappears below the road :)
     
  20. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Tiles - Ahh sorry man, I haven't messed around with indie shadows. Try commenting out the offset and see if the blob shadows work then. It may be that the offset messes up the projector for the shadows.
     
  21. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Thanks Chris :)

    Bingo, that`s indeed it. Commenting out the offset part makes the road receive shadows again. Unfortunately it is popping into the terrain again now. Seems that i either have to live with no shadow at the road, or with a road that vanishes. Tough decision, hehe.

    Anyways. Many thanks for your help :)
     
  22. SarperS

    SarperS

    Joined:
    Mar 10, 2009
    Posts:
    824
    Very generous, thanks!

    Can we use it for commercial projects?
     
  23. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    Chris, this is an awesome tool! Thanks for giving it to us crazies for free! :)
     
  24. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Mortiis - This tool is completely free for any use, including commercial. You can however find a donation button at the bottom of the tool's webpage if you'd like to support our team.

    I'm glad you guys enjoy it!
     
  25. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Just wanted to post a quick update.

    It is now being released under the Artistic License 2.0 - still open source and completely free, but if you plan to change the source or redistribute it you will need to read the license to see the proper way to do so.

    Also added:

    Now automatically removes any trees/grass/details from path.
     
  26. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Thanks for the update :)
     
  27. SoDoomed

    SoDoomed

    Joined:
    May 28, 2010
    Posts:
    6
    I followed the tutorial, adding the nodes and formed the shape, clicked finalize and there's no path, just nodes. I've tried adding the material, texture, and still nothing happens.

    Also had an error about there being no filtermesh, I guess you have to add the generated mesh to that, and that removes the error but the tool still doesn't do anything.

    So, how do you get this to work?
     
  28. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Great stuff... I would like to have this for Max :cry:
     
  29. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Make sure you read the directions on the website. The mesh is only made if you toggle the path as a "road". If you don't check the road box, it will paint a texture onto the terrain as a path instead of creating a mesh for the road.
     
  30. SoDoomed

    SoDoomed

    Joined:
    May 28, 2010
    Posts:
    6
    Well, if it was as easy as following the directions, wouldn't that be nice. Yes, I have done that a few times.

    I noticed whenever I click finalize it re-creates the path -150 below the terrain, if I click finalize again it goes down another -150 and so on. The Terrain is at 0,0,0

    Also getting another error about an array index being out of range.

    Filtermesh error comes up regardless.

    Maybe i'm missing something, anyway I give up.
     
  31. HansK

    HansK

    Joined:
    Feb 17, 2010
    Posts:
    22
    hey and thanks for that awesome tool.
    My problem: I can't see 2 buttons called "Smooth path" and "Smooth path slope".
    I have only "Add path node" and "Finalize path".
    Tried redownloading the script and replacing it, nothing happens.
    Help please?
     
  32. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    hansK - Smooth Path and Smooth Path Slope are only accessible after you finalize the path. They are just post-creation tools to fine tune the terrain around your road/path.
     
  33. HansK

    HansK

    Joined:
    Feb 17, 2010
    Posts:
    22
    hmm... thanks for answering but they never appear really :( even not after finalizing.
     
  34. HansK

    HansK

    Joined:
    Feb 17, 2010
    Posts:
    22
    can't help?
     
  35. mikesgames

    mikesgames

    Joined:
    Apr 16, 2010
    Posts:
    1,071
    Thanks for the amazing tools!

    There are sooo many made for Unity!
     
  36. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Sorry, I was on holiday for the 4th

    I have tried to reproduce your error but I cannot.

    Keep in mind guys, these tools were developed specifically for our in-production game - so the capabilities and features are specific to our needs and development machines. I will try to help where I can, but I cannot devote much time to re-tooling them for specific cases - it's free and the code is all there so it shouldn't be hard to find out what's going on

    mikesgames - Thanks! That is what's so great about this community!
     
  37. cryal

    cryal

    Joined:
    Jul 7, 2010
    Posts:
    3
    Hi and Thanks for sharing this awesome tools !

    I have been using river tool and it works great! But I am having problem on using the road tool for the same terrain I am testing with.

    I manage to get the polygon preview while creating the path but after i finalize path, I don't see any changes on the terrain besides the few points with arrows that I created from the beginning, which suppose to replace the texture for me. ( i have multiple textures on the terrain, so I can see the differences if there's any changes)

    then i tried checked on the "road" option and did the same thing but I got my terrain deformed, and the mesh I created is way below my terrain height also the road mesh that created is flat.

    Actually I am trying to use this tool to create a mesh on the contour of the hill with specific textures that I can adjust the UV in Max. I really hope that I could use this tool to archieve this.
     
  38. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Cryal -

    With the road option unchecked, you must supply it with a valid texture prototype ID - so if you go to your terrain and see the list of textures used on your terrain, the ID must match up with one of those textures. So if the first texture in that list is a grass texture, it has the texture ID of 0. Also make sure your "Wear" slider is turned up so that the path is more visible.

    When the road mesh is rendered below the terrain it usually means the terrain position is different from (0,0,0). The code samples the terrain height at the node positions. I can't really think of any other reason - I haven't ran into this in my testing.

    I'm working on a new tool at the moment, so when I finish it I will likely do some more testing on these older tools and try to figure out these sort of exceptions. Until then, just keep trying to work with it.

    Hope this helps!
     
  39. cryal

    cryal

    Joined:
    Jul 7, 2010
    Posts:
    3
    Hi Chris,

    Thanks for the feedback. I've found the issue that cause the mesh generated below the terrain which is I have 2 duplicate terrains as I want to keep the original position without moving it. So I manage to get the road mesh work but the result is different than what I am looking for. The preview mesh before finalize is the ideal mesh shape for me but after I finalize it it became flat and deform my terrain. Is there a way to get the mesh render exactly looks like the preview path mesh before the finalize without customize the script?

    As for the path texture without road, I tested on a new terrain which works fine but not with my project terrain. Is this tool supports the terrain that has more than 9 texture in the terrain?
     
  40. cryal

    cryal

    Joined:
    Jul 7, 2010
    Posts:
    3
    oh! I manage to export the generated path mesh to obj while still in progress of adding the path node !

    your tool is genius!
     
  41. BigHippo

    BigHippo

    Joined:
    Aug 23, 2010
    Posts:
    1
    Hi Chris, this is great! Do you have an idea of how difficult it would be to add a "Link first and last" button that would link the first and last nodes, to make a closed loop race track, for instance? Thx!
     
  42. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    Thanks BigHippo - That sounds like a good feature to add and wouldn't be too hard to implement.

    Our team is very busy at the moment converting everything up to Unity 3.0. A new version of this tool and the river tool will be released soon that is 3.0 compatible with a few bug fixes as well.

    I'll try to get that feature in when I get the time
     
  43. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Hey Chris if you've updated the RoadOffset shader for Unity3 i'd love to grab it!
     
  44. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    I updated the packages on the website so the Unity 3.0 offset shader is now included.

    There are also video tutorials for both of the tools now. The road tutorial is here: http://www.youtube.com/watch?v=Q8-wEfxLAKQ
     
  45. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
  46. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Hi Chris. Do you believe that it would be possible to add a possibility in the script so that we could use the tool also as a shore-foam mesh generator?
     
  47. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    94
    Hey Chris, this is looking like a great tool, the path tool is working nicely, however if I try to use the road tool I can't use the Road Material supplied as there is an error in the Shader file:

    Syntax error in Diffuse_RoadOffset: } at line 28

    I am yet to really look at shaders for Unity and haven't done any shaders for 2 years. Is this something that has come up as you have updated it to work with Unity 3? (still using 2.6 just now until our next release and the whole team will upgrade at once).
     
  48. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @elias_t - I think it's possible, but it would take quite a bit of work to automatically generate the nodes. If I were you I would modify the tool to build the mesh flat (not against the terrain) at the height of the water plane and then you'd have to outline the shore manually with the nodes.

    @Dover8 - Yes, when I upgraded the tool to 3.0 I used a surface shader for the road which isn't supported in 2.x. However, the material is nothing special at all - it's just a diffuse material with an offset parameter that keeps it above the terrain. I'll attach the old 2.x shader for you - but remember you can use any material you want, just add "Offset -8, -8" before writing the subshaders.

    Hope this helps
     

    Attached Files:

  49. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    I'm having a slight problem with the shader, in that trees often disappear behind a road... when in fact they're in front. It gets worse as the distance increases between the camera and road. Is there a setting in the shader I can tweak?
     
  50. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @duke - Yes, in the shader you'll see "Offset -8, -8" and these numbers determine the depth priority. You can tweak these numbers until you get the correct depth for your scene.