Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

TubeRenderer – Generate tubes in runtime!

Discussion in 'Assets and Asset Store' started by cecarlsen, Apr 30, 2012.

  1. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    Dear forum

    TubeRenderer is now available on the AssetStore under Scripting/Effects. The script procedurally generates tubes in runtime based on sets of points, radiuses and colours.

    FEATURES
    – Optimised for runtime manipulation
    – Variable edge resolution
    – Per point variable radius
    – Per point variable vertex colours
    – UV mapped
    – Optional tangents
    – Optional mesh inversion
    – Three procedural examples

    DEMOS
    http://sixthsensor.dk/code/unity/tuberenderer/demos/flower/
    http://sixthsensor.dk/code/unity/tuberenderer/demos/snakes/
    http://sixthsensor.dk/code/unity/tuberenderer/demos/spiral/

    ASSETSTORE
    http://u3d.as/content/sixth-sensor/tube-renderer/2Tc

    All the best!
    Carl Emil
     

    Attached Files:

    Last edited: Apr 30, 2012
    vritank likes this.
  2. larsjessen

    larsjessen

    Joined:
    Mar 17, 2008
    Posts:
    44
    Wauw - looks awesome!!
     
  3. Mcg

    Mcg

    Joined:
    Mar 28, 2012
    Posts:
    114
    holy , thats cool
     
  4. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    Thanks for the response! I developed the script to use in my live visuals setup. Here are the latest screenshots.

    ~ce
     

    Attached Files:

  5. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    More screenshots...
     

    Attached Files:

  6. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi Carl,

    Happy owner since a few days,
    Any chances to see a few more examples ?
    I like the static shots a lot. Would it be possible to reproduce them without Pro ?
    Thanks for the nice package,
    -Ippokratis
     
  7. Mcg

    Mcg

    Joined:
    Mar 28, 2012
    Posts:
    114
    some more examples would be great :)
     
  8. bryanleister

    bryanleister

    Joined:
    Apr 28, 2009
    Posts:
    130
    Are you familiar with MoSpline in Cinema4D? Would be cool to understand how to reproduce some of those effects with this. Things like extruding, adding twist, bend and curl to the shapes in real time.

    Really wish I had taken more math in college!

    Bryan
     
  9. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Carl, would be great to see a video of how it is done inside on Unity editor.
     
  10. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,881
    Can we use this to procedurally generate a cave system with some noise and some boolean operations?
     
  11. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    @ Ippokratis
    I'm happy you like it! I'll might produce more examples in the future, but I'm too busy at the moment.

    @bryanleister
    I didn't know MoSpline. Looked at some YouTube clips. The movement seems a bit odd slash not natural, but it's a fun effect. I think you can create a similar effect using a Bezier function and a bit of repulsion on the end points.

    @24pfilms
    The snakes interpolate from moving in a circular formation to wandering about by the influence of sine wave modulations. The formation can move, wander and spin. I also have an external audio analysis connected. I'll hopefully capture a video of the output sometime soon, but I'm not planning to produce a tutorial.

    @Aubergine
    If you want to do caves procedurally I would recommend Voxelform by Mark Davis. It rocks.
     
    Last edited: Oct 26, 2013
  12. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Hi,
    I got the latest update (v1.2) and it's great to see that this asset is still under development! Really cool features. But could you please add again the old spiral and the old Flower examples?
     
  13. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    I'm happy you like it! I can send the old examples to you personally (pm me with your email address). The new examples are far more pedagogic and I want to keep the package minimal. If enough people encourage me to add the old examples then I will consider it.
     
  14. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    634
    Could you make grass with something like this?
     
  15. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    I got an old version in a testproject I made a couple of months ago , so I have the code, but I thought it would be nice to have it in the latest release and don't have to remind me all the time where the old codepieces are. Your examples giving good inspiration, what you can do with tweaking only a couple of parameters and some math. Speaking for me I like to see as much as possible examples you could provide for this asset. (I think you have the right creativity to give us more inspiration :D )
     
  16. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    @blueivy
    You can make straw. Grass leafs are flat and I would recommend using a billboard particle system in most cases. Maybe I'll add a squeeze method so that you can make leaf-like meshes at some point.


    @sloopidoopi
    Thanks. I will probably post more examples in the future =)
     
  17. EvilFox

    EvilFox

    Joined:
    Jul 23, 2013
    Posts:
    83
    I think so too :)
     
  18. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    Now for the official announcement!

    I have updated the TubeRenderer. I'm very happy with the new features and I hope you will be so too.

    Firstly I've added a remote reference page with demos.
    http://sixthsensor.dk/code/unity/tuberenderer/

    Also I've:
    • Converted all methods for setting and getting tube data to properties.
    • Added 'caps': open or close the end points of your tube.
    • Added 'uvRect', 'uvRectCap' and 'uvRectCapEndMirrored': create custom uv mappings.
    • Added 'forwardAngleOffset': rotate tube around it's forward direction.
    • Added 'AddPostprocess', 'RemovePostprocess' and 'postprocessContinously': post process the mesh of your tube.
    • Added 'MarkDynamic' shortcut to mesh.MarkDynamic(): optimise for runtime manipulation.
    • Added 'drawMeshGizmos' and 'drawMeshGizmosLength': display gizmos for normals and tangents.
    • Implemented modulo iteration for cases where the length of point, radius and color arrays don't match.
    • Perfected normals and tangents for tubes with variable radiuses.
    • Fixed minor update issue with 'calculateTangents' and 'invertMesh'.
    • Fixed rotation issue with doubled points.
    • Added custom inspector and enabled editor execution.
    • Moved documentation to 'AssetStore/TubeRenderer/Reference.md' and updated it.
    • Created new examples and updated the old.
    In summery the features of 1.2 are:
    • Optimised for runtime manipulation
    • Per point variable radius
    • Per point variable vertex colours
    • Customisable uv mapping
    • Optional tangents
    • Optional caps
    • Optional mesh inversion
    • Optional mesh post processing
    • Seven procedural examples
    If you like it, then please don't forget to rate it and leave a review on the Asset Store.
    The more it sells the more time I can devote to developing it.


    $ForumShot.jpg
     
    Last edited: Nov 6, 2013
  19. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Just left a 5 star review ;)
     
  20. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    Yes! TubeRenderer now has three normal rendering modes; Smooth, Hard and HardEdges. This opens up for a whole new range of possible procedural shapes. The example below is generated in Unity and rendered in Modo.

    If you like it, don't forget to rate it in the AssetStore.

    $ForumShot3.jpg

    $ForumShot2.jpg
     
  21. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Awesome work man
     
  22. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    I have this asset but cannot download the latest update because the asset store requires Unity4.3.1

    Can you update the asset store to a lower version because 4.3.1 still has bugs and i cannot use it yet.

    Cheers.
     
  23. Nour-Asser

    Nour-Asser

    Joined:
    Feb 25, 2015
    Posts:
    3
    Is the tubes in this models are hollow??.. can i pass an object like sphere through it??.. please respond Thnx
     
  24. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    I am not sure I understand you correctly, please elaborate. The tubes have no collider by default (but there is an example included that shows how to do that).
     
  25. Nour-Asser

    Nour-Asser

    Joined:
    Feb 25, 2015
    Posts:
    3
    i need this tube to be like this. Check this out: http://www.janthor.com/tunnel/singletunnel.php?img=m8_barba_big.jpg
    this what i need and i want to be sure that i can pass an object through that tube
     
  26. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    Yes that is doable. One approach would be to: 1) Find a script online for calculating bezier curves 2) define your curve points and evaluate the curve at the resolution you want 3) pass the evaluated points to TubeRenderer and set 'invertMesh' to true 4) translate a camera along the same curve 5) enjoy a classic tunnel ride.
     
  27. Nour-Asser

    Nour-Asser

    Joined:
    Feb 25, 2015
    Posts:
    3
    Thnx a lot
     
  28. durvalp1

    durvalp1

    Joined:
    Aug 2, 2013
    Posts:
    3
    Hi. Is it possible to define splines with this plugin? I need to trace paths of transports in a city model, and I need to be sure they are going to be accurate.

    Cheers!
     
  29. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    There are no spline functions included. But, you can 1) find a spline script somewhere on the internet, 2) evaluate points on your curve and 3) assign those points to a TubeRenderer component. The result will be as accurate as the points that you provide to the tube.
     
  30. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    Version 1.9.4 is available today!

    Eight years on Asset Store and still kicking! Can you believe it?

    - Added compatibility with URP and HDRP. - Added GetLengthAtPoint().
    - Eliminated minor garbage created when normals were recalculated.
    - Adopted unity's semantic versioning.
    - Adopted package default package layout file structure.
    - Updated Slide example to use compound colliders.

    If you like it, don't forget to rate it.

    http://u3d.as/2Tc

     
    hopeful likes this.
  31. acmoles

    acmoles

    Joined:
    Jun 28, 2016
    Posts:
    4
    Hello! Looks good but two questions:

    How good is TubeRenderer at handling >=90deg elbows and constantly adding points to extend the line?
     
  32. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    1) TubeRenderer is not doing any intersection tests, so a 90deg turn will result in a loss of volume.
    2) TubeRenderer stores points in a bullet array. Changing the array length every update is possible, but will generate memory garbage.
     
  33. acmoles

    acmoles

    Joined:
    Jun 28, 2016
    Posts:
    4
    Thanks for the info @cecarlsen !

    Probably not for my use case then, but still looks like a really nice tool.
     
    cecarlsen likes this.
  34. SpaceOwlGames

    SpaceOwlGames

    Joined:
    Apr 22, 2016
    Posts:
    61
    I'm getting around 30FPS with the herd example with the TubeRenderer.LateUpdate taking 22ms. Would it be possible to improve this with the new Job / Burst System?
     
  35. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    It sure would. But it would require a complete rewrite. And it would probably be most efficient if users are also on DOTs.

    I wrote TubeRenderer more than 10 years ago and have since optimized it to a point where there is not much more to win if you stay in C# managed land.

    Nowadays I compile meshes in compute shaders. I haven’t had time to make a public/user friendly version of a GPU tube renderer yet though.
     
    Last edited: Sep 5, 2023
    hopeful likes this.
  36. Wilbert-Blom

    Wilbert-Blom

    Joined:
    Aug 13, 2011
    Posts:
    111
    Is it possible to have different radiuses for x and y direction?
    So I can make a flat tube.
     
  37. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    870
    It's not a feature, but you can mod TubeRenderer to do this at no performance cost. Try replacing Vector3.one with new Vector3(1f,0.5f,1f) at line 616 and 626.
     
    Wilbert-Blom likes this.
  38. Wilbert-Blom

    Wilbert-Blom

    Joined:
    Aug 13, 2011
    Posts:
    111
    Worked like a charm! Just had to use new Vector3(0.3f, 1f, 1f) because I wanted it flat(ter) the other way.
    THX!!!!
    upload_2024-4-24_15-29-11.png
     
    cecarlsen likes this.