Search Unity

[Cloth Physics]How is surface penetration achieved in Unity ?

Discussion in 'Physics' started by YoungXi, Jun 16, 2017.

  1. YoungXi

    YoungXi

    Joined:
    Jun 5, 2013
    Posts:
    63
    Hi guys,
    I wonder if anyone knows how is Surface Penetration achieved in Unity? Or we say in PhyX's cloth.
    I'm trying to do my own cloth simulation and I don't know how to handle cloth-human body collision properly.
    Here is what I have in mind:
    Since the cloth is also skinned, maybe there is a way to blend the skinned vertex position with the physics particle's position.
    I've tried something like this:
    With a skinned vertex, we have its position and its normal, which defines a plane. And the physics particle should not penetrate through that plane.
    It works but not so perfect.
    So I wanted to know how Unity implemented the surface penetration.
    Any answer would be appreciated.
     
  2. YoungXi

    YoungXi

    Joined:
    Jun 5, 2013
    Posts:
    63
    Oh, I have to point out what the problem is with my approach:
    With the plane defined, the particle will not go through that plane, it works if the particle is moving in the right zone. Imagine there is a wind force blowing from left to right, the left particle will stay at that position because of its corresponding plane, and the right most particles are blown away by the wind force, then makes the cloth strechs too much.
     
  3. YoungXi

    YoungXi

    Joined:
    Jun 5, 2013
    Posts:
    63
    ......No one knows?
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I think we need api access to the simulation for a high performance approach. Also it may be going gpu simulated at some point so these approaches are going to be hit and miss.

    I would probably suggest you go with custom cloth?
     
  5. YoungXi

    YoungXi

    Joined:
    Jun 5, 2013
    Posts:
    63
    That's indeed what I'm doing. I'm now doing my custom cloth using standard PBD. But when it comes to collision solving, I'm not sure how to handle the collision between cloth and a animated character, note that the cloth is also skinned.

    So that's why I'm curious about the surface penetration, it seems to be collision free and fast.
     
  6. YoungXi

    YoungXi

    Joined:
    Jun 5, 2013
    Posts:
    63

    Actually I've found an article, seems to be related "Adding Physics to Animated Characters with Oriented Particles" by Matthias Muller and Nuttapong Chenanez. It talked about the same blending process I was trying to do:

    upload_2017-6-19_19-59-53.png
    Only I can't figure out how vp and vb are blended into the final results.

    And plus, the Unity's surface penetration is converted into something called sphere collision distance... which makes me really confused... Cause actually I don't need any colliders for that to work...
     
  7. YoungXi

    YoungXi

    Joined:
    Jun 5, 2013
    Posts:
    63
    For anyone interested: The article can be found at here:
    http://matthias-mueller-fischer.ch/publications/animParticlesSlides.pdf

    The author mentioned:
    "
    To combine simulation and animation, we need a way to an-
    imate the particles and make them follow the motion of the
    skeleton. There is a simple way to do this. With the two sets
    of skinning references, we can derive references for skin-
    ning the particles to the bones of the skeleton. The links and
    weights from the particles to the bones are given by
    upload_2017-6-19_20-6-3.png
    where the superscript pb indicates particle-bone skinning. In
    words, particle i gets attached to all bones that vertex j is
    attached to, if vertex j is attached to particle i. Since several
    vertices attached to a given particle can be attached to the
    same bone, the list defined in Equation (3) can potentially
    contain multiple references to the same bone. We lump all
    these references to a single entry while summing up all the
    corresponding weights. To speed up skinning, we only keep
    the k entries with the largest weights (we use k = 4 in all
    examples) and normalize the weights so they sum up to one.
    All three skinning maps discussed above are depicted in Fig-
    ure 2.
    "
    That looks promising...
    Buuuuuuuuuuut, I just found out that, what he really means, is the particle can either be animated or simulated...You can choose which to do what. But as for collisions ? NOT as I expected...
     
  8. YoungXi

    YoungXi

    Joined:
    Jun 5, 2013
    Posts:
    63
    I think I finally knew how it is achieved...

    Unity cloth is based on PhysX from Nvidia... After some digging, I just realized how simple it could be done...

    Gonna try it out first, wish myself good luck.