Used morphs on import or "default" values

Issue #1011 duplicate
Former user created an issue

Hello,

I recently worked with Geografts for my character and noticed something that made my progress a little difficult. In my case, I was shaping genitals for a character with morphs and giving it a default shape that would be exported to Blender.

My problem is that when the mesh is imported, since the morphs are not contained in the mesh anymore, I need to import them as custom morphs again, but the shape keys are all set to 0. So when I try to use the same morphs as I used in Daz, they are added/applied twice onto the final shape.
Is there a way to import custom morphs that keeps the values assigned in Daz so I can continue working with the values in Blender or undo morphs I was using? Would it be easy to implement by reading the assigned morphs and storing the values somewhere on export to be read when the morphs are imported or is there another way to implement this into my workflow? Am I missing something?

(I guess using the default mesh and shaping it with custom morphs in Blender would be a solution but it doesn’t have the same freedom as in Daz since I make my character there before refining it in Blender)

Comments (14)

  1. Alessandro Padovani

    If you want to preserve the daz morph values then you have to import the base shape, then import morphs. If you import a morph baked with dbz then import the same morph again of course it will be applied twice.

  2. Former user Account Deleted reporter

    But is there no way to keep track of the morphs that are baked? Like some kind of way to not bake the used morphs but instead import them with the figure in Blender as shape keys and applied with the values set in Daz. Or an automatic way to import the custom morphs that were used in Daz so you don’t need to manually find and apply them again on a blank figure? That would allow some flexibility since the morphs would have been setup in Daz and simply added back in Blender

  3. Former user Account Deleted reporter

    Here is what I have in mind, (I’m not sure how difficult it would be) :

    • Create the figure with morphs in Daz
    • On export, check the morphs that are not set to 0 in the “currently used” morphs if it’s accessible, this gives an idea of which are really used
    • Store the information of those morphs somewhere, maybe keep track of the “favorite” morphs in Daz
    • When importing back in Blender, the morphs are automatically imported with the figure and their values are set

    Of course it could be toggled so that the imported can still use baked morphs, that would simply improve the workflow.

  4. Former user Account Deleted reporter

    After experimenting with Daz and Diffeomorphic’s scripts, I’ve made this simple function, which takes all the morphs that are used by the figure and each node with morphs, then save the morphs infos in a folder called “morphs” in the file directory as text files. Each file contains the path of the morph to be found (uri.toPath) and the values set on the figure. Of course it’s very simple and the figure is still baked with the morphs, this needs to be disabled. Also it requires a lot of tweaking, especially while checking for which morphs are used.

    The only issue I have is that it’s taking the morphs as expected but not the pose modifiers yet, especially units. For example, the modifiers such as “Eyes Close” or “Mouth Open” are not checked properly for some reason, I tried saving data from “eCTRLMouthOpen” which is not found.

    I tried writing a table with all of the modifiers that the exported came across during the exportation but there was not a single mention of “eCTRLMouthOpen”. I also checked Issue #848 but it doesn’t apply since the name and the ID of the morph are the same.

    Now, while it’s all fine, seemingly working enough from Daz, minus the last issues, I’m not good enough with Python to get this file and import the morphs to the figure automatically and with the values. I guess I would need to reproduce the Custom Morphs import using the saved data.

    const path = fp.dir().path();
    const dir = new DzDir(path);
    dir.mkdir("morphs");
    txt = new DzFile(path + "/morphs/" + node.name + ".txt");
    txt.open(txt.WriteOnly);
    
    var n = obj.getNumModifiers();
    for(var i = 0; i < n; i++)
    {
        var mod = obj.getModifier(i);
        if(mod.inherits("DzMorph"))
        {
            var oProp = mod.getValueChannel();
            var nMin = oProp.getMin();
            var nMax = oProp.getMax();
            var nVal = oProp.getValue();
            var nRaw = oProp.getRawValue();
            var nDef = oProp.getDefaultValue();
            var sPath = oProp.getPath();
            var sLabel = oProp.getLabel();
            var sName = mod.getName();
            var uri = mod.assetUri;
    
            if(nVal != nDef && nRaw != nDef)
            {
                txt.writeLine(uri.toPath(""));
                txt.writeLine(nMin);
                txt.writeLine(nMax);
                txt.writeLine(nVal);
                txt.writeLine(nRaw);
                txt.writeLine(nDef);
                txt.writeLine(sPath);
                txt.writeLine(sLabel);
                txt.writeLine(sName);
            }
        }
    }
    txt.close();
    

    Edit: I added “nRaw” because, unless I’m wrong, it seems to give out the exact value that is set and helps checking the morphs that are added to a figure by default, especially those set to 0 but defined as edited values. After a few tests, it seems to return ONLY the morphs that I decided to change as expected.

    Edit 2 : I managed to export the head morphs such as “eCTRLMouthOpen” after searching through the available properties of the node, now everything should be exported to the file.

  5. Former user Account Deleted reporter

    To allow the user to export the morphs baked as they are by default or not, there is a simple dialog showing up just like with the HD exports.

    This allows the user to create the morph files and get a figure exported without any morph applied before being added in Blender. Or the same as usual with every morph bake into the figure and no morph exported.

    The only thing missing is to let the DBZ file know what kind of export was used so that Blender can check if morphs needs to be imported or not.

    This is working quite well since after I import the non-baked figure into Blender, the meshes are the default without morphs applied (only if “Bake morphs” is unchecked), waiting for the morphs to be imported back into Blender. And since the values are removed and reapplied during the exportation process, there is no visible changes in Daz.

  6. Former user Account Deleted reporter

    Here is the whole process:

    • First, I shaped my character using morphs. Here the body was changed as an example.

    • I export the non-baked figure to Blender, unchecking the “Bake morphs” checkbox in my custom window. Here the morphs are kept in memory, set to 0 during the exportation and their original value is set back so that I can continue working with my morphs in Daz.

    • A text file has been created listing the morphs that I applied. Here only one, the “Boom Chica” morph.

      * Back in Blender, the figure gets imported without the morphs, but they are still known from the text file.

    • Here is the process I’m trying to automate, where I can’t get it to work properly:

    The morphs are read from the txt file and loaded with the values given by Daz. This would allow me to continue working on the figure with my custom morphs.

  7. Alessandro Padovani

    I can’t help you with the script since I’m not a coder. May be Thomas will find this useful and include it as an option.

    If I understand correctly you want your figure to be imported with the used morphs without baking them. In my opinion it would be easier to export a basic figure then import the morphs you want in blender. Also because there will be a number of unused morphs that you’ll want to import so you need to do this anyway.

  8. Former user Account Deleted reporter

    Yep, basically the idea is to not bake the morphs and use them as they were in Daz, or decide if they are still baked as usual. The solution I tried to bring here is a way to automate the process of importing the morphs in Blender without having to search for them one by one, especially if you don’t know their path. And since in my code I check which morphs have a value (raw value) not equal to it’s default value, it allows the exporter to know which morphs are used or unused.

    I had this issue in the beginning where I saw a list of morphs I didn’t use but I got rid of it thanks to this solution. What I’m left with is a file containing only the morphs I edited myself.

    The initial idea comes from me using morphs such as “cleavage” which I would have liked to switch on or off depending on the clothes on the figure but importing the morph every time was annoying, so I searched for a solution to import it with the figure directly without having it baked. Of course it’s a bad example since it’s only one morph, but applying this to geografts with many morphing possibilities that you can toggle with sliders and “prepare” in Daz before using it directly in Blender separates the workflow: Daz for the figure, Blender for the renders. And the ability to quickly “pose” the morphs for rendering makes the process easier.

  9. Former user Account Deleted reporter

    Update: I’ve uploaded my modified .dsa file here, it changes a big part of the script and it’s mostly for testing. What it does is basically search through properties and modifiers to check which values and raw values are not equal to their default value (when the morph has been changed by the user). It then writes the informations in a text file, for each figure in the scene, all inside a new “morphs” folder.

    During the exportation, the morphs are set to 0 and their object references and values are stored (it’s not pretty but since I’m not familiar with the api, I decided to go with a very basic 4 array solution, it should be replaced by a class if that’s even possible). This way, the exported figure will be imported into Blender without the morphs. Then, at the end of the process, all of the morphs are set back to their defined values and you can keep working in Daz.

    The only thing missing now is the Blender importer, it should be able to know if a figure was exported as “non-baked” and read the morph info file in the “morphs” folder that appeared. This will give the path to each morphs .dsf file and the values they were set to in Daz.

    This should allow users to work with non-baked morphs.

  10. Thomas Larsson repo owner

    Wilfre, did you try to import the character with Mesh Fitting set to Morphed, as in https://diffeomorphic.blogspot.com/2021/03/importing-morphed-character-without-dbz.html. This should load the character without applying the morphs. Unfortunately, it seems to work only sometimes, but I never used it myself so I haven’t investigated the issue further.

    To make the morphs affect the armatures as well, you need to enable ERC Morphs in the global settings. See https://diffeomorphic.blogspot.com/2021/09/morphing-armatures.html and https://diffeomorphic.blogspot.com/2021/11/morphing-armatures-and-rendering.html.

  11. Alessandro Padovani

    Thomas, what Wilfre is looking for is for the used morphs to be exported as non-baked. This allows to set the custom morphs in daz studio instead of “searching” for the morphs when we load custom morphs in blender. This is not provided with any current tool.

    Then personally I believe the request by Wilfre is not useful. I mean there are a lot of non-used morphs that we need to load to make the figure working as intended, so we have to search for them anyway. For example the custom jcms. So listing the used morphs is not a solution to avoid importing custom morphs by hand.

    Also blender doesn’t work fine with hundreds of morphs anyway that’s why I rather prefer to simplify the figure with #994. That’s exactly the opposite of what Wilfre does.

  12. Former user Account Deleted reporter

    As Alessandro said, the idea is indeed to import non-baked morphs if the user decides to go with this process. Instead of importing manually the morphs or custom morphs you want and setting their values to reflect the changes in the Daz project, this idea would instead have Blender import the figure without morphs and get the required morphs imported automatically depending on which are needed.

    For now, what I have is generated files by the exporter that tells which morphs are used, only the ones which have been modified and not the unused morphs, and their values as well as their file paths. I managed to ignore unused morphs and ended up with a list with ONLY the ones that are really used as to avoid getting unexpected morphs.

    In my example (and further testing), I used two morphs: “Boom Chica 1” and “Mouth Open” (which is a property), those two are the only references in the file which is generated. And since we now know both their values and file paths, all that’s needed is to import them in Blender by reading the files. This should launch a custom import of both “eCTRLMouthOpen.dsf” and “FBM_LY_BoomChica01.dsf” only. As, again, I managed to avoid references to unused morphs and end up with those only two morphs as expected.

    This would mirror the process used in “Import Units” for the “Mouth Open” property, and “Import Custom Morphs” for the “Boom Chica 1” modifier. And should, if done properly, avoid importing any other morph than the ones required.

  13. Former user Account Deleted reporter

    To illustrate what I ended up with after the export:

    This is the whole content of the file that I generated. “Mouth Open” is referenced as a property, with the path to the file and the values. And the morph “Boom Chica 1” with it’s own path as well. There is not any other morph in this file besides the two I used and managed to find properly.

    No unnecessary morph has been referenced since I ignored the ones that are unused by the user.

  14. Log in to comment