Geometry Nodes/Clothing Projection Morphs

Issue #989 closed
Midnight Arrow created an issue

In #985 I said I was looking for a way to do projection morphs. So that if we have two Genesis meshes in a scene we can nondestructively deform clothing between the two shapes without needing to import any morphs or transfer any shape keys.

I have now created a preliminary workflow for it.

The Suzanne is our “clothing”. The outer cylinder is our base mesh and the inner cylinder is our morphed mesh, which was duplicated from the base mesh (to ensure its vertex count matches) and shrunk with a shape key.

This is the base mesh’s geonodes setup. It looks to the morhed mesh and fetches the vertex position at the same index. Then subtracts it from its own position and outputs those into a “Deltas” attribute that stores the offsets for every single vertex pair.

The Suzanne head has this geonode setup. It looks to the base mesh and fetches the “deltas” attribute with the “Nearest Face Interpolated” mode. So whatever geometry is closest it’ll get the vertex offset associated with it and set it to a Set Position node to deform the target mesh. It’s run through a vector math node and multiplied by a scalar to control the blending.

This is the result. Compared to the previous image we see the Suzanne head has been deformed about 0.5 meters, the difference between the base mesh and the morphed mesh.

Here it is in action. An Everyday 2 shirt blending between a G8 default and Mei Lin 8. (The “Original” and “Relative” toggle in Object Info can be used to change if the mesh warps to the new origin or just warps in place.) The deformation isn’t perfect, probably due to the face interpolation. But the Geometry Proximity node, which seems like it should do this only has outputs for “position” and “distance”, not a way to lookup an attribute from a vertex.

Still I think it’s a useful first step towards better conforming clothing.

Comments (15)

  1. Midnight Arrow reporter

    Geometry nodes are replacing modifiers so it’s “better” in it’s more modular and flexible.

    But shinkwrap is something different. That moves all vertices to the surface of the target mesh. This keeps the mesh’s surface the same but morphs the overall shape to the new figure, like moving a character slider in Daz Studio deforms the clothing they’re wearing.

  2. Thomas Larsson repo owner

    So this for fitting a piece of clothing to a character that differs from the base character, so essentially the same thing as fitting the clothing to the character in DS. Apart from workflow being non-destructive, does it add anything that isn’t already done if you import the character with dbz mesh fitting? And you must keep both the morphed and unmorphed versions of the character in Blender, right?

    The shrinkwrap trick has a different purpose: to keep the clothes outside the body of the posed character, i.e taking the armature modifier and jcms into account dynamically. It is usually easy to fix skin that pokes through the static mesh with a bit of sculpting, but the problem may resurface for the posed mesh.

    But the shrinkwrap trick has its limitations. It tends to flatten clothes, if the inner side moves out from the skin but the outer side does not. And it doesn’t handle rigid objects like buttons well. So it would be nice if one could come up with some nodes that doesn’t have these drawbacks.

  3. Midnight Arrow reporter

    It adds the ability to not use Daz Studio for anything which I consder a major plus. But it does allow to create corrective morphs for clothing more efficient. Daz Studio has a big issue where a character morph (especially an exaggerated one) will cause a distortion on clothing’s fine details even with rigidity groups (and those don’t work outside an A-pose anyway). But if you slide between unmorphed and morphed characters (and if I figure out a way to improve the projection) in Blender you can examine the clothing without need to import and export over and over again. It’s non-destructive and it’s realtime version of Daz projection morphs. As I mentioned this compliments #985 where I speculate the exporter could benefit from expanding its focus to PAs and other people who want to make clothing assets, but it’s also useful if we need to edit clothing that is exported with bad distortion.

    The memory use shouldn’t be bad since an unmorphed G8F is less than 20,000 vertices. To keep it down you can store the JCM shape keys on the base figure and use geonodes to transfer them with Set Position to the other figure, and that stores only the character-specific shape keys. Since it’s just adding up vertex positions the result should be the same (though I haven’t tested it yet).

    The raycast node is setup as the replacement for shrinkwrapping. It works very well if you have a flat surface and check for collision from a consistent direction, like a character lying on a bed. But geonodes is missing important nodes like expanding selection and smoothing so it’s not suitable for character intersection yet.

  4. Thomas Larsson repo owner

    I made an attempt at this, although it does not work yet. In lack of a better name, the tool is currently called

    Advanced Setup > Mesh > Add Projection.

    Morphed mesh active, base mesh selected, and the target clothes are selected in the popup dialog. The node trees seem to agree with your pictures, but the output vector slot remains empty, even though I set it to “Deltas” in the code. It is unclear to me if I have to add some data structure which can store the output vectors. I would appreciate if you tell me what I’m missing.

  5. Midnight Arrow reporter

    @ Thomas

    I didn’t realize this at the time, but the Surface Deform modifier does exactly what I was requesting (replicate projected morphs from Daz Studio). So this feature isn’t necessary. If you want to remove the code, I can wait to close it.

    I was looking for an effect like this: https://www.youtube.com/watch?v=vCSWDuBHmQs Except for morphing between the base Genesis figure and a character morph.

  6. Thomas Larsson repo owner

    The code was removed a few days ago. I tried the surface deform modifier but was not too impressed by the result.

  7. garden

    I experimented with Surface Deform and Daz morphs and Transferring morphs from Genesis to clothes.

    1. Fittings with Surface Deform work slower. Clothes with morphs and drivers were animated at 55 fps, while clothes with Surface Deform received 50 fps. Performance is critically important, so at this point you need to abandon the Surface Deform.
    2. Also, you can't adjust in any way what Surface Deform does, shape keys just don't work with this modifier. Complex clothing, does not use the standard JCMs created in Daz, usually vendors edit them manually so that the clothes look correct. Surface Deform tries to replicate the standard JCMs, and they will look wrong on some clothes that in Daz use their own JCMs, and not created automatically in Daz.
    3. Surface Deform is not as accurate as transferred morphs from Daz or transferred morphs from genesis directly into blender. Surface Deform matches approximately 95-99%, in some extreme bends, the result will be slightly different for the worse compared to morphs.

    If you wanted to create clothes in blender without going to daz. Then you can simply transfer morphs and drivers from any model (in this case with genesis) using this addon https://mmemoli.gumroad.com/l/tOKEh

    I tested it a couple of days ago, it transfers morphs in the same way as Daz.

    Instruction manual:

    1. Upload a mesh of clothes to the scene
    2. Press the button to transfer the vertex group
    3. Press the button to transfer the shape keys
    4. Press the button to transfer the drivers
    5. Add the armature modifier to the mesh (don't forget to check the box on "Preserve Volume")

    As a result, you will get clothes that follow the character with all the morphs and drivers. This is absolutely the same thing that we get using the Daz Transfer Utility.
    Next, you need to adjust the weight map, if necessary.
    And edit some JCMs if necessary.

    Here is the top that I took from the wildeerstudio model and dressed using the instructions above on my genesis 8 character. I slightly smoothed the weight map on the breast, for a more correct deformation. Jcms did not need to be edited, because the clothes fit tightly.
    It wasn't difficult.

  8. Midnight Arrow reporter

    @ Thomas

    Depends on your use case.

    It doesn’t require any vertex groups or shape keys, so it’s easier to set up and lighter on memory. And it’s better than shrinkwrap because it preserves relative detail (the distance away from the surface) while shrinkwrap will either flatten everything or flatten what’s below the surface but keep everything above it intact, causing weird distortion. Better to use it if you can get away with it.

    I’m also looking at ways to use it for a base to create shape keys for export back to Daz Studio, so transferring shape keys would defeat the purpose.

  9. Alessandro Padovani

    @garden Yes of course custom morphs work better. Using shrinkwrap or surface deform is an approximation to avoid importing tons of morphs in blender, it doesn’t always work fine but when it does it’s a good simplification. Then performance-wise 55 vs 50 is not a big deal imo. But thank you for your tests, it’s always good to have more opinions and data.

  10. garden

    @Alessandro Padovani

    avoid importing tons of morphs in blender

    We're uploading a ton of morphs to Genesis anyway.

    Then performance-wise 55 vs 50 is not a big deal imo

    This is a performance in an empty scene, one character with one item of clothing in 1000 polygons.
    As soon as we start adding a second character and more clothes and post the rigs dependencies, our FPS will melt before our eyes. And ultimately, due to the poor performance of the Surface Deform, we can get fps in the viewport less than the frame rate set in the scene settings.
    Every fps in viewport is very important.

    The only plus of Surface Deform is that it is a couple of minutes faster to turn it on than to transfer morphs through daz import or the addon that I showed above. But worse in everything else.

  11. Alessandro Padovani

    I don’t agree that every fps counts, also it’s not necessarily true that we load tons of morphs anyway. But again, of course I agree that using prebending and shrinkwrap is not as good as custom morphs, so it depends what you need. And the two methods can also be mixed.

  12. Midnight Arrow reporter

    I don’t make animations, so the debate over viewport performance is meaningless to me. Surface deform is also a useful tool for making custom morphs, which is only ever done in an empty scene anyway.

  13. Log in to comment