Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Frequent runtime updates of Curvy Generator for simulating plant growth using Splines
#1
Hi! I've been using Curvy for a couple of months now and I like it a lot. I've learned a lot of its idiosyncrasies and read all of the Documentation and guides. What I'm trying to do is make a system for growing large trees (~100m tall) from tiny seedlings, all using splines. I'm using the Curvy Generator to do this, but I've quickly run into performance problems as I add branches to the tree. Each branch is a separate Curvy Generator, and each generator takes ~2ms to update each frame. Ideally I want 10-100 branches growing and updating at a time, so I need to get the Curvy Generator update speed down around 0.1ms for each branch. 

There are two kinds of updates happening:
-Branch extension, where I add new control points to the Input Spline Path while changing the local transform of the terminal control point to simulate branch growth
-Branch widening, where I increase the radius of a CSCircle at the base which dirties the Input Spline Shape and updates a Variable Mix Shapes Modifier to simulate branch thickening

These two types of spline updates, mainly via rasterization, account for ~60% of the update time and I would like for them to occur every frame. The rest of the update time is related to Create Mesh and I view that as unavoidable. A lot of the Editor functionality (Dirtying, checking Configured) seems to be slowing things down as well.

I have tried having two generators where only the tip of the branch is updated, but there aren't that many savings, especially because of branch widening and the cost of Variable Mix Shapes, which is quite high actually. I've employed all the other suggested optimizations, like reducing the rasterization resolution, disabling transform checking, spline orientations etc. What would need to be done to get a big network of splines growing fast?

So far my ideas are to speed up the rasterization procedure somehow, and to reduce the amount of cached information that is recomputed (Fpath, etc) each time a spline is updated since I am dealing with very frequent runtime updates to simulate growth. Specifically I've implicated InputSpline.GetSplineData as the main target of any optimization efforts

I kept getting Base Request 400 uploading my project on the forum here.
I included a sample project with my Generator graph and the code for building a tree at this link: <censored>
Maybe simple changes to the Generator can help?
Reply
#2
Hi

Thanks for putting so much time in Curvy Splines.

The obvious optimizations seem to be already applied in the project you send me*. I will take a deeper look and try to find what can be optimized. I will start with easy ones, but don't expect any miracle from those (at best a 2x speed increase). Since you aim for a 50x speed increase, reaching such performance will take some structural changes, and that will take me a lot of time to realize.

I will keep you updated.
I am assuming your Curvy Spline copy does not have any modified code. Let me know if this is the case.

Have a nice day

* I censored the link by the way, this is a public forum, and you might want your code to not be publicly available.

PS: feel free to share with me what can be improved to reduce the asset's idiosyncrasies
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
Also, I am assuming the 2ms per generator per frame figure is measured in editor, right? How are the performance in a build? A lot of perfs are used by the editor code of Curvy Splines, code that don't run in a build.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#4
(10-01-2020, 06:56 PM)_Aka_ Wrote: Also, I am assuming the 2ms per generator per frame figure is measured in editor, right? How are the performance in a build? A lot of perfs are used by the editor code of Curvy Splines, code that don't run in a build.

Hi thanks for the quick reply. Yes I've done all my profiling in the Editor during Playmode, have not tested during a build. As far as changes to Curvy, all I've done is optimize updating the CSCircle a bit, as many spline properties are really not necessary for performing shape extrusion.

What I am trying to find out is whether I will need to rewrite many of the modules in Curvy (and potentially implement my own extrusion/mesh creation routine inspired by and borrowing Curvy code without using the Generator), or whether I can apply relatively simple changes for my use-case while still maintaining the Generator and all of the nice editor functionality that comes with it. 

I think a lot of savings can be made with the Variable Mix Shapes Modifier since I can assume my inputs shapes will always be a simple CSCircle, but I am still not sure which Spline properties can be ignored while still ensuring Shape Extrusion works properly. I may also need greater control over mesh creation to meet my runtime rendering goals. I am willing to implement a lot of these changes if you can provide advice about which structural changes are possible, given the assumptions I can make about my use-case here.
Reply
#5
Instead of modifying the spline and using a variable mix, use the same circle with variable scale (Shape Extrusion module, Scale tab, set Mode to Advanced). This way is way faster. If you still need further optims, let me know about it here, while telling me how much perfs you still need.

If and when you feel like it, please leave a review for the asset, that helps a lot.
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#6
(10-01-2020, 08:46 PM)_Aka_ Wrote: Instead of modifying the spline and using a variable mix, use the same circle with variable scale (Shape Extrusion module, Scale tab, set Mode to Advanced). This way is way faster. If you still need further optims, let me know about it here, while telling me how much perfs you still need.

If and when you feel like it, please leave a review for the asset, that helps a lot.
Have a nice day

Yes this gives me huge performance gains and gets me close to my goals. Thank you so much for this simple tip. Any further changes I need will probably be related to mesh creation, and I could make a different post for that since it may be relevant to other cases. I will look into leaving a positive review on the Unity Store very soon. Your responsiveness is really appreciated
Reply
#7
You are welcome
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Batch processing of the Generator to create a bunch of Meshes HatraE 3 48 10-21-2020, 11:21 AM
Last Post: _Aka_
Information Curvy 7.0.0 is live _Aka_ 8 1,109 10-17-2020, 11:17 PM
Last Post: _Aka_
Information Curvy 7.1.2 is live _Aka_ 0 52 10-08-2020, 10:09 AM
Last Post: _Aka_
  Subdivide in runtime? Spectra 3 122 10-07-2020, 08:28 AM
Last Post: p30better

Forum Jump: