Strand Based Hair Vertex Info?

Hi all,

I just exporter a character with the new Elven Lord as OBJ, and the hair is exported as polylines, which is to be expected.

I am trying to access this polyline information, but the new SDK has no additional geometry classes for polylines; all the geometry is still represented by DzFacetMesh. But I notice that nodes that are hair strands have many vertices and 0 faces.

But the question remains: Given an array of vertices, how does one interpret it as one or more polylines? There's a suspicious new function

unsigned char *DzVertexMesh::getVertexFlagsPtr();

That I suspect holds the key, but there's no meaningful documentation as to what the bits mean.

Can anyone shed some light on how to output the vertices that make up the hair strands?

Thanks!

 

Comments

  • Seven193Seven193 Posts: 1,080
    edited November 2020

    When you switch to iRay rendering mode in the preview window, strand-based hair doesn't even show up.  It only shows up when the scene is finally rendered.  So that would mean, there's nothing to export.

    I guess you would have to read the strand-based hair tree list parameters, and interpret them yourself, which is beyond complex.

    There's a new node called DzStrandHairNode, but since the SDK hasn't been updated in years, there's no API to access it.

     

    Post edited by Seven193 on
  • TheMysteryIsThePointTheMysteryIsThePoint Posts: 2,946
    edited November 2020
    Seven193 said:

    I don't think strand-based hair geometry (vertices or faces) even exists in the Geometry Cache.

    When you switch to iRay rendering mode in the preview window, strand-based hair doesn't even show up.  It only shows up when the scene is finally rendered, so I would assume the strands are generated on the GPU?  So that would mean, there's nothing to export.

    I guess you would have to read the strand-based hair tree list parameters, and interpret them yourself, which is beyond complex.

    There's a new node called DzStrandHairNode, but since the SDK hasn't been updated in years, there's no API to access it.

     

    @Seven193

    Thanks for that info. But if that class was not in the recent SDK update, and Google returns 0 hits, may I ask how you knew about it? If there is another source for SDK information, I would really live to tap into it. This is beyond frustrating.

    I did some research a while ago, and I think it is in the various duf resource files; I didn't work out how to go from a node name to vertex data, though, because I felt there *must* be an easier way.

    Thanks again.

    Post edited by TheMysteryIsThePoint on
  • Seven193Seven193 Posts: 1,080
    edited November 2020

    What recent SDK update are you referring to?

    This is the C++ SDK:
    https://www.daz3d.com/daz-studio-4-5-sdk

    It has always been at v4.5, and has never been updated in over 8 years.

     

    Thanks for that info. But if that class was not in the recent SDK update, and Google returns 0 hits, may I ask how you knew about it?

    Nodes have a property called className(), which returns a string name.  But, somebody needs to update the SDK to include DzStrandHairNode.h, otherwise, we have no API to access it.

    Post edited by Seven193 on
  • Seven193 said:

    What recent SDK update are you referring to?

    This is the C++ SDK:
    https://www.daz3d.com/daz-studio-4-5-sdk

    It has always been at v4.5, and has never been updated in over 8 years.

    It was updated a few months ago; my files are dated 8/31/2020. A few things were added, the uic and rcc compilers are included now, and some typos and minor conventions were fixed.

    Seven193 said:

     

    Thanks for that info. But if that class was not in the recent SDK update, and Google returns 0 hits, may I ask how you knew about it?

    Nodes have a property called className(), which returns a string name.  But, somebody needs to update the SDK to include DzStrandHairNode.h, otherwise, we have no API to access it.  But, if it doesn't provide methods to generate geometry from strands, then that will be of no help either.

    Ah, I forgot about className(). But unless Daz forgot to strip debugging symbols, it's of absolutely no use :)

    I'm finding that more and more things are not accessible via the SDK, for the reasons you point out, but can still be piece together from the DSON, which is self-documenting to a certain degree. That's been my approach on several occasions.

  • Seven193Seven193 Posts: 1,080
    edited November 2020

    I've haven't looked at code in a long time, but if DzStrandHairNode is based on DzGeometry, you could try casting it to DzGeometry to access its geometry cache, if it has any.  Just a long shot I guess.

    Post edited by Seven193 on
  • Seven193 said:

    I've haven't looked at code in a long time, but if DzStrandHairNode is based on DzGeometry, you could try casting it to DzGeometry to access its geometry cache, if it has any.  Just a long shot I guess.

    Yes, dynamic_cast<DzGeometry*>() was the first thing I tried, and I tried just about everything. In all cases, the vertex data did not come back as what I expected. I gave up and started digging through the DSON and convinced myself that everything is in there, one just has to figure out how it all links together. That's certainly sub-optimal, but at least the DSON is human readable.

    Thanks again for the empathy, if nothing else :)

  • Seven193Seven193 Posts: 1,080
    edited November 2020

    I created a sphere primitive, applied a strand base hair node to it, and tried to export it, but FBX exporter shows zero polygons. 

    So, Daz Studio's own plugins can't find strand geometry either.

    Maybe if you report it as a bug/feature, "can't export strand based hair as polylines", someone might eventually add it.

     

    https://i.imgur.com/LluWlSj.png

    Post edited by Seven193 on
  • That's interesting. I saw no faces, but I did see vertices. It is not encouraging that different tools get different answers. I think I will file a ticket just for laughs. I'm sure in typical Daz style I'll be completely ignored, but at least it only takes a second.

    Thanks for your experiment and suggestion.

  • Seven193Seven193 Posts: 1,080
    edited November 2020

    FBX format supports polylines with FbxLine() class:

    FbxNode* lpNode = FbxNode::Create( pManager, "node" );FbxLine* lpLine = FbxLine::Create( pManager, "polyline" );lpNode-&gt;SetNodeAttribute( lpLine );

     

    Wavefront OBJ format supports polylines with 'l' tag:

    l v1 v2 v3 v4 v5 v6 ...

     

    So, they can't argue polyline export is not supported, because it's there if they want to use it.

     

    Post edited by Seven193 on
  • Seven193 said:

    FBX format supports polylines with FbxLine() class:

    FBX format supports polylines with FbxLine() class:FbxNode* lpNode = FbxNode::Create( pManager, "node" );FbxLine* lpLine = FbxLine::Create( pManager, "polyline" );lpNode-&gt;SetNodeAttribute( lpLine );

     

    Wavefront OBJ format supports polylines with 'l' tag:

    l v1 v2 v3 v4 v5 v6 ...

     

    So, they can't argue polyline export is not supported, because it's there if they want to use it.

     

    Yes, and Alembic supports it with the ICurvesSchema interface. There's no excuse, but yet here we are :(

  • I know nothing about development etc but it is probably related to them wanting to keep the Dforced Strandhair PA only, it might reveal too much info

    is a shame as it could be used for grooms in Unreal if developers had more information

  • Seven193Seven193 Posts: 1,080
    edited November 2020

    I think it's something more basic, like they might have to modify the SDK, so it recognizes polylines.  The SDK only recognizes triangles and quads, which belong to a poly mesh.  Is a polyline defined as a mesh? I don't know.. They could probably throw it in dzface.h as a hack:

    	bool	isQuad() const { return (m_vertIdx[3] &gt;= 0); }	bool	isTri() const { return (m_vertIdx[3] &lt; 0); }	bool	isLine() const { return (m_vertIdx[2] &lt; 0); }

     


    For Daz to create an interface for the sole purpose of exporting polylines outside of Daz Studio is probably not going to happen.

     

    Post edited by Seven193 on
  • Seven193Seven193 Posts: 1,080
    edited November 2020

    After searching for this answer in the forums, "Why doesn't strand hair show up in iRay preview?", I finally got strands exported!

    First of all, you must get the strands visible in iRay preview, otherwise the geometry cache isn't being generated.  Click on your strand based hair object, under Parameters -> Line Tessellation, and set Preview PR Hairs to On (if it's set to Off).

    Render Line Tessellation Sides is parameter you can use to increase the detail of the hair.  For example, if it's set to 3, the hair strand will be exported as a 3-sided quad cylinder. Increase the number to increase the sides of the cylinder even more.  For this small patch of hair, a setting of 3 nearly generated 100k polys, so this can easily go above a million polys if not careful.

    So, strand hairs are exported as uncapped quad cylinders, not polylines.  And they can be exported through the usual means, like FBX or OBJ. Another interesting thing, is that these quad strands are UV mapped, so if you wanted to apply color bands or a gradient alpha channel map to them, that should work.

     https://i.imgur.com/l6QG9u5.png

    Post edited by Seven193 on
  • @Seven193 You are a hero. I mean it.

    Are both ends of the strand uncapped, or are they ordered? I.e. is there a reliable method to know which end of the strand is the root end?

    That would be trivial to convert to a Blender particle system.

  • Seven193Seven193 Posts: 1,080
    edited November 2020

    @Seven193 You are a hero. I mean it.

    Are both ends of the strand uncapped, or are they ordered? I.e. is there a reliable method to know which end of the strand is the root end?

    That would be trivial to convert to a Blender particle system.

    They're all UV mapped the same way, so you could use their UV coordinates to infer the 'root' vertex position.  Say, if u=0 or v=0, then that vertex is root  Likewise, if u=1 or v=1, that vertex is the other end the strand, as UV space appears to be normalized.  Those two might be flipped around, so you'll have to test it.

     

    Post edited by Seven193 on
  • Seven193 said:

    @Seven193 You are a hero. I mean it.

    Are both ends of the strand uncapped, or are they ordered? I.e. is there a reliable method to know which end of the strand is the root end?

    That would be trivial to convert to a Blender particle system.

    They're all UV mapped the same way, so you could use their UV coordinates to infer the 'root' vertex position.  Say, if u=0 or v=0, then that vertex is root.

    Brilliant. Thank you so much.

Sign In or Register to comment.