Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[RELEASED] Curvy 2 - the ultimate spline solution

Discussion in 'Assets and Asset Store' started by Jake-L, Sep 29, 2015.

  1. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    You want smooth camera flights?
    You want your player to follow a dynamic path?
    You want mesh extrusions along curves? With objects cleverly placed on the mesh's surface?
    What about moving your player or any other GameObject over that surface?
    You want a fast, mobile-ready solution?
    You want a battle-proven spline solution that can be seamlessly integrated in your custom level editing tools?

    Curvy 2 - Highlights
    • State of the art SceneView curve editing for most common curve types (Linear, Bezier, Catmull-Rom, Kochanek-Bartels)
    • Extensive Orientation management offering dynamic orientation smoothing while keeping full control
    • Graph based Content Generator to create extrusions, clone objects, mix paths and more
    • A range of ready-made controllers to make your GameObject interact with curves, mixed paths and extruded volumes
    • Designed for speed through a highly optimized caching system, threading and object pooling
    • PlayMaker custom actions
    • Full C# source code - well structured and fully IntelliSense documented
    • Extensive documentation, full API reference, tutorials
    • Developer friendly: highly customizable and extendable, rich API (Runtime & Editor)
    Trailer

     
    Last edited: May 2, 2018
  2. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    183
    Wow, it's looking awesome!
    (First ;)
     
  3. Haagndaaz

    Haagndaaz

    Joined:
    Feb 20, 2013
    Posts:
    222
    Would this be able to create roads / road intersections? Or is that outside the scope of Curvy?
     
  4. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    It can create roads and railtracks and does handle intersections logically. Graphical representation of intersections/crossing needs to be handled manually (i.e. Curvy doesn't build complex intersections graphics from scratch).
     
  5. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,545
    thanks for the big update. There are some scenes that are broken, and missing references. I tried sending you an email but it bounced as spam. Your spam filters are very strong
     
  6. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    Hi there! Can you elaborate on which scenes had the issue and which Unity release you are using? And perhaps paste the error trace from the console tab of the editor?
     
    Last edited: Sep 30, 2015
  7. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Curvy 2.0.1 Release notes
    • (NEW) CG path rasterization now has a dedicated angle threshold
    • (NEW) Added CurvyController.ApplyTransformPosition() and CurvyController.ApplyTransformRotation()
    • (FIX) CG not refreshing as intended in the editor
    • (FIX) CG not refreshing when changing related splines
    • (FIX) Controllers resets when changing inspector values while playing
     
  8. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    791
    The new version look very cool and improved but it's not GC safe, took me a while to remove all runtime allocation in 1.6, surely won't redo everything again.
    I'll keep an eye on this for future version.

    By the way, the package is broken, it complained about IMeshModifier not being implemented on UITextSplineController using Unity 5.2.
     
  9. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    This is caused by an unannounced change UT folks made in the IMeshModifier interface with Unity 5.2.1p1 (not sure if that's even intentional on part of the devs, interface changes like those shouldn't really land in patches, and this wasn't even mentioned in the notes). The package should work fine with 5.2.1. An appropriate check for this change is already in the repo and will arrive in the next store update of Curvy, I think.

    Can you elaborate on the GC issue? What scenario with Curvy 2.0 specifically caused GC issues for you?
     
  10. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    791
    There are various allocation at runtime, a simple profiler will show you.
    By memory if I recall they are on HasEvents on CurvySpline move and other methods.
    Probably other parts I can't remember now.

    By the way, the new mesh generation is too complex( and I think too slow for runtime generation on mobile).
    Prefer by far the old simple version, that even with many limits was blazing fast and easy.
     
  11. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    183
    Unity 5.2.1.p.1
    Curvy 2.0.1
    Fresh project

    Assets/Packages/Curvy/Controllers/UITextSplineController.cs(73,19): error CS0738: `FluffyUnderware.Curvy.Controllers.UITextSplineController' does not implement interface member `UnityEngine.UI.IMeshModifier.ModifyMesh(UnityEngine.UI.VertexHelper)' and the best implementing candidate `FluffyUnderware.Curvy.Controllers.UITextSplineController.ModifyMesh(UnityEngine.Mesh)' return type `void' does not match interface member return type `void'
     
  12. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    As I've said above, temporary workaround seems to be a switch to Unity 5.2.1. Unity folks made an undocumented change in that interface with p1, breaking assets using it.
     
  13. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Anyone using 5.2.1p1: Get the temporary fix here!
     
  14. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,625
    It looks cool. In 3d, what about if you want it to randomize or modify the path shape at runtime, and regenerate a section of geometry along that path, and randomly add/position objects along the path, so that each time you play (follow the path) it's a different experience? Do we have to dip into script API for all that or is that built-in to the generator stuff?

    My other question is about 2D use... could it be used to create side-view curves, like a side-view of a tube, curved surfaces, with Physics2D colliders? And can the spline curves be animated at runtime by accessing the nodes via an animation clip, or is the data for the nodes too embedded as variables which can't be animated?
     
  15. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    We keep GC alloc as low as possible and not all allocations you see are intentional, but can be fixed (saying that, just fixed a few glitches that caused GC alloc being higher than needed, will be in 2.0.2). But you won't get a package completely allocation free, no way!
    For example, when moving over a spline, Curvy needs to check whether events has listeners or not, because with no listeners present the movement is far simpler and faster than with listeners attached. Checking allocates 20 bytes and there is absolutely no way around until Unity makes that property public (btw, vote for it here!).

    After all, having some memory allocations isn't evil, it all depends on the amount.

    Besides the fact that Curvy Generator is 2x-3x faster than the old MeshBuilder for similiar tasks, it is well structured and complex tasks are broken down into easy to configure modules. You want the old functionality? Create a CG, add the "Shape Extrusion" template, drag a spline to the path and you're done. Create templates as you like and use them to build complex graphs with a few clicks.

    Sure, there is a gentle learning curve, but the possibilities of the system are endless and you can create things you won't ever achieve with a single component.
     
  16. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Randomly scatter objects along the path is already builtin. To randomize a path just randomly move Control Points of the path's source spline.

    This is absolutely possible, but dedicated 2D modules aren't in yet, but planned for the near future (e.g. a dedicated 2D line renderer). CG is a completely new system and we have some great ideas in stock and will continously add new modules and functionality.

    Control Points ("nodes") are GameObjects, so you can easily animate their transforms.[/Quote][/QUOTE]
     
  17. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    183
    Sorry for asking, but are you guys working on a beginners tutorial for your CG?
    I'm sure it's all easy and very, very cool - but not knowing how to 'crack the nut' it can be very hard to get into really using it - I sit here and try and test the demos etc, but there are so many things left to guess - like the most basic stuff, so I still cannot start my own project from scratch and make cool things.

    A tutorial or two just showing how to build a couple of different things - like the railroad for example - hills and all - from scratch, explaining all 'simple' steps.. even like how to refresh the CG generated mesh, or how to place a spline on the ground etc and make hills without the railroad sinking into the ground before the hill etc - basic stuff.. would be VERY nice and make it easy to pick up all the complex stuff that it looks like you are documenting nicely :)

    (I'd offer to do the tutorial for you if only I knew how it all works myself ;)

    Thanks!
     
  18. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    We're totally aware that the new features need some good tutorials. Just be a little bit more patient, they're on the way...
     
    hopeful likes this.
  19. BirdieL

    BirdieL

    Joined:
    Oct 3, 2015
    Posts:
    7
    Hi Jake, Could you briefly explain how I can make connections with your graphic tool and in code? I am using your Curvy 2.0 and having trouble with both ways. Thanks
     
  20. BirdieL

    BirdieL

    Joined:
    Oct 3, 2015
    Posts:
    7
    Hi Jake, I figured by looking at your examples. Thanks.
     
  21. BirdieL

    BirdieL

    Joined:
    Oct 3, 2015
    Posts:
    7
    Hi Jake, could you tell how to connect a spline to a random point(instead of control point) of another spline? Thank you in advance!
     
  22. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    183
    Cool!

    Just an input: You do not have to overdo it with music, cool graphics etc.. If you just sit down with a screengrapping tool, shoot for as long as it takes to set something up - including mistakes and all: Shoot, Upload, done - this works often much better than a polished video.. and is SO much faster to do :) Thanks!
     
  23. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    @BirdieL
    You can't connect a spline to a random point, because a connection is fundamentally a special container holding two control points, not two positions. You can easily insert a new control point into the spline, though (enter Draw Spline mode, select a control point you want to precede your new one, click on a plane, voila), or shift any of your neighbouring control points to the specific position on a path you like (this is one of my favorite small features - select a control point, press Shift on the toolbar, and you can slide it along a path without bothersome XYZ position adjustment). After you have a point, set up a connection - you already know how, I guess.
     
    Last edited: Oct 7, 2015
  24. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    @Fritsl
    We'll try not to overdo it! Just got to finish the huge video about splines themselves (almost done), and then we'll be able to dive into a CG video.
     
    Last edited: Oct 7, 2015
  25. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    bac9-flcl likes this.
  26. pluhn

    pluhn

    Joined:
    Jul 27, 2010
    Posts:
    42
    I'm using Curvy to create power cords, and my scene is modeled in 1m to 1 Unity unit scale. In Shape Extrusion under Scale, I have to set the scale to .005 in order for the cord radius to be the right size. Even with path resolution set to 100, the mesh ends up not following the curve with a high enough resolution. Is there any way around this?
    curvy2.jpg curvy.jpg
     
  27. pluhn

    pluhn

    Joined:
    Jul 27, 2010
    Posts:
    42
    Aaaaand... nevermind, I figured it out. Adjusting the Max Cache PPU in the Curvy settings fixed it.
     
    hopeful likes this.
  28. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    160
    I make intensive use of splines in almost all my projects and I'm currently using SuperSplines for the purpose. That plugin is now grown old and hasn't received any update in more than a year and a half. Since I need something better and more optimized, I think I'll totally go with Curvy 2. It looks rad, congrats for your work!

    I have one question, though, before I begin: when you extrude a shape along a spline, can you optimize the mesh to have more or less subdivisions depending by the curvature? Just like the green thingy in the picture. My current mobile project features very long procedural roads, so I'd like to go easy on the polycount without sacrificing quality too much. Currently no spline plugin can do that, as far as I know!

    Also, another vital thing to me: having a Vector3 as reference, is it possible to get the closest point on the spline?

     
    Last edited: Oct 15, 2015
  29. pluhn

    pluhn

    Joined:
    Jul 27, 2010
    Posts:
    42
    I'm having another issue. It looks like optimize path doesn't take into account max cache PPU, which I have set to 30. The left is before optimization and the right is after with an angle threshold of 2.5. Changing the angle threshold doesn't affect anything other than moving the joints slightly.
    curvy.jpg
     
  30. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    Yes, you can definitely do that, check the Optimize mode in the Shape Extrusion CG module. More than that, you can separately define the threshold angle for cross section vertices and path vertices - for example, to make a very low-poly (e.g. 4-sided) cross-section that is very finely subdivided on path turns.

    Yep, check the 05_NearestPoint example scene. :)

    Can you tell us the Resolution of Shape Extrusion path, your max cache PPU value, Cache Density value on the spline you are using as a path; and enable the Orientation visualization and make a screenshot with it's lines visible on that spline?
     
  31. pluhn

    pluhn

    Joined:
    Jul 27, 2010
    Posts:
    42
    The resolution of the shape extrusion path is set to 100. Max cache PPU is set to 30. Cache density of the spline is 100.
    curvy.jpg
     
  32. pluhn

    pluhn

    Joined:
    Jul 27, 2010
    Posts:
    42
    I've got the resolution set to 100 everywhere I can.

    If I turn on Debug, the Samples Path/Cross changes from 56/9 to 15/9 when optimize is turned on. Not sure if that tells you anything.
     
  33. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    The spline is very short (1.8 world units) and in this case MaxCachePPU or extrusion resolution isn't the limiting factor, but CurvyGenerator.MinDistance (defaults to 0.1 world units). Set it to 0.01 or even lower and it works!
     
    pluhn likes this.
  34. pluhn

    pluhn

    Joined:
    Jul 27, 2010
    Posts:
    42
    Yes! Thanks for the help.
     
  35. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    If you're curious about the reason for that property: it's used to prevent runaway loop insertion with extreme settings (e.g. when a user sets optimized extrusion angle threshold to 0.01) and to prevent deadloops that can be triggered from float inaccuracy. You shouldn't encounter any of that with your spline, but default settings err on the safe side and are tweaked for somewhat bigger splines, hence the need to tweak that value :)
     
    pluhn likes this.
  36. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Could you clarify how Curvy 2 works with LODs?

    Would it be possible to have a curve be more accurate and add more polygons to dynamic geometry the closer the camera is? Does dynamic geometry chunks help in this regard?


    EDIT:

    I'm also interested in detailed UV layout for extrusion shapes. Could you elaborate, the documentation isn't very clear.

    Could you animate individual bones along a curve?
     
    Last edited: Oct 16, 2015
  37. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    Fitst of all, spline extrusions support segmentation, so they can take advantage of occlusion culling and, theoretically, of local LoD swapping. Yes, it's probably possible to write a custom component that will handle such an extrusion and trigger rebuilding of segments with different settings on every shift of a camera based on a distance to it, but I can't recommend it.

    Far, far less complex mesh operations, like subdivision and heightmap-based displacement in the standard terrain system, are already a very performance heavy. Rebuilding of very complex meshes like spline extrusions requires a lot more complex math and will be even less friendly at runtime. While doing it once it a while when your gameplay requires it or some animation requires it is fine, it's not really the best idea to constantly rebuild all the splines you see in a frame using the distance as a factor. It won't ever run well.

    There are some alternatives if you invariably need LoDs, though. Splines allow you to export meshes! So, you can segment your path into however many extrusions you want, and for each, configure CG settings you see as appropriate for each LoD level, export each configuration into a mesh, then place those static meshes with LoD into the scene. That can work if you are using Curvy to author static level geometry like pipes that you won't need to modify at runtime or tweak frequently.
     
    StaffanEk likes this.
  38. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Yeah rebuilding of curves doesn't sound so hot. I think interchanging LOD0 and LODn chunks sounds more reasonable.
     
  39. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Does the custom UV mapping support tiled chunks in an Atlas texture?

    For example: A sidewalk is within UV coordinates 0.0 U - 0.3 U / 0.0 V - 0.3 V. If the sidewalk becomes wider it will still tile with the same texel density from the respective UV coordinates.
     
  40. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    Can you post an example of an atlas? I made some examples using custom UVs from atlases with consistent texel density (e.g. railtrack sides + railtrack center or that scene with pipes), but maybe you're talking about something a bit different. Myself I never found any limitations that prevented me from getting nicely consistent mapping from an atlas.



    Generally, if you want the sidewalk or some other part of an atlas to very reliably snap to a specific part of a cross section, you should make the end point of that part use Explicit U or UV seam flag too, - not just the first point. Then, instead of using an averaged U scale across all cross section patches (which prevents V tearing but might not necessarily get you the scale you want), U coord will be very precisely mapped between two vertices you have configured.
     
    Last edited: Oct 16, 2015
    StaffanEk likes this.
  41. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    I'm just wondering if it's possible to have the grass tile along a curve even though there are other textures "in the way".



    Or would I need to have an atlas that looks like this where the is nothing in the way of the grass texture in the U direction.



    EDIT: If the grass part becomes larger how will it continue tiling? In your example, can you make the rail part become higher in some parts of the track without stretching the texture?
     
  42. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    Ah, nope, that's impossible. And it's not even about Curvy, you can't do that even with traditionally authored geometry unless you use stuff like DX11.2 tiled resources. It's not up to geometry to conjure up tiling when there are no UV seams and vertices to insert wrapped coords and when the texture can't support it. :)



    The only solution can be welding limited areas, basically making every single cross section loop a UV seam. It's a pretty poor fit for extrusions as you typically want them to have variable subdivision based on curvature and as you want them to have a minimal vertex count (UV seams will inflate it). And not that good solution in general without very painstakingly authored atlases with dilated margins etc.:



    But if there is a tiling on one axis, then yes, everything works perfectly. Here is the atlas I used in example above:

     
    StaffanEk likes this.
  43. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Thanks for clearing that up.

    Unless your atlas is comprised of 8x8 images for instance. Then you can simply have the mip levels made out of individual image tiles without any mip leaking whatsoever.

    EDIT:

    8 x 1024

    8 x 512

    8 x 256

    8 x 128 etc..
     
  44. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    777
    Technically you can write a custom shader that will offset tex2d UV input into the range you desire when it goes outside the first tile, but I can't really recommend doing stuff like that outside of terrains.

    Not sure what you mean by 8x8 idea, leaking from filtering and mip mapping will still occur in that case, tile size and count being power of two does almost nothing to prevent that.
     
    StaffanEk likes this.
  45. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    You can write custom mip files from different layers into a .dds format with Gimp 2. If the tiles are reduced individually they will not bleed to their neighbors.
     
  46. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Curvy 2.0.2 Release notes:
    • (NEW) Added Range option to Input Spline Path and Input Spline Shape modules
    • (NEW) CG editor improvements
    • (NEW) Added more Collider options to Create Mesh module
    • (NEW) Added Renderer options to Create Mesh module
    • (NEW) Added CurvySpline.IsPlanar(CurvyPlane) and CurvySpline.MakePlanar(CurvyPlane)
    • (NEW) Added CurvyController.DampingDirection and CurvyController.DampingUp
    • (FIX) Controller Inspector leaking textures
    • (FIX) Controllers refreshing when Speed==0
    • (FIX) VolumeController not using individual faces at all occasions
    • (FIX) Unity 5.2.1p1 silently introduced breaking changes in IMeshModifier
    • (FIX) IOS deployment code stripping (link.xml)
    • (CHANGE) CurvyController.OrientationDamping now obsolete!
     
    bac9-flcl likes this.
  47. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,089
    Hi On the latest version I'm getting this error in unity 5.2.1

    Assets/Packages/Curvy/Base/CG/CGModule.cs(594,42): error CS1061: Type `PoolManager' does not contain a definition for `GetPrefabPool' and no extension method `GetPrefabPool' of type `PoolManager' could be found (are you missing a using directive or an assembly reference?)


    Assets/Packages/Curvy/Base/CG/CGModule.cs(599,42): error CS1061: Type `PoolManager' does not contain a definition for `FindPools' and no extension method `FindPools' of type `PoolManager' could be found (are you missing a using directive or an assembly reference?)

    Assets/Packages/Curvy/Base/CG/CGModule.cs(604,35): error CS1061: Type `PoolManager' does not contain a definition for `DeletePools' and no extension method `DeletePools' of type `PoolManager' could be found (are you missing a using directive or an assembly reference?)
    any ideas?
     
  48. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    You most likely have another package installed that contains a class of type "PoolManager" without being namespaced or you didn't imported the whole package.
     
  49. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,089
    yes I had a class already called PoolManager.
     
  50. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    If you can't namespace the other poolmanager you'll have to change all files using FluffyUnderware.DevTools namespace (i.e. all files that raise that error), adding "using PoolManager = FluffyUnderware.DevTools.PoolManager" to the file's using block.