Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blueprint and Bind on runtime
#1
Hi! I am generating the blueprints at runtime and binding the skinnedmesh. Everything works great but I have quite a delay, between 2 and 3 minutes for all the work, so I have two doubts:

1. It is possible to copy each of the variables (Positions, rest, orientations, etc) from the Blueprint to a file and load them again individually in each field. If so, I should call some function once this process is done (This would save me 40s in models already made)

2. The binding process seems to take the longest, is there any way to speed it up? For already created models or for new ones, either option would work well.

Thanks in advance!

PS: The meshes currently go around 20,000 vertices and 500/900 particles depending on the preset.
PS2: I am generating the blueprint with the couritine to avoid any crash or error that the immediate method can give me
Reply
#2
(03-03-2023, 11:52 AM)SimonP Wrote: 1. It is possible to copy each of the variables (Positions, rest, orientations, etc) from the Blueprint to a file and load them again individually in each field. If so, I should call some function once this process is done (This would save me 40s in models already made)

Hi Simon,

Blueprints are ScriptableObjects and can be saved in the project as an asset using AssetDatabase.SaveAsset. Once saved you can reuse them as much as you want. If you're doing this outside the Unity editor, then you need to serialize the data contained in the blueprint in a custom format of your choice, this is entirely up to you (just like you'd do for save game data for a game, for instance).

(03-03-2023, 11:52 AM)SimonP Wrote: 2. The binding process seems to take the longest, is there any way to speed it up? For already created models or for new ones, either option would work well.

As it is, not really. Binding a mesh to a set of particles requires generating vertex skinning data for all vertices in the mesh, so you have to iterate trough all vertices no matter how you do it. If really in need of a faster binding algorithm, you could write a multithreaded version or even move it to compute shaders, but that's outside the scope of Obi.

(03-03-2023, 11:52 AM)SimonP Wrote: PS: The meshes currently go around 20,000 vertices and 500/900 particles depending on the preset.

Unless you have lots of meshes, a blueprint with 500-900 particles should not take too long to generate.

(03-03-2023, 11:52 AM)SimonP Wrote: PS2: I am generating the blueprint with the couritine to avoid any crash or error that the immediate method can give me

Not sure how calling a coroutine may avoid crashes/errors? In fact both methods call the exact same code, all the immediate method does is advance the coroutine one in a while loop like this:
Code:
while (coroutine.MoveNext());
Reply
#3
Quote:Blueprints are ScriptableObjects and can be saved in the project as an asset using AssetDatabase.SaveAsset. Once saved you can reuse them as much as you want. If you're doing this outside the Unity editor, then you need to serialize the data contained in the blueprint in a custom format of your choice, this is entirely up to you (just like you'd do for save game data for a game, for instance).

Yes, the idea is to serialize the data for a save/load system so that's great, I'll start doing it right away.

Quote:As it is, not really. Binding a mesh to a set of particles requires generating vertex skinning data for all vertices in the mesh, so you have to iterate trough all vertices no matter how you do it. If really in need of a faster binding algorithm, you could write a multithreaded version or even move it to compute shaders, but that's outside the scope of Obi.

All my attempts to create a compute shader that does whatever fails miserably. So I'll try to make a version for multithread, but with being able to save the blueprints I'm happy.

Quote:Unless you have lots of meshes, a blueprint with 500-900 particles should not take too long to generate.
If about 40 seconds in the best case (It was a little more until I modified the timestep) But that's the best I could do already compiled

Quote:Not sure how calling a coroutine may avoid crashes/errors? In fact both methods call the exact same code, all the immediate method does is advance the coroutine one in a while loop like this:

With the immediate method it gives me a massive drop in fps and sometimes (few) the game just crashes. Maybe it's the testing machine, when I finish other things I'll try in the main one or maybe my old code was garbage lol

Thanks for all the responses Sonrisa
Reply