Jump to content

[Fixed] Computer generated Matrix Weights / Indices


JCPalmer
 Share

Recommended Posts

I am continuing my work on Particle Hair.  I can transfer vertices without faces in Tower of Babel.  See:

hair.jpg.58463ef887c1d2d745b77947a8436089.jpg

Matrix weights / indices are not really capture-able, so I am just trying to generate them.  If they need to be generated, might as well do it in Javascript vs Python and save the transfer bandwidth.

I was not going to get real fancy with the number of influencers, just 1.  As soon as I add the skeleton, the Hair (LinesMesh) dis-appears.  I added both vertex colors & skeletons to LinesMesh for 3.0.  I really wanted to get this working prior to 3.0 production.

I could just be having a mental block, so I tried to do the simplest playground scene.  If you change the if (1 === 0) to if(1 === 1), it also disappears.  Any clues?

Link to comment
Share on other sites

@Borislav, it is not even combed yet!  My objective is for the LineMesh to simply stay with the rest of the body.  Parenting to body will keep it at the same origin as body if body position or rotation changes. If the head turns, or knees bend,  the hair will not move along with it without also using the skeleton.

For head turning purposes, I am specifying a stiffness factor.  If you said, 0.5 & a strand had 5 segments (6 vertices):  Then the weights from scalp out would be: 1.0, 0.9, 0.8, 0.7, 0.6, & 0.5.  Having a lower value at the end means it would not rotate as much.  This is really needed for longer hair, or the hair would cut through the body when turning.

With my hero, checking on what might be wrong, I moved ahead, & have finally figured out how to add a custom panel onto particle properties tab.  Took me all day & part of yesterday to figure out.  Nobody must be doing this, Googling will not get you even a close answer.  May try to add more control (color, patterns), if I get what I got now to run:

hairSettings.jpg.d58033e9977dda40f3d41e42c81583fd.jpg

Kind of disagree about the high end pc comment.  This is a single mesh, so single draw.  No texture, so very simple fragment shader.  Vertices / segments are removed during export using Limited Dissolve operation.  Oh yeah, might add degree control for the dissolve in UI.

Link to comment
Share on other sites

14 minutes ago, JCPalmer said:

@Borislav, it is not even combed yet!  My objective is for the LineMesh to simply stay with the rest of the body.  Parenting to body will keep it at the same origin as body if body position or rotation changes. If the head turns, or knees bend,  the hair will not move along with it without also using the skeleton.

For head turning purposes, I am specifying a stiffness factor.  If you said, 0.5 & a strand had 5 segments (6 vertices):  Then the weights from scalp out would be: 1.0, 0.9, 0.8, 0.7, 0.6, & 0.5.  Having a lower value at the end means it would not rotate as much.  This is really needed for longer hair, or the hair would cut through the body when turning.

With my hero, checking on what might be wrong, I moved ahead, & have finally figured out how to add a custom panel onto particle properties tab.  Took me all day & part of yesterday to figure out.  Nobody must be doing this, Googling will not get you even a close answer.  May try to add more control (color, patterns), if I get what I got now to run:

hairSettings.jpg.d58033e9977dda40f3d41e42c81583fd.jpg

Kind of disagree about the high end pc comment.  This is a single mesh, so single draw.  No texture, so very simple fragment shader.  Vertices / segments are removed during export using Limited Dissolve operation.  Oh yeah, might add degree control for the dissolve in UI.

 

That is very complicated :/.

Link to comment
Share on other sites

It is not directly in the LinesMesh class itself.  The Geo is in Mesh.  The material, ShaderMaterial, assigns matrix weights indices & number of influencers attributes (I stole what Sebavan did for HighlightLayer.isReady).  The Color.vertex.fx got stuff added for bones at the same time as vertex colors.  This is the PR.

I probably have messed something up.  At least with this Playground that looks like it should be a valid test, it might be debugged without dragging my massive generated data.

Link to comment
Share on other sites

Actually, now I am remembering from the very end of how far I got in my initial push in April.  After I went thru all the changes to all those files, I realized that LinesMesh was mostly a "glue job" of other pieces.  It could actually be made with BABYLON.Mesh & a standard material.

You commented that the fragment shader of StandardMaterial might not be as efficient, I think.  There are also other reasons for ShaderMaterial to be able to use skeletons, not just Lines.

If you could figure out what I got wrong,  I think I am going to refactor my QI.Hair class to inherit from QI.Mesh not BABYLON.LinesMesh.  Still use ShaderMaterial.  Then I might be able to computer generate shapekeys for bounce up, it the character is running or something.  LinesMesh could use the 3.0 morph facility, but I would not to mix the 2 different methods.

Link to comment
Share on other sites

Complete success when stiffness is set to 1.0. The example shown in first post looks like a brush head firmly stuck on the head as the character moves.  I need to work to verify that this strategy of limpness works for long hair works as head turns.  That is at my level though, not framework.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...