better dforce

Issue #410 resolved
Alessandro Padovani created an issue

daz studio 4.15, blender 2.92, commit 6e8321f

First I'm not a dforce or blender simulation expert at all, so I'm sure things can be improved and anyone interested please help. Then, since in the daz forum there's some request to import dforce assets, I decided to dig in for the fun and I got some nice results, so I'll share them here.

The purpose is not to import dforce simulations in blender, or to use the blender simulation to mimic exactly what dforce does. But it is rather to import dforce assets so they can be used with the blender simulation.

So let’s start.

Comments (32)

  1. Alessandro Padovani reporter


    We start as example with the "simple sheet drop" scene in the dforce starter. Test scene dforce-1.duf included.

    The first step is to import the basic dforce scene attributes, so that when we start the simulation in blender it will behave similar to dforce. Luckily this is not so difficult, we just need the collision and dforce attributes.

    If we get "visible in simulation" in daz studio in the display options, then we add a collision modifier in blender. The only caveat is, if the object gets a subdivision modifier then we have to place collision before subdivision. This is necessary both to speed the simulation and to improve the precision since it seems the blender simulation has issues with too small polygons. Also, always for better precision, we set thickness to 1 mm that seems the minimum possible value.

    Ok we got the collision objects. Now if there's a dforce surface in daz studio then we use a cloth modifier in blender. Please note that different surfaces in daz may get different dforce parameters. Again we're not interested to get exactly what dforce does, but rather to get something similar in blender. So the only surface parameters we're interested in is if dforce is used or not, and how much, that is, the dynamics strength.

    Then in blender we place the cloth modifier before collision. As for the simulation parameters I found that the silk preset works quite fine, but this can be changed by the user with any other preset once the dforce asset is imported. As for precision, I found that 16 steps for the cloth and 4 steps for the cloth collision seems to work fine enough in most cases. Also as usual 1 mm distance for collision that's the smallest available.

    # the modifier chain will be: cloth (if any) > collision (if any) > subdivision (if any)
    # we use cloth to simulate dforce
    preset = silk
    quality steps = 16
    collision quality = 4
    collision distance = 1 mm
    self collision distance = 1 mm

    Also we have to set a pin map in blender with the dynamics strength, to assign to the cloth shape. Please note that different surfaces in daz studio may get different dynamics strenghts, so the pin map in blender will get all of them. We'll see a more complete example later with the bardot outfit for G8F.

    # we create a pin map with the dynamic strength
    dforce pin = 1 - dynamics strength

    Then below the conversion result. First daz studio then blender. Please note that the draping is not the same since we didn't convert the dforce parameters, but we got a dforce scene in blender that we can use with the blender simulation.

    simulation in daz studio at frame 60

    simulation in blender at frame 60, the draping is different and "harsh"

    Please note that the blender simulation is "harsh" since in this case the polygons are big enough. To solve the issue we could get smaller polygons by subdivision, but this also means to slow down the simulation. So a better solution is to add a subdivision after the cloth, together with a displace modifier to compensate for the subdivision smoothing.

    This is not possible to automate since we don't know when this trick is needed. So it could be a "dforce smooth" tool that the user can apply to "harsh" simulations.

    # dforce smooth parameters
    midlevel = 0
    strenght = 2 mm

    Then below the result with the "dforce smooth" trick.

  2. Alessandro Padovani reporter


    Our second test will be a dforce outfit. We take the bardot skirt for G8F as example. Test scene included dforce-3.duf.

    The steps are the same as above, but the difference here is that the skirt gets multiple surfaces, with multiple dynamic strengths to bake in the pin map. To do this by hand in blender, we can select the surface in edit mode, then assign the weight. We can also see the obtained pin map in weight paint mode.

    # we create a pin map with the dynamic strength
    dforce pin = 1 - dynamics strength

    Then below the simulation, first daz studio then blender. Again please note the cloth is before subdivision to avoid precision issues and also speed up the simulation.

    simulation in daz studio at frame 30

    simulation in blender at frame 30, again the draping is not the same, here we don’t need the “dforce smooth” trick

  3. Alessandro Padovani reporter


    Well now for the real deal. We want to simulate in blender a figure animation with a dforce outfit. We take as example the bardot outfit for G8F. Test scene included dforce-4.duf.

    Please note that there are a number of caveats to get a successful simulation, these rules apply both in daz studio and in blender, or any other software.

    1. We have to start the simulation with the relaxed pose for the outfit, so to allow the draping to take place.
    2. At the start of the simulation the outfit must not intersect with the figure, that's the collider.
    3. During the simulation the figure, that's the collider, must not intersect with itself. If this happens the cloth gets caught and bad things happen to the simulation.

    For the purpose I did a little animation by baking the "dance in place" aniblock for G8F, but starting with the neutral G8F pose. Test animation included g8f-zero-dance.duf.

    So to get the test scene in blender we have to import dforce-4.duf, then follow the procedures above to get dforce into cloth, then import the zero-dance animation and simulate. Of course the animation must be loaded in daz studio too before simulation.

    Then below the final result, first daz studio then blender.

    simulation in daz studio at frame 50

    simulation in blender at frame 50, again the draping is not the same

  4. Alessandro Padovani reporter


    One trick to speedup the simulation is to use the speed multiplier. This way we can lower the steps without breaking the collisions. The bad side is that the cloth simulation gets “amplified”. That is, the lower the speed the more deformation we get.

    edit. The dforce time on my system is 45 sec, so 100 sec for blender seems acceptable considering that dforce is using the gpu while blender is using the cpu. Also I have a weak cpu ryzen 3 2200G, that’s slow compared to my GTX 1060.

    Below some possible combinations:

    1. speed 1, steps 16, simulation time 100 sec
    2. speed 0.5, steps 8, simulation time 50 sec
    3. speed 0.75, steps 12, simulation time 75 sec

    And an example at frame 50 with speed 0.5. Please note the amplified deformation.

    Then it is possible to counter-effect the speed multiplier by increasing viscosity. Below it’s frame 50 with viscosity 10. The animation is not so good though, it looks like underwater, that’s what viscosity is for. Anyway I believe it can be useful to know about these tricks.

    As for the default values I’d stay with 16 steps and speed 1 that works fine for most cases and gives a good animation, though it’s a bit slow.

  5. Alessandro Padovani reporter


    Another option is to use dforce weight maps, that will work together with the dynamics strength to define the influence. Below an example where I used a weight map to convert the dark storm armor for G3F. That’s the “create > new dforce weight node” menu. Test scene included d-map.duf. And below a quick tutorial for dforce weight maps.

    Please note that there’s one weight map per figure, as opposed to one strength per surface.

    Please note that it may be necessary to save as support asset to test the plugin. I didn’t do it to avoid creating a zip package for the test scene. The test scene includes G3F with the dforce armor and a short animation for the draping.

    # dforce weight map
    dforce pin = 1 - (dynamics strength * weight map)

    And below the simulation at frame 30.

  6. Thomas Larsson repo owner

    This is an interesting read, but I don’t think it belongs here. It is more suitable for some tutorial site. If you like I could copy the content to my blog.

  7. Alessandro Padovani reporter

    Thomas, I see the plugin already imports some basic dforce attributes. So why can’t we improve it ? By importing collisions and the dforce strength together with weight maps, as explained above, we’d have a good support for dforce outfits that’s the goal here.

    Also, we can copy the strength but there’s no way to export the weight map, other than using an exporter so only diffeo could do it.

  8. Alessandro Padovani reporter

    Thomas, the request for dforce outfits at the daz forum goes on, and personally I believe it would be nice to introduce it in 1.6, at least as a first attempt, since nowadays almost every outfit for G8 gets dforce draping. If you could import collisions and a weighted pin map as described above, this would be enough for a first implementation of dforce draping. And in my tests it doesn’t work so bad. The draping is not the same but it drapes nevertheless.

    Please also let me know if you need help for technical data since we can ask to Sam of the daz team. He contacted me to get better materials for the daz bridge.

    edit. As an example of dforce outfit using both strength and weight there’s the sweet anime outfit in the sakura 8 starter bundle, that I can test.

    edit. Below an example with the anime outfit that I converted by hand. It’s the draping at frame 50 first daz then blender. I chose the cotton preset in this case because it tends to preserve the shape better.

    In the general option we could also set default values for dforce that the user can change. In my tests the relevant options are the iterations and the collision distance, other than the cloth preset.

    # default values for dforce simulation
    simulation quality: 16
    collision quality: 4
    collision distance: 1 mm
    cloth preset: cotton

    edit. Below the simulation in blender where I halved the cotton vertex mass. It seems to me that the blender cloth presets are a little heavy compared to real gsm (grams per square meter that’s the common unit for cloths). We could add a gsm factor in the global options to multiply the vertex mass with.

    # default values for dforce simulation
    simulation quality: 16
    collision quality: 4
    collision distance: 1 mm
    cloth preset: cotton
    gsm factor: 0.5 (vertex mass multiplier)

  9. Alessandro Padovani reporter

    Thomas, again .. there’s really demand for this. Please consider importing at least the dforce strength and weight in the pin map as reported above. I see the plugin already imports a pin map but it’s flat so not useful.

    Also let me know if you need help since I can ask to Sam of the daz team for technical data.

    Or please let us know if you’re definitely not interested so I can close this one. But if so I can’t understand what the simulation settings in the global options are for if you don’t want to support and/or improve them.

  10. Thomas Larsson repo owner

    I’m definitely interested in this, just haven’t found the time. It was quite some time since I thought about simulation, and have forgotten most about it.

  11. Alessandro Padovani reporter

    That’s all I need to know so I’ll keep this open. Of course take your time and let me know if you need anything. I’m here to help.

  12. Alessandro Padovani reporter

    I see it’s started already. As for commit 812ec91 I tested dforce-1.duf and it goes great as a first step. The collision modifier has to be after the cloth though.

    Also I’d advise to expose the main simulation parameters in the global settings, so the user can change them if needed. And it is also useful to me to do tests, instead of tweaking the code. The cotton preset and a 0.5 gsm factor seem to work fine in general. The silk preset is a little weak to keep the cloth shape and it’s not good for outfits.

    # default values for dforce simulation
    simulation quality: 16
    collision quality: 4
    collision distance: 1 mm
    cloth preset: cotton
    gsm factor: 0.5 (vertex mass multiplier)

    Please note that dforce uses gsm while blender uses a vertex mass. So in general it is not possible to convert dforce into blender cloth, unless the geometry density is constant. That’s also why using a preset may make more sense than trying to convert the dforce parameters.

    As another note personally I believe that both dforce and blender cloth are quite unstable at the moment and it is a little miracle that they work fine enough. This is another reason for me to stay away from too complex conversion and point to convert the main structure instead.

    Specifically, I see that the blender cloth only works fine with the default 1.0 unit scale. If we change it the whole cloth precision goes south, and unfortunately this seems confirmed by the blender team. So this may be an important note to add in the docs.

  13. Alessandro Padovani reporter

    As for commit 0821b96 I tested dforce-3.duf but I get a blank dforce pin. Not sure what the comment “Simulation influence groups, at least sometimes“ in commit 63f1d7c means. We basically have to assign the surface dynamic strength to the pin map, as described in chapter 2 above “getting into dforce outfits“. If I can do this by hand I suppose the plugin can do it too. Please let me know if something is not clear.


    1. in edit mode select the material, this will select all the material vertices
    2. in the vertex groups panel assign the weight to the pin map, this will affect the selected vertices

    As for the global settings, I was including the collision distance because I see that blender is quite sensitive to this. That is, for large objects we could choose a larger collision distance and lower the needed iterations. So if you could include the collision distance it would be useful.

    Then as a default value for GSM I’d suggest 0.5 that seems to work fine enough for daz outfits. Of course it is true that this also depends largely on the mesh density. But in my tests we can’t go too low on this otherwise the simulation breaks, so 0.5 seems a good value anyway.

  14. Thomas Larsson repo owner

    You get a pin group with d-map.duf, but I haven’t found where the weights are hidden in dforce3.duf. So one out of two is sometimes.

  15. Thomas Larsson repo owner

    I found some old asset with dforms, which can be translated into vertex groups in Blender. The pin group could then be made from the sum of the dform groups, perhaps. However, most dforce assets don’t seem to have dform modifiers, so this is rarely useful.

  16. Xin

    Are you looking for the “Dynamics Strength” inputs? those are per-material parameters. If you get the polygons covered by the material, you can create a vertex group with them.

  17. Alessandro Padovani reporter

    As Xin says, it’s the dynamics strength in the duf file. You apply the value to the vertex selection as explained in chapters 2 and 5, and in the example above. If there’s no weight map we only use the dynamics strength (weight map = 1).

    # dforce weight map
    dforce pin = 1 - (dynamics strength * weight map)

  18. Alessandro Padovani reporter

    As for d-form, as I understand it, it has nothing to do with simulations. A d-form modifier is something we can use in daz studio to animate deformations. That is, the d-form properties are keyframed. It may be something similar to the hook modifier in blender.

    It’s more “Poser 6” technology for V4, rarely used in genesis figures. And if you want to implement it may be it deserves another discussion for testing.

  19. Thomas Larsson repo owner

    The plugin does add a pin group with a constant value based on the dynamics strength, but to do it on a per vertex basis I need a weight map. There is such a map in the file d-map.duf, but AFAIU not in dforce3.duf. But if the weights are assigned on a per-material basis, the vertex weight may be taken from there. Have to study this more.

  20. Thomas Larsson repo owner

    Now it works. Thank you Xin for pointing out that the simulation parameters are defined per material, that was exactly the comment I needed.

  21. Alessandro Padovani reporter

    Thomas you got it, commit 6b40e69 works great with the dynamics strength. I get an error with the weight map though. I used dforce-6.duf as test, that gets both strengths and a weight map.

    Sorry that I wasn’t clear enough. The strength is per material, while the weight map is per object.

    Also I see that self collision is disabled for cloth. I’d suggest to turn it on since cloth can’t work fine without self collision. Then disabling self collision may be a optimization attempt to speed up the simulation, but it doesn’t work fine for the general case.

  22. Thomas Larsson repo owner

    Hopefully things will work now. I don’t have the Sakura bundle so I haven’t tested that, but your description is clear and I think it will work.

  23. Alessandro Padovani reporter

    Commit 0583689 works great, now I can load any dforce outfit and it drapes fine. We did it !

    ultra mega important note

    I found a tutorial that’s suggesting to change the scale to speed up the simulation. I just tried it and it seems to work. With d-map.duf that’s the dark storm armor, the simulation goes from 120 to 40 seconds, same parameters just changed the scale to 5x. So may be this is a nice trick to add to the docs.

    Personally I suspect this has something to do with the minimum distance for self collision. That is, without self collision the difference is not noticeable. With self collision we go from 120 to 40 seconds. By changing the scale, 1 mm of self collision gets more precision and the simulation runs smoother and faster.


    1. set the scale of the figure to 5x, no need to apply the scale
    2. run the simulation
    3. set back the scale to 1x

    edit. Please note that we can’t do this by changing the scene unit, since this way the simulation precision breaks. We need to change the figure scale instead.

  24. Alessandro Padovani reporter

    @Thomas Larsson , some notes about the blog post, that may also be useful to anyone reading here. Then I'm marking as resolved since this is a good start and eventually we can open other discussions for improvements.

    1. It seems the dforce-4.duf example got corrupted in the upload, that's why the bardot skirt doesn't get the collision modifier. And I suppose this may also affect the simulation. Yes I know we're lucky. I'm replacing it now.
    2. As for the subdivision modifier, it doesn't affect the simulation because it's after both the cloth and the collision. But it takes some time to render in the viewport. I usually keep subdivision off in the viewport with the simplify settings, this also helps animation.
    3. I don't get your strange result with the bardot simulation. Specifically the skirt should't rise that much, it looks like it's underwater. Using the default settings with cotton and 0.5 gsm it's much better, then in this case I get an optimal result with silk and 1.0 gsm. Below it's the simulation at frame 50.

    Please note that the skirt transparency is wrong. That's reported in #460 to fix.

  25. Log in to comment