Posts: 45
Threads: 20
Joined: Mar 2024
Reputation:
2
06-04-2024, 12:10 PM
(This post was last modified: 06-04-2024, 12:38 PM by kodra.)
I'd like to disable ObiSoftbodySkinner at runtime and make the mesh deformation controlled by SkinnedMeshRenderer again, and reenable it at some condition.
The first time disabling it works. However, if I enable ObiSoftbodySkinner again after disabling it, I get this error:
Code: InvalidOperationException: The previously scheduled job BurstShapeMatchingConstraintsBatch:ShapeMatchingConstraintsBatchJob writes to the UNKNOWN_OBJECT_TYPE ShapeMatchingConstraintsBatchJob.restComs. You are trying to schedule a new job BurstShapeMatchingConstraintsBatch:ShapeMatchingCalculateRestJob, which writes to the same UNKNOWN_OBJECT_TYPE (via ShapeMatchingCalculateRestJob.restComs). To guarantee safety, you must include BurstShapeMatchingConstraintsBatch:ShapeMatchingConstraintsBatchJob as a dependency of the newly scheduled job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.ScheduleParallelFor (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters, System.Int32 arrayLength, System.Int32 innerloopBatchCount) (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
Unity.Jobs.IJobParallelForExtensions.Schedule[T] (T jobData, System.Int32 arrayLength, System.Int32 innerloopBatchCount, Unity.Jobs.JobHandle dependsOn) (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
Obi.BurstShapeMatchingConstraintsBatch.CalculateRestShapeMatching () (at Assets/ThirdParty/Obi/Scripts/Common/Backends/Burst/Constraints/ShapeMatching/BurstShapeMatchingConstraintsBatch.cs:147)
Obi.ObiShapeMatchingConstraintsBatch.RecalculateRestShapeMatching () (at Assets/ThirdParty/Obi/Scripts/Common/Blueprints/Constraints/Batches/ObiShapeMatchingConstraintsBatch.cs:232)
Obi.ObiSoftbody.RecalculateRestShapeMatching () (at Assets/ThirdParty/Obi/Scripts/Softbody/Actors/ObiSoftbody.cs:194)
Obi.ObiSoftbody.UpdateParticleProperties () (at Assets/ThirdParty/Obi/Scripts/Softbody/Actors/ObiSoftbody.cs:243)
Obi.ObiSoftbodySkinner.BindBoneParticles () (at Assets/ThirdParty/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:261)
Obi.ObiSoftbodySkinner.Softbody_OnBlueprintLoaded (Obi.ObiActor a, Obi.ObiActorBlueprint blueprint) (at Assets/ThirdParty/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:199)
Obi.ObiSoftbodySkinner.OnEnable () (at Assets/ThirdParty/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:130)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
I get this with Obi 7. I didn't test if it happens with 6.4.
Changing influence seems to be impossible either at runtime?
My guess (not a very educated one) is that it has something to do with Obi 7's new asynchronized mode. In synchronized mode this error doesn't happen. In asynchronized mode it happens sometimes.
Posts: 6,348
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(06-04-2024, 12:10 PM)kodra Wrote: I'd like to disable ObiSoftbodySkinner at runtime and make the mesh deformation controlled by SkinnedMeshRenderer again, and reenable it at some condition.
The first time disabling it works. However, if I enable ObiSoftbodySkinner again after disabling it, I get this error:
Code: InvalidOperationException: The previously scheduled job BurstShapeMatchingConstraintsBatch:ShapeMatchingConstraintsBatchJob writes to the UNKNOWN_OBJECT_TYPE ShapeMatchingConstraintsBatchJob.restComs. You are trying to schedule a new job BurstShapeMatchingConstraintsBatch:ShapeMatchingCalculateRestJob, which writes to the same UNKNOWN_OBJECT_TYPE (via ShapeMatchingCalculateRestJob.restComs). To guarantee safety, you must include BurstShapeMatchingConstraintsBatch:ShapeMatchingConstraintsBatchJob as a dependency of the newly scheduled job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.ScheduleParallelFor (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters, System.Int32 arrayLength, System.Int32 innerloopBatchCount) (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
Unity.Jobs.IJobParallelForExtensions.Schedule[T] (T jobData, System.Int32 arrayLength, System.Int32 innerloopBatchCount, Unity.Jobs.JobHandle dependsOn) (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
Obi.BurstShapeMatchingConstraintsBatch.CalculateRestShapeMatching () (at Assets/ThirdParty/Obi/Scripts/Common/Backends/Burst/Constraints/ShapeMatching/BurstShapeMatchingConstraintsBatch.cs:147)
Obi.ObiShapeMatchingConstraintsBatch.RecalculateRestShapeMatching () (at Assets/ThirdParty/Obi/Scripts/Common/Blueprints/Constraints/Batches/ObiShapeMatchingConstraintsBatch.cs:232)
Obi.ObiSoftbody.RecalculateRestShapeMatching () (at Assets/ThirdParty/Obi/Scripts/Softbody/Actors/ObiSoftbody.cs:194)
Obi.ObiSoftbody.UpdateParticleProperties () (at Assets/ThirdParty/Obi/Scripts/Softbody/Actors/ObiSoftbody.cs:243)
Obi.ObiSoftbodySkinner.BindBoneParticles () (at Assets/ThirdParty/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:261)
Obi.ObiSoftbodySkinner.Softbody_OnBlueprintLoaded (Obi.ObiActor a, Obi.ObiActorBlueprint blueprint) (at Assets/ThirdParty/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:199)
Obi.ObiSoftbodySkinner.OnEnable () (at Assets/ThirdParty/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:130)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
I get this with Obi 7. I didn't test if it happens with 6.4.
Changing influence seems to be impossible either at runtime?
My guess (not a very educated one) is that it has something to do with Obi 7's new asynchronized mode. In synchronized mode this error doesn't happen. In asynchronized mode it happens sometimes.
Thanks for the report! I’ll take a look at this and get back to you.
Posts: 45
Threads: 20
Joined: Mar 2024
Reputation:
2
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.
Posts: 6,348
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(06-04-2024, 12:10 PM)kodra Wrote: I'd like to disable ObiSoftbodySkinner at runtime and make the mesh deformation controlled by SkinnedMeshRenderer again, and reenable it at some condition.
The first time disabling it works. However, if I enable ObiSoftbodySkinner again after disabling it, I get this error:
Code: InvalidOperationException: The previously scheduled job BurstShapeMatchingConstraintsBatch:ShapeMatchingConstraintsBatchJob writes to the UNKNOWN_OBJECT_TYPE ShapeMatchingConstraintsBatchJob.restComs. You are trying to schedule a new job BurstShapeMatchingConstraintsBatch:ShapeMatchingCalculateRestJob, which writes to the same UNKNOWN_OBJECT_TYPE (via ShapeMatchingCalculateRestJob.restComs). To guarantee safety, you must include BurstShapeMatchingConstraintsBatch:ShapeMatchingConstraintsBatchJob as a dependency of the newly scheduled job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.ScheduleParallelFor (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters, System.Int32 arrayLength, System.Int32 innerloopBatchCount) (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
Unity.Jobs.IJobParallelForExtensions.Schedule[T] (T jobData, System.Int32 arrayLength, System.Int32 innerloopBatchCount, Unity.Jobs.JobHandle dependsOn) (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
Obi.BurstShapeMatchingConstraintsBatch.CalculateRestShapeMatching () (at Assets/ThirdParty/Obi/Scripts/Common/Backends/Burst/Constraints/ShapeMatching/BurstShapeMatchingConstraintsBatch.cs:147)
Obi.ObiShapeMatchingConstraintsBatch.RecalculateRestShapeMatching () (at Assets/ThirdParty/Obi/Scripts/Common/Blueprints/Constraints/Batches/ObiShapeMatchingConstraintsBatch.cs:232)
Obi.ObiSoftbody.RecalculateRestShapeMatching () (at Assets/ThirdParty/Obi/Scripts/Softbody/Actors/ObiSoftbody.cs:194)
Obi.ObiSoftbody.UpdateParticleProperties () (at Assets/ThirdParty/Obi/Scripts/Softbody/Actors/ObiSoftbody.cs:243)
Obi.ObiSoftbodySkinner.BindBoneParticles () (at Assets/ThirdParty/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:261)
Obi.ObiSoftbodySkinner.Softbody_OnBlueprintLoaded (Obi.ObiActor a, Obi.ObiActorBlueprint blueprint) (at Assets/ThirdParty/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:199)
Obi.ObiSoftbodySkinner.OnEnable () (at Assets/ThirdParty/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:130)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
I get this with Obi 7. I didn't test if it happens with 6.4.
I've been unable to reproduce this so far. Will try some more cases and get back to you.
Posts: 6,348
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
08-04-2024, 01:38 PM
(This post was last modified: 08-04-2024, 05:02 PM by josemendez.)
(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.
Posts: 45
Threads: 20
Joined: Mar 2024
Reputation:
2
(08-04-2024, 01:38 PM)josemendez Wrote: 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.
Oh I see... that makes sense. Thank you for the answer.
I still think it might be worth it to provide this as an option for the user to use at their own risk though.
|