transfer jcms optimization ?

Issue #972 resolved
Alessandro Padovani created an issue

daz studio 4.15.0.30, blender 3.1.2, diffeomorphic 1.6.2.0968

It is reported by Surody at the daz forum that some outfits take forever to transfer jcms. I did a little test on g8f with basic wear and noticed that some jcms are transferred even if the outfit gets no weight maps for them. This happens both for easy import and the transfer jcms tool.

For example the lShin bone gets no weightmap on the shorts, so it is unuseful to transfer the lShin jcms on the shorts, they will drive nothing. I mean before transferring a jcm we can check if the bone gets a weightmap, if not the jcm is not transferred.

Test scene included basic-wear.duf

steps:

  1. easy import basic-wear.duf with transfer jcms

alternate steps:

  1. easy import basic-wear.duf without transfer jcms
  2. transfer jcms

Comments (16)

  1. Thomas Larsson repo owner

    No, I don’t think that you can do that. Even if the shorts have no shin weights, they need to move in the same way as the underlying body, and that would not happen if the shapekeys are removed. The shin bend morph affects the knee area, both on the shin and the thigh, and apparently it extends all the way up to the shorts.

    The plugin does skip shapekeys that do not influence a piece of clothing at all, by comparing the bounding boxes of the clothing and shapekey. But in this case the shin bend jcms do affect the shorts, because otherwise they would not have been created. The character in front of the shapekey in the terminal window shows what happened:

    . * Vendor morph used.

    . + Shapekey transferred

    . - Shapekey transfer attempted but the result was empty.

    . 0 Shapekey skipped because bounding boxes did not overlap.

  2. Alessandro Padovani reporter

    Uh do you mean a jcm can potentially go outside the weight map and affect any part of the mesh ? This may be technically possible but makes little sense since jcms are meant to correct the weight map deformations so to only affect inside the weight map.

    Just did a test with the shin jcms and I see the thigh deformations on g8f but nothing in the area that affects the shorts. If I use another example as the dark storm pants then yes they do have weigh maps for the shin that covers part of the thigh.

    When I proposed this optimization to the daz developers for the blender bridge, Sam implemented it commenting this was a good idea. And it speeded up the bridge a lot. Are you sure that we can’t use the weight maps as filters ? Would it be difficult to add this as “experimental“ to do some tests ?

    Then if you’re 100% positive that this is not going to work can you provide an example where it fails please ? So I’ll mark as resolved.

  3. Alessandro Padovani reporter

    Changed from bug to proposal since after the explanation by Thomas I understand this is not a bug, and may also fail as enhacement for a general case. But I’m still not sure it wouldn’t work in a real case scenario for the daz figures.

  4. Alessandro Padovani reporter

    To explain it better. If the shorts have no weight map for the shin bone, then it means they’re not supposed to deform with the shin bone at the weight map level. Then I understand jcms may affect any part of the mesh, but the idea is they shouldn’t affect outside what it is supposed to deform with weight maps. At least should work if jcms are “designed correctly“ as may be the case with daz figures.

  5. Alessandro Padovani reporter

    update. real case to test for speed.

    Apart the optimization idea, below is an example of the “wait forever“ case. I provided the blend file stripped of materials, where I imported G8F and a snake bracelet. The figure includes a couple jcms for testing, it’s the shoulder up jcms. If we try to transfer pJCMShldrUp_90_L to the snake we “wait forever”.

    Be aware that the snake is about 62K vertices so that may be the only reason why it takes forever. But I reported this example for you to test just to be sure there isn’t any other reason.

    steps:

    1. load nile.blend
    2. transfer pJCMShldrUp_90_L from G8F to the snake bracelet

  6. Thomas Larsson repo owner

    The shin bend 155 morph affects the front of the thigh quite high up. Here is the difference without and with it. The shin bend 90 morph is more localized to the knee area and is therefore not transferred.

    And a closeup

  7. Thomas Larsson repo owner

    Oops. There was a totally uncessary double loop in the code for transferring rigidity loop. Now the transfer time is linear rather than quadratic in the number of vertices, i.e. much faster.

  8. Alessandro Padovani reporter

    And if you look at it you’ll see the shorts don’t cover that portion of geometry, they are much closer to the hip. Also I can’t see any poke on the shorts if I apply the full shin jcms on g8f. My point is that if the bone weight doesn’t affect the outfit then it is likely that the bone jcms won’t either. But I do understand what you say, mine is not “correct“ as a general case.

    Anyway the speed issue seems to be different from the optimization, as the snake test above.

  9. Alessandro Padovani reporter

    Thomas commit 776729b works great you got it. To transfer jcms is now fast with rigidity too.

    As for the snake example, again there are jcms that in my opinion are not necessary, in this case the collar jcms that don’t have a weight map. Please let me know if you want to try the “weightmap optimization“ as experimental, otherwise I’ll mark as resolved since the main issue is fixed.

    And thank you for the fast fix as always.

  10. Thomas Larsson repo owner

    There is now an option to ignore jcms without vertex groups. I don’t think it is very useful, but it doesn’t seem to hurt, at least in the shorts example.

    The plugin makes quite a few steps to handle rigidity, so it is not unreasonable that it takes twice as long. Anyway I didn’t see anything obviously bad in the code anymore.

  11. Alessandro Padovani reporter

    Commit 578bfb5 works fine, marking as resolved.

    With the figures I tested there doesn't seem to be any sensible difference in speed with the vertex groups option. But it does simplify the jcms without any artifact that I noticed.

  12. Log in to comment