Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disable/Enable ObiSoftbodySkinner at runtime?
#5
(06-04-2024, 07:55 PM)kodra Wrote: Besides this exception, I think it would be nice to be able to adjust the Softbody Influence property at runtime, so one can enable/disable the skinner smoothly (by increasing/decreasing the influence over time) rather than abruptly.

It is not possible to do this, since changing the softbody influence requires to recalculate and sort all per-vertex influences and then drop those above the desired amount of total influences per vertex. While I simplified this as lerp(skinning, simulation, influence) in another post, it doesn't actually work that way: full bone skinning and softbody skinning calculated, then their results interpolated per vertex. The reason for this is performance.

Say for instance there's a vertex that originally had 4 bone influences, with the maximum amount of influences being 4. Upon binding the softbody, there's 3 particles within the influence radius. So with a softbody influence of 1 (100%), the 4 bone influences would be dropped and only the 3 particles would have any effect, their weights calculated using the distance to the vertex and then normalized (so that all weights add up to 1). You end up with 3 influences instead of 7 (4 bones  + 3 particles).

With a softbody influence of 0.5, all 4 bones and 3 particles influence the vertex, so they're sorted by weight and only the 4 having the most influence are kept, then normalized. You end up with only 4 influences, instead of 7.

With a softbody influence of 0 no particles have any influence and only bone influences are calculated, just like in a regular SkinnedMeshRenderer. Again you end up with 4 influences instead of 7.

This way the cost of the whole thing is not cost of bone skinning + cost of particle skinning: you only pay for the amount of influences actually used, for a typical speedup of x2. The downside of this is that you can't lerp between them in realtime, since the lerping parameter is "baked" into the weights.
Reply


Messages In This Thread
RE: Disable/Enable ObiSoftbodySkinner at runtime? - by josemendez - 08-04-2024, 01:38 PM