SBH hair error

Issue #268 resolved
Alessandro Padovani created an issue

Tested with daz studio 4.11 and 4.14 beta, blender 2.90.1, plugin commit 672b92b.

It is the first time that I try to import strands hair, so it may very well be something I miss. I did a simple SBH in daz studio, scene included, when I try to import it I get the following error.

Comments (32)

  1. Thomas Larsson repo owner

    The crash is eliminated. However, it turns out that SBH is not implemented after all. What I thought was SBH, e.g. the mohawk hairdo, turns out to be a mesh with lines instead of faces. In practice most vendors tend to do hair that way, and the lines are readily translated into particle hair in Blender. Proper SBH cannot be implemented, because the data is stored in an undocumented binary format (base64 encoded iirc). For the same reason, aniblocks cannot be implemented.

  2. Alessandro Padovani reporter

    Thomas, if we enable the line tessellation as shown above, then the SBH is converted to polylines and it is visible in the viewport. Then it seems it is also exported in the dbz, though I don’t see it imported in blender. So may it be that we just need to turn on tessellation ?

    As for commit b5c7df9 I can confirm the error is gone.

  3. Alessandro Padovani reporter

    I believe I get it. I did some tests with mohawk. Now the dforce version is imported fine, while the sbh version is not. Unfortunately dforce hair is only available to PAs, who are daz published artists. While “common” daz users can only do sbh hair.

    Please let us know if sbh may be imported by tessellation.

  4. Thomas Larsson repo owner

    Preview PR Hairs has something to do with it. If you turn it on and export the dbz file (with the updated exporter). When you import the scene into Blender, you get something that resembles the SBH in DS. It is only a mesh, and the edges are not connected into polylines, but it is a start.

  5. Alessandro Padovani reporter

    As for commit c2c07de I get an error when I try to import a tessellated sbh. Tried both my sphere test and the standard mohawk sbh.

  6. Thomas Larsson repo owner

    That bug is gone now. However, note that there are a number of pitfalls with SBH.

    1. Preview PR hairs must be enabled when the dbz file is exported.
    2. Mesh fitting must be dbz for anything to happen. The importer cannot read the data in the duf file, so all information about sbh is in the dbz file.
    3. If Strands As Hair is off, a lines-only mesh is created. This is the case that works.
    4. To make particle hair, the hair must be parented to a mesh in DS. The parent then becomes the emitter mesh. If the hair does not have a parent, a hair mesh is always created.
    5. If all conditions above a met, particle hair is generated. Alas, it is a total mess at the moment.

  7. Thomas Larsson repo owner

    And I just noticed that the sbh has a Fit To option, which could be used as emitter. Something to do tomorrow.

  8. Noname

    Thomas

    Regarding custom undocumented binary format, Qt has build in qCompress & qUncompress functionality https://doc.qt.io/qt-5/qbytearray.html#qCompress

    Just wild guess here but maybe data is qCompress → base64 ? So maybe de-base64 → qUncompress could give something useful ?

    Didn’t tried it but maybe that’s it ?

    Just my two cents.

  9. Thomas Larsson repo owner

    Thanks, but decompression is not the problem, and python also has base64 support. The problem is what to do with the binary data after decompression.

  10. Thomas Larsson repo owner

    Alessandro, some progress. After loading your test file there are several particle systems. Hair-03 is similar to what we see in DS, the others are junk which must be deleted.

  11. Noname

    Thomas

    What I meant was that maybe data is qCompress and then base64 so when You unBase64 You will end up with compressed package that needs to be decompressed using qUncomrpess. IIRC it’s deflate compression.

    Just clarification what I meant 🙂

  12. Alessandro Padovani reporter

    Commit 6b414e5 seems a very good start. Both the sphere test and mohawk work fine.

    I see multiple emitters are generated because they use different segments. Also I see the “junk” emitter to be deleted, that’s totally off scale and I wonder where it comes from. It would be nice to have resize and sparsity options the same as the mesh hair, so to get a simplified single emitter.

    As for the hair color may be we can use the hair root color in daz studio. For example the mohawk hair gets two surfaces face and torso that we can set with different colors.

  13. Alessandro Padovani reporter

    To better understand what’s happening I edited a simplified version of mohawk with a density of 2 in the sbh editor. Scene included.

    Now when we import that in blender we need to set the children to none in the emitters, since every strand is already imported. And we see that all the emitters contribute to the hair with different segments. If we hide some emitters we see that we lose hair compared to daz.

    Plus there’s one “junk” emitter Hair-02 for mohawk, that’s totally out of scale and the only one it seems we can delete. That I have no idea where it may come from.

  14. Alessandro Padovani reporter

    Commit ccbc78a is great. Tested both the sphere and mohawk. The “junk” emitter is gone. And the new hair material is very interesting. We still need to set the emitter children to none to get the same hair as daz. Also I found that if we set the tessellation to 2 in daz studio the exporter is about twice faster so this may be a good trick.

    It would be nice to have a single emitter, or one emitter per material. But again this is a great commit, if going further is too difficult I believe we may be happy with this.

  15. Thomas Larsson repo owner

    Actually, tesselation = 2 did not work correctly until now. That variable controls the number of corners of the caps of the tesselated mesh, so 2 gives a flat surface and 3 a tube with triangular cross-section. Those are the only two cases that are handled correctly.

    The number of viewport and render children has been made into a global setting, but that may be overkill. The setting is overridden if the number of children is specified in the duf file, as it often is for polyline hair, and the convert mesh to hair tool has its own setting now.

  16. Alessandro Padovani reporter

    Commit b2ea44a is very good. I noticed that the sphere example comes with one emitter, while the mohawk example comes with multiple emitters. Is this the desired behavior, and if so when do we get one or multiple emitters ?

    Also I see that in the blog you made a comparison between cycles and iray for hair rendering. Please note that iray is strongly affected by both the tessellation and the hair thickness. So to compare with cycles we need tessellation 3 and a proper hair thickness for the size of the object. Below a comparison of the sphere example with tessellation 3 and hair thickness 0.5 mm in the SBH editor.

    We can see that iray tends to be much darker than cycles as for the hair color. I am not a sbh expert so at this time I have no idea why. Indeed personally I have some difficulties managing hair colors with iray and I like the blender version better.

    Also see https://www.daz3d.com/forums/discussion/337496/

  17. Alessandro Padovani reporter

    Please Thomas let me know if multiple emitters is the intended behavior for sbh, and/or if you want to add resize and sparsity options as the geometry hair. So I’ll mark as resolved or leave this open accordingly.

  18. Thomas Larsson repo owner

    What do you mean by multiple emitters? Mohawk has only one emitter, the G8M mesh. There are multiple particle systems, though, one for each strand length, since the number of segments is fixed in a given particle system. But you know that, so maybe I don’t understand what you are getting at.

    The polyline Mohawk only has two strand lengths, 7 and 5 iirc, so I don’t understand why sbh Mohawk has many more. Can SBH have strands with a different number of sizes?

  19. Alessandro Padovani reporter

    It’s my fault since I’m new both to particles and sbh. Yes by “multiple emitters” I mean “multiple particle systems” in the simplified mohawk-sbh.duf uploaded as test. I’m wondering if you may add resize and sparsity options the same as the geometry hair so to simplify the hair to one particle system per hair material.

    As for the mohawk hair if we look at the wireframe in daz studio we see that it comes with multiple strands with different segments. I can see 5, 6, 9 and 10 in the picture but there are many so I guess the importer is fine providing one particle system per different strand segments.

  20. Alessandro Padovani reporter

    As for commit 6970ed6 that works great ! I can create sbh hair for mohawk with a single particle system by using the resize option and it works fine.

    I’m a little confused about the import options though. I mean if I don’t check any option in the global settings then I’d expect the hair to be imported as geometry, that’s strips in my case since I exported with tessellation 2 in daz studio. But it seems the hair is always imported as polylines no matter what.

    That’s absolutely fine for me as it works fine when creating hair. I’m just wondering if this is the intended behavior, and if so I don’t understand the strip and tube options in the hair creation since it’s always polylines.

    Also I may suggest to set a higher quality for viewport and rendering, so to help novice particle users (as me) getting nice hair by default. Otherwise hair looks blocky with the default blender settings, especially in the viewport.

  21. Alessandro Padovani reporter

    Then if I check the strands and postpone options it seems I get nothing on import. So it seems it works fine when I don’t check anything. As I said I’m a little confused on the options but it definitely works fine as hair creation. May be I just have to wait for the blog explanation to fully understand how it is supposed to work.

  22. Thomas Larsson repo owner

    Some partial commits were released somewhat prematurely, but now I think I got it right: https://diffeomorphic.blogspot.com/2020/11/hair-improvements.html.

    If Postpone Hair Creation is enabled, hair only appears after you do Restore Strand Hair, which must be done after geografts have been merged, see https://diffeomorphic.blogspot.com/2020/10/strand-based-hair-and-geografts.html. Alternatively, you can now import hair as lines, merge geografts, and make hair from the lines.

  23. Alessandro Padovani reporter

    Thank you for the nice explanation now it is clear how it is intended to work. It seems to me that there are many options that could be simplified though.

    1. As for the import options in the global settings, it seems to me there's no need for them. I mean, the make hair tool already handles the various cases. So the importer just needs to import what's in the duf and dbz, that will be sheets or polylines depending on the hair type.
    2. As for the make hair tool, the tube option can be avoided if we specify as requirement that the daz sbh must have tessellation = 2, that also makes sense for performance reasons. Then we could always import sbh as polylines the same as dforce hair. This makes sense since sbh in daz studio is the base for dforce hair only available to PAs, that's imported as polylines.
    3. As for pospone hair creation, again there's no need for it in my opinion. That is, we have to make hair after merging geografts because we can't modify the emitter. So it makes sense to always pospone hair creation. Also the restore strand hair tool is not needed because we can keep the hair as sheets or polylines in the scene until we make hair.
    4. With the above simplifications we only have sheets or polylines as hair type, so may be the make hair tool could identify the hair type so there's no need for the hair type options too.

    With the above simplifications the process would be:

    1. Import the daz scene, the importer will import hair as sheets or polylines by reading the information in the duf and dbz files. There are no options to import hair.
    2. Eventually after merging geografts, we can convert the imported hair to particles by using the make hair tool, the tool will auto-detect the hair type by checking the selected hair geometry.

    This may make the hair tool easier to understand and use, and may be simplify the implementation too. These are only ideas of course, as far as it works everything is good. Please Thomas let me know what you think.

  24. Alessandro Padovani reporter

    I see there’s an option for the root transparency suggested by J Cade in the daz forum, that’s a good variation for the hair material. But there’s another trick that doesn’t need to tweak the material and it’s to shape the hair with thin roots. This is suggested by Krampus in the daz forum and below there’s a variation of mine that provides a little better shape.

    https://www.daz3d.com/forums/discussion/comment/6133517/#Comment_6133517

    Default Shape.

    Thin root shape.

  25. Thomas Larsson repo owner

    Aleassandro, I agree. Now when the Make Hair tool can handle tesselated SBH and polylines, there is really no need to create hair during import. That will simplify both the UI and the code. I will make a quick commit where the hair import is disabled and hidden. Removing the actual code will take a little longer.

  26. Alessandro Padovani reporter

    Didn’t test all the cases but commit 806e73d seems to work great so far. I’ll update if I find something. It would be nice to have an option for thin roots as suggested by Krampus, or may be we can just do thin roots by default, since the standard shape doesn’t work fine anyway.

  27. Alessandro Padovani reporter

    Marking as resolved since it works for me and there are no news. Then we can always open another discussion for improvements or bugs.

  28. Log in to comment