Posts: 27
Threads: 6
Joined: Jul 2022
Reputation:
0
14-07-2023, 06:21 AM
(This post was last modified: 14-07-2023, 06:22 AM by danazoid.)
Hi, I am trying to use a tool to push on cloth in VR.
I have 2 issues.
1. Cloth push-back on tool
Is there a way to increase the force exerted by the cloth on the tool?
As I understand it, PBD starts from position, then calculates velocity, which is then used to calculate impulse.
So I increased the mass of both particle and tool and it helps quite a bit. Are there other ways?
(I am holding the tool with a configurable joint spring. When the hand moves through an impassable VR object, the tool is separated from the hand, and visuals signal the user that this is unrealistic)
2. Object passes through cloth
The cloth resists bulky shapes like sphere colliders nicely.
a) but I have issues with long and thin objects like a cylinder (capsule collider). The ends of the cylinder tend to be resisted fairly, but the sides of the cylinder slip through, even though barely any force is applied.
I suspected maybe there weren't enough particles, but increasing particle density (via mesh) and particle radius (via cloth blueprint) does not help.
b) I enabled surface collisions which works with bulky colliders but not the cylinder sides.
I observe that the object passes through the cloth upon a certain force (and not particle separation). Is this observation correct?
=====
Side question: what does the setting "one-sided collisions" on the obi cloth component mean? I could not find it in the manual or the forum.
Thanks
Posts: 6,346
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
14-07-2023, 06:37 AM
(This post was last modified: 14-07-2023, 06:40 AM by josemendez.)
(14-07-2023, 06:21 AM)danazoid Wrote: Hi, I am trying to use a tool to push on cloth in VR.
I have 2 issues.
1. Cloth push-back on tool
Is there a way to increase the force exerted by the cloth on the tool?
As I understand it, PBD starts from position, then calculates velocity, which is then used to calculate impulse.
So I increased the mass of both particle and tool and it helps quite a bit. Are there other ways?
The only way to increase acceleration (that is, the effect a given force has on an object) is decreasing mass. Decreasing the mass of the tool compared to the mass of the cloth will make the cloth move the tool around more easily. Doing the opposite (decreasing cloth mass and increasing tool mass) will make it easier for the tool to move the cloth.
(14-07-2023, 06:21 AM)danazoid Wrote: 2. Object passes through cloth
The cloth resists bulky shapes like sphere colliders nicely.
a) but I have issues with long and thin objects like a cylinder (capsule collider). The ends of the cylinder tend to be resisted fairly, but the sides of the cylinder slip through, even though barely any force is applied.
I suspected maybe there weren't enough particles, but increasing particle density (via mesh) and particle radius (via cloth blueprint) does not help.
b) I enabled surface collisions which works with bulky colliders but not the cylinder sides.
I observe that the object passes through the cloth upon a certain force (and not particle separation). Is this observation correct?
Is this object a rigidbody? If so, it shouldn't pass trough the cloth as long as their mass ratio is sane (typical rule of thumb in most engines is 1:10, that is, don't have objects that are more than 10 times heavier or lighter than the other interact with each other).
This is a limitation of all physics engines, large mass ratios (and hence, large forces) require finer temporal resolution (that is, a smaller fixed timestep) to be solved accurately.
(14-07-2023, 06:21 AM)danazoid Wrote: Side question: what does the setting "one-sided collisions" on the obi cloth component mean? I could not find it in the manual or the forum.
Makes cloth collide against other cloth objects only against the front-facing side of the geometry (that is, the side that vertex normals point towards). This is useful to avoid tangling when using multiple layers of cloth.
Posts: 27
Threads: 6
Joined: Jul 2022
Reputation:
0
Thanks for the quick reply.
Quote:The only way to increase acceleration (that is, the effect a given force has on an object) is decreasing mass. Decreasing the mass of the tool compared to the mass of the cloth will make the cloth move the tool around more easily. Doing the opposite (decreasing cloth mass and increasing tool mass) will make it easier for the tool to move the cloth.
May I ask how the force from the cloth is actually calculated?
Because I get this unexpected result: when my tool mass is small, it is easily pulled through the cloth. When the tool mass is large, the cloth can resist the tool better. I can record a video to show you.
Quote:Is this object a rigidbody? If so, it shouldn't pass trough the cloth as long as their mass ratio is sane (typical rule of thumb in most engines is 1:10, that is, don't have objects that are more than 10 times heavier or lighter than the other interact with each other).
Yes it is a rigidbody.
To clarify, by cloth mass do you mean:
1) entire cloth mass
2) total mass of particles of cloth that contact object
3) mass of each particle that contacts object
=====
Additional question: sometimes, the cloth particles move but the cloth rendered mesh doesn't. What might be the cause?
Posts: 6,346
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
14-07-2023, 07:54 AM
(This post was last modified: 14-07-2023, 08:00 AM by josemendez.)
(14-07-2023, 07:40 AM)danazoid Wrote: Thanks for the quick reply.
May I ask how the force from the cloth is actually calculated?
You can see for yourself in BurstColliderCollisionConstraintsBatch.cs. There, a position delta is calculated for both the particle and the rigidbody involved in each contact (roughly, lines 277-282). It is then converted to an impulse and applied to the rigidbody using BurstMath.ApplyImpulse().
The basic formula is your typical PBD constraint:
Code: lambda = constraint * (massA + massB);
deltaA = lambda * gradient / massA;
deltaB = lambda * gradient / massB;
(14-07-2023, 07:40 AM)danazoid Wrote: Because I get this unexpected result: when my tool mass is small, it is easily pulled through the cloth. When the tool mass is large, the cloth can resist the tool better. I can record a video to show you.
That doesn't make sense, should be the exact opposite. Could you share a video of this, or describe a way to set things up in a way that reproduces this?
(14-07-2023, 07:40 AM)danazoid Wrote: Yes it is a rigidbody.
To clarify, by cloth mass do you mean:
1) entire cloth mass
2) total mass of particles of cloth that contact object
3) mass of each particle that contacts object
Each particle collides against the cloth individually (think of each particle as an individual "rigidbody") so I mean single cloth particle mass vs contact object mass.
(14-07-2023, 07:40 AM)danazoid Wrote: Additional question: sometimes, the cloth particles move but the cloth rendered mesh doesn't. What might be the cause?
That should not be the case, mesh vertex positions are directly copied from particle positions. Can you share a video of this?
Posts: 27
Threads: 6
Joined: Jul 2022
Reputation:
0
14-07-2023, 04:33 PM
(This post was last modified: 15-07-2023, 05:43 AM by danazoid.)
Hi Jose, here is a video recording
https://www.youtube.com/watch?v=UeyJtU7u_e0
I have taken the liberty to send to the support email a unity package with the scene and scripts.
Observations
1. Resistance to pass through
- volume: large better than small
- object mass: heavy better than light
- particle mass: heavy better than light
- mass ratio does not seem to be important
2. Forceps passes through freely
3. Mesh does not always animate with particles
=====
I suspect the cause of heavy object mass resisting better, could be my VR setup.
My VR hand setup is like this.
Hand Controller --> Hand Grabber --> Object
Hand Controller
- Controller mesh visual
- XR Action-based controller
- Rigidbody kinematic
- Config joint to "Hand Grabber"
Hand Grabber
- Sphere mesh visual
- Rigidbody non-kinematic
- On grab, config joint attaches to tool
- joint translates tool with linear drive (but changed to limited linear motion to obtain joint forces in the video)
- joint rotates object with Slerp drive
=====
Really, what I need is 2 things:
1. forcep is resisted by the skin cloth (resists pass-through)
2. when forcep is resisted, it is visibly pushed away from the VR hand (ie the force acting on the forcep is large enough).
Hopefully the forceps can behave more like the blue sphere or large blue cylinder.
It is ok if the forcep eventually passes through if the user keeps pushing.
Posts: 27
Threads: 6
Joined: Jul 2022
Reputation:
0
(14-07-2023, 07:54 AM)josemendez Wrote: The basic formula is your typical PBD constraint:
Code: lambda = constraint * (massA + massB);
deltaA = lambda * gradient / massA;
deltaB = lambda * gradient / massB;
Did you mean lambda = constraint * ( invMassA + invMassB)?
which is consistent with PBD paper/slides and Obi code:
BurstContact.SolveAdhesion {
...
float dlambda = -constraint / TotalNormalInvMass;
...
}
=====
Then velocity of the rigidbody is calculated here?
BurstMath.ApplyImpulse {
...
linearDeltas[rigidbodyIndex] += rigidbodies[rigidbodyIndex].inverseMass * impulseWS;
...
}
=====
Then somehow Unity calculates something that interacts with the joint force.
Posts: 6,346
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
17-07-2023, 09:38 AM
(This post was last modified: 17-07-2023, 10:59 AM by josemendez.)
(17-07-2023, 08:44 AM)danazoid Wrote: Did you mean lambda = constraint * ( invMassA + invMassB)?
which is consistent with PBD paper/slides and Obi code:
BurstContact.SolveAdhesion {
...
float dlambda = -constraint / TotalNormalInvMass;
...
}
Nope. Both the PBD paper and Obi's code divide by the total inverse mass. A / (1 / B) = A * B.
Still, constraint * (massA + massB) is not correct since 1/A + 1/B != 1/(A+B), should have said constraint / (1/massA + 1/mass B). My bad!
(17-07-2023, 08:44 AM)danazoid Wrote: =====
Then velocity of the rigidbody is calculated here?
BurstMath.ApplyImpulse {
...
linearDeltas[rigidbodyIndex] += rigidbodies[rigidbodyIndex].inverseMass * impulseWS;
...
}
That's a linear velocity delta, not the final velocity. linearDelta is then added to the rigidbody's linear velocity at the start of the frame. Same with the angular velocity.
(17-07-2023, 08:44 AM)danazoid Wrote: Then somehow Unity calculates something that interacts with the joint force.
Unity solves for impulses, same thing Obi does. You accumulate multiple impulses on a rigidbody (some come from Obi, some come from Unity joints), and end up with the final velocity.
Posts: 27
Threads: 6
Joined: Jul 2022
Reputation:
0
17-07-2023, 11:04 AM
(This post was last modified: 17-07-2023, 11:16 AM by danazoid.)
(17-07-2023, 09:38 AM)josemende Wrote: Nope. Both the PBD paper and Obi's code divide by the total inverse mass. A / (1 / B) = A * B.
Still, constraint * (massA + massB) is not correct since 1/A + 1/B != 1/(A+B), should have said constraint / (1/massA + 1/mass B). My bad! Oh I made a typo by putting the * instead of /.
Thanks for the confirmation!
Quote:Unity solves for impulses, same thing Obi does. You accumulate multiple impulses on a rigidbody (some come from Obi, some come from Unity joints), and end up with the final velocity.
Ok I think I can explain what I observe wrt mass.
The user experiences the displacement of the tool from the VR hand.
The displacement is proportional to the force/impulse on the tool from the cloth.
Based on the PBD equations, increasing either massA or massB (either cloth OR tool), increases the impulse on the tool, so gives a larger displacement.
Does that sound right?
========
The other issue is the tool collider shape.
Changing the mass of the cloth / tool doesn't help all that much.
The forceps and the long thin cylinder tend to pass through the cloth without much force.
Any suggestions on preventing this? The forceps can't really change its dimensions.
Posts: 6,346
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
17-07-2023, 11:35 AM
(This post was last modified: 17-07-2023, 11:49 AM by josemendez.)
(17-07-2023, 11:04 AM)danazoid Wrote: Ok I think I can explain what I observe wrt mass.
The user experiences the displacement of the tool from the VR hand.
The displacement is proportional to the force/impulse on the tool from the cloth.
Based on the PBD equations, increasing either massA or massB (either cloth OR tool), increases the impulse on the tool, so gives a larger displacement.
Does that sound right?
No, that's not at all how it any of it works. Otherwise by simply increasing the mass of objects you could impart arbitrarily large accelerations on them which is against momentum conservation. Two 10000 kilograms objects colliding with each other must react exactly as two 1 kg colliding objects would.
Substitute lambda in the position delta (displacement) calculations, you get this:
Code: deltaA = gradient * constraint * invMassA / (invMassA + invMassB);
deltaB = gradient * constraint * invMassB / (invMassA + invMassB);
Let's say the mass of the cloth is 5 and the mass of the tool is also 5, so their inverse mass is 0.2. Ignoring the "gradient * constraint" term because it is the same for both objects, you get 0.2/(0.2+0.2) = 0.5 for both deltas, which means both the cloth and the tool are displaced by 50%. Since their mass is the same, displacement is the same for both. You would get the same result regardless of their mass, as long as both objects have the same mass.
If you increase the mass of the cloth to 10, you get 0.1/(0.1+0.2) = 33% displacement for the cloth and 0.2/(0.1+0.2) = 66% displacement for the tool. The tool is displaced more than the cloth, which makes sense since the cloth is heavier.
Conversely, if you increase the mass of the tool to 10, you get 0.2/(0.1+0.2) = 66% displacement for the cloth and 0.1/(0.1+0.2) = 33% displacement for the tool. Now the cloth is displaced more than the tool.
As you can see increasing the mass of the tool only increases the displacement on the cloth, and vice versa. The absolute mass values you use don't matter, only the mass ratio does.
(17-07-2023, 11:04 AM)danazoid Wrote: The other issue is the tool collider shape.
Changing the mass of the cloth / tool doesn't help all that much.
The forceps and the long thin cylinder tend to pass through the cloth without much force.
Any suggestions on preventing this? The forceps can't really change its dimensions.
Not really, the best you can get out of a particle-based engine is surface collisions which attempt to fake collisions against a continuous surface. However this doesn't guarantee zero penetration at all.
What's puzzling here is the behavior you're getting with respect to the relative mass of the tool and the cloth, as it doesn't behave like it should. I'll take a look at the project you sent asap, it will take a couple days though as I'm moving and don't have access to my development computer.
Posts: 27
Threads: 6
Joined: Jul 2022
Reputation:
0
17-07-2023, 03:13 PM
(This post was last modified: 17-07-2023, 03:52 PM by danazoid.)
(17-07-2023, 11:35 AM)josemendez Wrote: Substitute lambda in the position delta (displacement) calculations, you get this:
Not really, the best you can get out of a particle-based engine is surface collisions which attempt to fake collisions against a continuous surface. However this doesn't guarantee zero penetration at all.
What's puzzling here is the behavior you're getting with respect to the relative mass of the tool and the cloth, as it doesn't behave like it should.
Yes I understand what you are saying about the cloth/tool displacement from their interaction with each other.
The displacement I was referring to, is the displacement of the tool from the VR hand. The VR hand connects to the tool by a config joint, which is a spring force, ie F = kd, so a larger displacement of the tool from the hand ("pushback") can be seen if the impulse on the tool from the cloth is bigger.
That said, it's still a mystery why it is easier for the lighter sphere to pass through vs a heavy one.
The particles don't look like they are being separated when this occurs.
Quote:I'll take a look at the project you sent asap, it will take a couple days though as I'm moving and don't have access to my development computer.
No hurry, I can work on other things! Thanks for your consideration
|