GSoC 2019: Cloth Simulator Improvement - Weekly Reports

@ish_bosamiya It hasn’t directly to do with this gsoc project, but do you know whether it would be somehow possible with the current cloth simulation system to implement the ability to rip and break clothes?

Yes, it is definitely possible but there would be many limitations to it so it has not been worked on yet.
After this GSoC project, it would get easier to implement cloth tearing because dynamically changing number of vertices would be supported. I hope to work on this after my GSoC :slight_smile:

13 Likes

Hello, first of all thanks for all the hard work. About this project, my main concern is if the remeshing feature will work with motion blur, as it changes the number of vertices per frame.
Thanks!

1 Like

I am not really sure about this, fluid simulation which has constantly changing number of vertices has motion blur applied in Cycles, of course EEVEE doesn’t support it because it is compatible only with object basis motion blur. So it might be possible to add such support even for this.

Week 9:

  • Finished obstacle metric support but dynamic remeshing not fully supported yet, need to continue to refine some parts
    • Split edges now flips the newly created edges if needed
    • Transitioned to using ClothVertMap which is a mapping between the BMVert pointer and the ClothVertex, this is important to eliminate floating point precision errors and to also speed up the remeshing step
    • Switched to using the same edge size calculation for all the different sub algorithms during remeshing to ensure consistency and better maintenance of code
    • Edge face pair detection used the method part of the BMesh api, it was overlooked that it gives the face pair if and only if 2 faces are available for the edge. Hence switched to custom function which works with even a single face.
    • Improved UV determination method
  • Started discussion with mentor about how the caching system can be changed to support changing number of vertices
    • One of the plans is to run the remeshing step before the cache file is read to ensure that the number of vertices matches for both, the mesh and the cache file match. The cache file already stores the information that is needed during the remeshing step, this would mean no extra data needs to be stored. Although this does have a time overhead.
    • Another plan is to store Barycentric UV coordinates of all the new points within the existing faces and also store face indices for each of those points. It might be possible to reconstruct the topological data from this information.

Plan for the following week:

  • Have a working build for dynamic remeshing
  • Start to implement the above mentioned caching methods
  • Continue to add back support for pinned vertices and sewing
13 Likes

Hello again. When will there be a tutorial for using this new syste? Dan’t wait, Thx :grin:

1 Like

Thanks for the answer! It’d be awesome having true motion blur on the adaptive remeshing, otherwise would be kind of limiting render-wise.
Cheers!

1 Like

True!

Having Motion Blur is something absolutely needed for anything, devs should always plan things with this in mind :slight_smile:

3 Likes

Week 10:

  • Dynamic Remeshing is now WORKING! :smiley:
    • Link to video
    • Massive increase in remeshing speed
      • By storing the nearest planes every frame instead of recalculating it for every face
      • By adding a new way to update active faces after “flip edges”
      • By calculating UV offset every frame instead of each time the UVs are needed
    • Found and fixed errors
      • Eigen decomposition was not working correctly, 2 elements of the matrix were swapped
      • Made an error while calculating the aspect ratio of the triangle leading to smaller than expected values
      • Some of the matrices were transposed which lead to wrong calculations
    • The remeshing step now respects the initial mesh structure and does not affect original vertices. Although this is useful, it is debatable that the remeshing step should preserve the overall structure not necessarily the original vertices. Need to discuss this with mentor.
  • Starting to implement the first caching method
    • Have run into the issue of the entire cloth modifier structure getting deleted every time the cache is invalidated, possible fix is to have a special function for freeing the modifier when adaptive cloth simulation is active

Plan for the following week:

  • Continue to fix bugs that lead to instability
  • Continue to implement caching
  • Continue to add back support for pinned vertices and sewing
27 Likes

Hey great job :+1:
May I ask if pressure is a planned feature? I’d use it extensively for making cushions, pillows etc.

Thanks

1 Like

@Sleeper_G I will make the tutorial once GSoC is done, although the documentation will be enough to understand how to use it.

@MarcoG It is not part of the GSoC proposal but there was a proposal for the same created a long time back https://developer.blender.org/T30941. Maybe it can be merged in sometime soon.

2 Likes

Since you are already talking about making tutorials after GSoC, does that mean that the odds are good that this will be accepted into the main branch?

I certainly hope so, although this is up to the core developers. I do plan to continue to work on this even after GSoC is done.

10 Likes

Week 11:

  • Added support for sewing edges
    • If cloth has sewing edges, new sewing edges are automatically added when an edge between 2 sewing edges is subdivided. If the opposite side edge can be subdivided, it subdivides the edge and creates a new edge between the 2 newly created vertices, if the opposite edge cannot be subdivided, it creates a new edge between one of the existing vertices of the opposite edge.
  • Caching system is nearly implemented
    • Caching works if playback is started from the first frame, but fails if playback is started from any other frame, need to find a way to prevent this from happening.
  • UI changes
    • It is now possible to turn off adaptive remeshing.
    • Added option for choosing between static and dynamic remeshing.
  • Fix bugs that lead to instability
    • Most notably, BMesh vertices that were killed during collapse edges were not being reflected on the cloth vertices, this has now been fixed.

Plan for the following week:

  • Continue to implement caching
  • Start working on the documentation
14 Likes

Week 12:

  • Started working on documentation
  • Worked on fixing bugs and worked on caching (in separate branch)
    • Added custom method for collapsing an edge
      • The BMesh method for collapsing an edge lead to some mesh artifacts, so added a method to collapse an edge which maintains triangulation.
      • Initially, the bug seemed to be in split edges, so I implemented two other ways for splitting an edge and maintaining triangulation of the mesh. Need to see which method is most optimized and remove the rest.
    • Caching is still an ongoing issue.

Plan for the following week:

  • Wrap it up
5 Likes

How did things go with the final week of GSoC? I hope it went well! :slight_smile:

The final week has gone well, more info here.

In brief - Happy to say, pinning now works :smiley: , will work on making the project stable after a short break.

10 Likes

When I try applying the cloth simulation from the modifier stack or pause the object goes back to its original shape, I think it’s a bug, is it fixed?

Yes its a bug, caching has not been implemented completely which leads to the mesh jumping back to the original shape. I hope to get back to this project soon :slightly_smiling_face:

4 Likes

Thanks for the reply, although when you hit play the mesh continues of from where it left on from the last time the simulation was running and this keeps happening until you change a parameter within the cloth settings.