Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback At which point in time will Unity add Splines?

Discussion in '2021.2 Beta' started by Rowlan, Mar 2, 2021.

  1. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Now that there's 2021.2 Alpha, can you please give an ETA about when we'll get Splines? Thank you!
     
  2. Schodemeiss

    Schodemeiss

    Joined:
    Jan 4, 2018
    Posts:
    43
    Wow - Splines come up A LOT in this forum. Seriously, if Unity just dropped everything they were doing and spent ALL their energy on Splines (and whatever Editor improvements they are making to support them better), I swear this forum would go almost silent.

    Of course, I'm being entirely tongue-in-cheek and I don't mean any harm - I just find it surprising how often splines comes up in here.
     
  3. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hey! :) We can't make promises on timeline. However, very exciting, as of this week our team focus switched from Overlays, to Splines!

    This is a good time to note, we'll have some research surveys and moderated sessions coming up soon ... keep an eye out for those, if you'd like to participate - thanks!
     
    ledshok, bradshep, BATTLEKOT and 21 others like this.
  4. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    A.W.E.S.O.M.E.!!! :)
     
    gabrielw_unity and NotaNaN like this.
  5. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
  6. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Last edited: Mar 22, 2021
  7. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Done. What wasn't covered in that survey was the movement along the spline. Is it possible to

    * move by percentage
    * move by distance, ie meters
    * move by gameobject bounds (considering rotation along spline)

    Then some core functionality:

    * snap to any object when you place a node, eg terrain
    * i don't want to move tangents, that's tedious
    * quickly add at begin/end or inbetween
    * quickly delete without moving to every single node, ie adding deleting should be fast without much user interaction
    * align objects along spline, eg fence



    or houses

    town-opt.gif

    or vegetation

    bushes.gif

    Then some extended functionality:

    * physics along splines



    * multiple splines via offset

     
    Last edited: Mar 23, 2021
  8. Schodemeiss

    Schodemeiss

    Joined:
    Jan 4, 2018
    Posts:
    43
    Just me, or is this a HUGE question: "What do you expect a spline tool to be able to do?"
     
    gabrielw_unity likes this.
  9. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,068
    I just hope spline implementations is going to be minimal (but not super minimal ;) ) and interface based.
    All this extra features (spawning morphing etc.) can be build around it but should not be a part of it.
    My 5 cents.
     
  10. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Yeah, same here. I'd have expected the spline tool to be just that. And everything else evolve around it. I don't expect any of the things that were in the survey. Or what I showed above. Just position nodes, create splines, move along them, save them, re-use them. Nothing else.
     
    mariandev likes this.
  11. Schodemeiss

    Schodemeiss

    Joined:
    Jan 4, 2018
    Posts:
    43
    Yes, this. I'm quite happy if they expose some Events and a programming API so we can do stuff at runtime - but that should be down to the dev.
     
  12. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    862
    I think that splines in the editors should be separated from runtime splines. Editors splines should just be editor tools.
     
  13. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,237
    Based on the questions in the survey (which seems to anticipate a lot of use cases!), a spline may not be bound to a Monobehaviour per se, but it may act as a front end/editor. So hopefully it'll still be possible to create splines entirely through an API, without any game objects, at runtime or otherwise.
     
    NotaNaN likes this.
  14. DoctorShinobi

    DoctorShinobi

    Joined:
    Oct 5, 2012
    Posts:
    219
    It'd be nice to have a choice to create a spline that can either be saved as an asset(allowing multiple reuses of the spline) or just be copy-pasted as an inspector value(which is quicker and doesn't litter the project with assets).
     
  15. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    469
    Also would like to see support for importing splines from fbx or other formats so we can draw them in external programs.
     
    Ruchir likes this.
  16. Havokki

    Havokki

    Joined:
    Jun 28, 2015
    Posts:
    118
    I hope you guys provide an API that does not generate new arrays on each call like so many Unity APIs do, otherwise this will be just another feature we have to avoid.
     
    Orimay likes this.
  17. Schodemeiss

    Schodemeiss

    Joined:
    Jan 4, 2018
    Posts:
    43
  18. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    950
    And thread safety would be really nice, going forward.
     
  19. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Wow! That generated a lot of replies - super! Thanks everyone who took the time to respond in the survey, we're very happy to get all that info. And I'll walk through here as well - gimme a bit to formulate good replies ...
     
    NotaNaN, JonSWEDEN, MousePods and 2 others like this.
  20. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Alright, I think the first thing to address, is clarifying exactly what we are creating - and that is only a spline.

    So, essentially:
    - list of points forming a path, with tangents to set curves if needed
    - tooling for manipulating these points
    - utilities for accessing the spline data (runtime or editor)

    Additionally, we're making it easy (on both artists and developer side) to set custom data along the path.

    So, for developers this means yes it ought to be a really, really clean and performant base solution. Ideally, existing Asset Store spline developers will also benefit from this! (and we'd love to chat with you ... )

    For artists, it means nice consistent tooling/workflow for splines, no matter what.



     
    gaolei_nls, Nexer8, NotaNaN and 6 others like this.
  21. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hey, thanks for the detailed reply! :)

    Moving along a spline, instantiating, physics - since we're just providing the spline (see directly above post), you/others would implement this, in whatever way you like. We might provide some basic additional components for "Animate/Move Along Spline, Instantiate Along Spline, Render Spline as Tube/etc" ... but they would be meant as examples, at best.

    So, why are we being so lazy and not providing complete direct-to-artist uses? :p We've talked a lot on this. And the simple answer is, we can't both a) provide everything the 80% would need, while also b) keeping the spline light and minimal.

    Perhaps more importantly, we also know from experience ... needs change fast. And Unity changes slowly. For example, did you hear about that spline thing, and how long it took? :D har har ...

    We're not the right people to provide the detailed functionality - instead, we want to just ensure everyone gets solid, quality foundational elements, API, base tooling, extensibility.
     
  22. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Ha, well, we wanted to get a real big-brush picture first, then get into details. There were some really useful replies to this one, and the final "what did we miss?" long-form questions. Thanks!
     
  23. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    So, "yes". :D

    This was a tough decision to make (especially as an artist myself), but it appears to be reflected well, both here and in the survey - total separation of "spline" (ultra minimal) and "stuff that is added onto the spline or references it etc". Great to hear we took the right path!
     
  24. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Very likely :) We don't expect this to be super common (and the survey confirms this), but when it's needed ... it's critical. I don't want to deny/confirm anything before it's 100%, but this is very likely.
     
    Ruchir and DoctorShinobi like this.
  25. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    This one ... unfortunately we have no control over :( It's up to FBX, which doesn't currently support splines (not really, it bakes them down, yuck).

    Interestingly, we also saw very little desire for this in the survey ... we expected it to be a top item ...
     
    Ruchir likes this.
  26. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    We have a custom spline solution which we use to generate roads, fences, etc. It is quiet a complex system, here is a screenshot of our scene view to demonstrate:
    unknown.png

    The splines are referenced by various generators. When any splines referenced by the generator is changed/dirtied, we tell the generator to regenerate its content (might be a fence generator, road surface, etc).

    The roads are done with splines as you can see, but so are the factory walls and fences. (The splines are not visible here)

    Some things that we would find useful if we wanted to replace our in-house splines with Unity's splines:
    • Ability to specify "roll", so the points on the spline have a position, direction, a tangent and a normal.
    • Functionality to retrieve a list of evenly distributed points along the spine (try to keep X units between points where the start and end are always included. Points will rarely be spaced exact X units apart, but the algorithm should do it's best to make sure they're spaced as close to X as possible)
    • Some sort of callback or quick/efficient way to check if a spline is "dirty" so we can regenerate geometry etc that depends on the spline
    • More specifically, it is very useful to know which segments within the spline are dirty so we can regenerate only the parts of the mesh that depend on the dirty segments. (Where a segment is all the points that lie between 2 knots).
    • Building on the previous point, it is nice to have some way to specify/"reference" a span within the spline and be notified (or be able to check) when it is dirty and be able to fetch evenly distributed points within that span, too. IE "Reference a span on 'Spline A' starting at '25%' and ending at '75%'."
     
    Last edited: Mar 27, 2021
    rz_0lento, NotaNaN, mh114 and 6 others like this.
  27. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    What exactly does this entail? If we have some custom data for a spline, and the spline has new points added, how is that handled?


    Ideally we would be able to implement an ISpline interface that the UI tools could use, so we're free to lay out the data in whatever way we want. All the UI really needs to know about is the positions of the nodes and control points, so if I could just hand that to you (and get a callback for changes), that'd be the most flexible solution.
     
    NotaNaN and Wolfos like this.
  28. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    For those interested, Gabriel shared a screen in my YAPP thread. This will be awesome stuff, so many possibilities :)
     
    gabrielw_unity, Havokki and Onigiri like this.
  29. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    469
    Just had a look on them from UI point of view. I love that splines and handles are smooth and antialiased. @gabrielw_unity Can you also make points to look like camera aligned dots instead of cubes and spheres? Right now they feels... not so modern. Attaching example from sprite shape spline. I think it would be good for both systems to look the same.
     
  30. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Ah! Sorry for the late reply, especially after your help!

    So, it's 2 options:
    1. You use the default generic spline and store data in your component, using "path points" (distance or percentage along the spline)
    2. You "extend" the spline class (I may have wrong term there), and can include extra data directly in the spline, which allows you to attach that data directly to knots.

    That's the general idea :)
     
    Baste likes this.
  31. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Thanks!! :) Yes, it's coming along!
     
  32. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    I think in 2D mode, that looks great - hopefully yes we can keep enable a switch for that? However, we found those handles were really difficult to see/use in 3D space, so we switched up to the 3D handles. Also, the cubes for knots/control points will be important for indicating the 3D orientation of the knot! :)
     
    JoNax97 likes this.
  33. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Ah, @Baste , I might have misunderstood - are you expecting to get events like "add control point", "move control point", etc, from your custom component?
     
  34. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    Yeah, the way imgui is set up, polling for changes can be really bad. It's just not intended at all in uitk.

    So if I make a custom tool like SpriteShape that uses your splines, then I'll want to immediately update the mesh when the user moves/changes control points. I'll also want to know which points are updated so I can restrict my updates to the relevant parts of the mesh.

    I mean, I assume that you're building something somewhat real on top of this (ie. that this is something you're actually implementing, not just something you drew), and that you'll avoid too many gotchas when making systems like that.
     
    Rowlan likes this.
  35. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    My wish list for the spline itself:
    - definitely expose tangent controls - this is a must IMHO. Let people who don't care about then just use defaults but don't take the control away from people who need it.
    - let us use stock unity transform tools to adjust spline rotation in all 3 axis (so we can roll/twist the spline as well. I know this makes it mathematically more complicated but it's what people expect from tool like this)
    - let us use stock unity transform tools to adjust spline scale so we can do later whatever we want with the scale data on our own tooling. With obvious road example this would control the width of the roadmesh when we build our own code on top of this but could be handy to have scale access per point for all 3 axis for all kinds of things if you want to do more fancy generators that adjust thickness of the objects, spacing etc whatever directly from the transform tools.

    and for the utilities/tooling:
    - obvious getters for transforms along the spline based on distance (and optionally also based on percentage as it's more artist friendly, this is trivial to make yourself with the first part but since it's common use case, it should just be there IMHO).
    - given any position vector from user side, give tool to find the closest distance along the spline for this. This may sound bit specific but it's something people tend to want from spline tooling.

    I do agree with others here that there shouldn't be any ready made artist tooling, just foundation for things you can build your own things on top.
     
  36. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    I'm a bit sceptical about stock unity transform tools, because they imply that the splines has scale and rotation, which they don't have by default if we're talking about just bog standard bezier curves.

    I'm all in favour of being able to add extra data to the spline points - like a rotation and a scale - but you wouldn't want that on all splines. That's essentially tripling the amount of data in a spline that might not need it.

    Rotation is also clunky because there's ambiguity about what that means. Do you just have rotation data at the node points and then slerp the rotation between them, or do you also have rotation data at the control (tangent) points so you get a proper interpolation? If you have rotation on the tangent points, how do you draw that?


    I think it's better if they make sure that it's easy to relate arbitrary data to each node/tangent as needed, and make it easy to draw and manipulate that data. Then tools that need it can very easily add rotation and scale if they want.


    The percentage is the trivial part for splines. The actual distance is the bit that's hard, you usually end up having to binary search it. But, yeah, utilities for getting data like "how far is it between these two points along the spline" and "give me a point that's x unity units along the spline" or "give me the point on the spline that's closest to this world point" are all very useful, and it'd be great if we didn't have to implement them ourselves.
     
    NotaNaN likes this.
  37. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    While this is true, the amount of extra data is basically only for your spline points and we are not talking about absurd amount of data still. This could be optional on the spline component itself (have dropdowns etc for spine rotation/roll and scale where you could omit the extras if not wanted).

    How I'd imagine most would want such system to work is to just use the two axis of it to control the tangent directions so the spline would just turn sideways and up/down directions and then the remaining roll axis would be used to adjust the tilt of whatever you want to use it for (and then use one scale axis to control the tangent size) but this isn't really that important in the bigger picture.

    What I do see important here is that you can use some built-in transform manipulation tools to set and get the full transform data for each spline point without having to build dedicated editor tooling for that yourself. What you do with that data then could still be left to user to implement.

    If it's left to user to build editor tooling to be even able adjust such spline point data in editor (meaning you'd have to code gizmos and controls yourself for roll and scale) it gets quickly to a point where you start to wonder why you needed Unity's own splines in the first place.. At very least there should then be some template for it to make it worthwhile.
     
  38. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    Wait, are you just talking about using the rotation/scale tools to move the tangent point? Or is there some data we're rotating?

    I'm not quite clear about if we're creating f-zero x or if we're rotating a road turn to instead become a hill, but still a flat road.
     
  39. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I'm only talking about being able to store transform data for each spline point and being able to manipulate it with unity provided editor tooling. Basically being able to have my own scripts ref spline component which holds this data without me having to write a single special editor tool for the spline manipulation itself. This would mean I'd get roll along the spline and at least one scale value along the spline. Being able to tweak the tangent scale was separate point (probably should have left it out of the comment but it would be convenient if we could tweak it on the editor too using built-in tooling).
     
  40. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Ok, have confirmed with team this info:

    The indeed have 2 Actions(events) they can register to:
    Spline.changed, that is triggered every time the spline is modified (multiple time per frame) and available at runtime
    EditorSplineUtility.afterSplineWasModified that is available in the editor and send an event when a spline is modified (with a reference to the modified spline as well)
    We were also considering to add extra events such as OnKnotAdded, OnKnotModified, OnKnotRemoved


    Regarding what we're building, we are not actually building a road generator, prefab instantiator, etc ... just the base spline, for everyone else to add functionality (via Components) as they need. Does that seem incorrect?
     
    mariandev, mahdi_jeddi and Rowlan like this.
  41. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Yes, tangent controls are all available, that's clearly important :)

    The standard tools will work on the Spline elements (knots, tangent handles), yes. However, there is no scale data (scale tool simply stretches the tangents), and instead of full rotation data, we use an "up" that is created on placement, combined with tangents, to give a predictable and useful orientation of each knot - mostly for tooling (similar to using "local" handle orientation on a gameobject).

    As @Baste brought up, it's really important to us that the spline remains super lightweight.

    For scale, width, etc, that will be a value you can add and adjust via your component, eg in your "Generate Road", you would have "Road Width" points that you could place along the path, and manipulate seamlessly, like changing the radius of a Light.

    At least, this is how it's currently planned, we're making sure it all really works as needed :)
     
    NotaNaN, mariandev, JoNax97 and 2 others like this.
  42. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    I don't think you should build the road generator as a thing you ship to us. I think you should build the road generator or something like it internally to discover the kinds of bugs and annoyances that only show up when you try to build something real. Maybe have it as a package sample?

    Unity tools that are just built from theorycrafting how they'll be useful without anything bigger than tiny demos and tests built with them have a tendency to ship with some bad designs that end up being hard to change due to backwards compatibility concerns.
     
  43. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    My main fear here is that same mistakes get repeated as what happened initially with Unreal's spline component: they just rolled out super bare bones spline component and people had to hack in the type of functionality mentioned earlier with really ugly workarounds. Epic eventually did add scale and roll controls on UE 4.13 or so which made things easier for all there. That being said, doing custom editor tooling is a lot simpler on Unity so it's not fair comparison.

    I'm just not that excited having to go for custom editor stuff for things that shouldn't need it in principle. It just beats the purpose of using ready made things at that point IMHO. That being said I guess it's still giving some value if you provide some templates/samples that implement few commonly used scenarios because then people could just adapt from there without having to reinvent the wheel for common use cases.
     
    gabrielw_unity likes this.
  44. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    611
    Maybe Unity could provide an out-of-the-box component for this, that's easily available but still separated from the core?
     
  45. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Ah! So, yes we're building examples and demos internally very much of course. Agreed on the danger of "theorycrafting" only (that's a good word ... )

    Regarding usable components shipped with, that'd be up to the individual teams (eg Terrain, Animation, etc), but we're working closely with them ... and of course ProBuilder is in our court, for mesh generation :)
     
  46. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Of course nothing is set in stone and such, but since Terrain Tools 4 are approaching, might there be a spline example with terrain manipulation? Like carving a river or a road into a terrain? Something like I toyed around with here, but waited for the splines to arrive before I continue. I rather have that stuff come from Unity, it definitely would benefit everyone :)
     
  47. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    It is imperative that the callback tells you which section of the spline was modified (IE points between Knots A and B were just dirtied by the User, but not C and E, etc.). It is not enough to know that the spline was dirtied somewhere along its entire length.
     
  48. TheSniperFan

    TheSniperFan

    Joined:
    Jul 18, 2013
    Posts:
    712
    Is there any info on which type of spline were getting? Are we talking Bézier or (hopefully) B-Splines? Or is it something else entirely?
     
  49. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    970
    Things that have been important to me in a past project that heavily used spline paths for movement, although I have to go from memory from nearly 5 years ago:
    • Being able to get the closest point along the spline from a point, along the normal or along an axis.
    • Being able to traverse the spline by a set distance (as opposed to just a normalised factor). We had to bake down the splines to equidistant points and interpolate along that last time.
     
    Last edited: May 7, 2021
    NotaNaN and gabrielw_unity like this.
  50. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    I've been chatting with the Terrain folks about exactly this, yup! They are super busy with the Terrain Tools package for now, but are excited to try this out ASAP :)

    Bezier handles the most cases, so that'll be the default to start, but we have been working with other options as well.

    Yup, this should be doable with the helper utilities in the API :)