Search Unity

Hair Designer - Dynamic hair & fur tool

Discussion in 'Assets and Asset Store' started by kalagaan, Sep 16, 2016.

  1. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    The length of the curve depends of the geometry scale factor, the initial length can be changed in the design tab.
    Most of the time you'll create the first curve and you'll duplicate it, so the initial length is not really important :p

    You can use the collider script on a existing unity collider (sphere or capsule), or you can define each sphere of the caspule.

    You can also use the "Motion constraint" to prevent some bones to move in the simulation process.
    It could be usefull to prevent some unwanted motion, or for locking some strands to a specific position.
    The motion constraint can be unlocked at runtime.
     
    Doomchecker likes this.
  2. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Did you ever make the tutorial?
     
  3. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    All the parts of the video have been recorded, now I have to edit the final version.
    It will be available soon on my youtube channel.
     
    Last edited: Jun 4, 2021
    Qleenie and wetcircuit like this.
  4. jejouelejeu

    jejouelejeu

    Joined:
    Aug 23, 2017
    Posts:
    5
    Hi there,
    I am trying to load a haircut on another version of my character using the runtime loader and it doesn't work :( A recurring error is in the console: "Object reference not set to an instance of an object".
    I integrated my two layers, target model and collider in the runtime loader but to no avail... in your documentation, it explains it very briefly with no steps and I really don't know where to go from there... Could you explain, in a more detailed manner how to load a haircut on another model?
     
  5. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    You can only use the runtime layer on the same geometry, so the 2 characters must share the same mesh.
    The runtime layers should be loaded at the start, could you send me more informations about the issue by email (contact@kalagaan.com).
    Maybe you could send me a sample scene or some screenshots of the settings.
     
  6. Syxish

    Syxish

    Joined:
    May 15, 2014
    Posts:
    1
    It currently seems that there is no way to use a texture map based on a UV layout to control fur Length and Direction. Based on what i can see, the fur length and direction is determined by the Brush Texture, which afaik, maps each pixel to a vertex by number (or am i wrong?). Pretty hard to edit that image in an outside editor

    Painting fur length and direction in Unity can be useful for fine tuning when editing in Unity, but being able to create at least the starting fur length map in an outside image editor (photoshop/gimp) would make for a better work flow for large scale productions. Especially when trying to paint length in high geo areas with sharp angles - feet, faces, etc...

    Am i just missing something? Is this a planned feature?
     
  7. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    The brush direction & length are defined per vertex, so creating a map based on UV could be misleading, because only the pixels on the position of the vertex will be used.
    So a complex map won't have any sens on low poly character, and I recommand to apply the fur on a low poly version for better performances.
    If the character use mirrored UV, the direction can't be painted properly on a map based on UV.
    I didn't planed to create a conversion tool, but I'll think about it.
     
  8. ChickenHero

    ChickenHero

    Joined:
    Jul 18, 2016
    Posts:
    79
    When GenerateLayers is called by HairDesignerUMALoader, all hairs are displayed for a moment.
    I tried m_hairDesigner.m_generators .SetActive (false) at the end of GenerateLayers, but the hair is still displayed.
    Is there a way to solve this problem?
     
  9. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    You can add this line to the GenerateLayers function :

    //Hide the latest layer added
    m_hairDesigner.m_generators[m_hairDesigner.m_generators.Count - 1].SetActive(false);


    Tested with Unity 2020.3.13, UMA 2.12
    If you still have issues, please let me know your version of unity, and I'll check it ;)

    Code (CSharp):
    1.  
    2. void GenerateLayers(UMA.UMAData data)
    3.     {
    4.         m_hairDesigner = data.GetRenderer(0).gameObject.AddComponent<HairDesigner>();
    5.         HairDesignerRuntimeLayer.m_boneNameTotransform.Clear();
    6.  
    7.         for (int l = 0; l < m_runtimeLayers.Count; ++l)
    8.         {
    9.             HairDesignerRuntimeLayer rtl = m_runtimeLayers[l];
    10.  
    11.             if (rtl == null)
    12.                 continue;
    13.  
    14.             for (int i = 0; i < rtl.m_requiredBones.Count; ++i)
    15.             {
    16.                 GameObject bone = data.GetBoneGameObject(rtl.m_requiredBones[i]);
    17.                 if (bone != null)
    18.                     HairDesignerRuntimeLayer.m_boneNameTotransform.Add(rtl.m_requiredBones[i], bone.transform);
    19.             }
    20.  
    21.        
    22.             rtl.GenerateLayers(m_hairDesigner);
    23.             //Hide the latest layer added
    24.             m_hairDesigner.m_generators[m_hairDesigner.m_generators.Count - 1].SetActive(false);
    25.         }
    26.  
    27.         HairDesignerRuntimeLayer.m_boneNameTotransform.Clear();
    28.  
    29.     }
    30.  
     
    Last edited: Jul 21, 2021
  10. ChickenHero

    ChickenHero

    Joined:
    Jul 18, 2016
    Posts:
    79
    Thank you for your reply. But it didn't work.
    However, instead of calling the GenerateLayers function with CharacterCreated.AddListener, I modified it to call GenerateLayers as a public function after CharacterUpdated and it worked.
     
    kalagaan likes this.
  11. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    109
    Hi,
    thank you so much for the long hair tutorial, the tool is getting better and better and I absolutely enjoy it.
    Nevertheless, I need some help with URP, two problems I have, maybe they are related.

    Here I have a fresh URP 10.4 Scene with Unity 2020.3.

    1)
    When I create a new Long Hair Layer, the hair is barely visible.
    upload_2021-8-23_15-54-44.png
    What I can do is playing around with the Alpha settings of the material. I get this result with those settings.
    Would you say this is the correct approach? I wouldn't mind this workaround, just wanna be sure.
    upload_2021-8-23_15-57-59.png


    2)
    The strand count in the Design tab is not working. I can change it from 1 to 50 with no difference at all.

    Maybe another hint, just to mention it:
    I have to increase bend start and bend end to ridiculously high numbers (like 50.000) for them to have any effect.
     
  12. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    1) You can increase the global scale in the design tab,
    and you should create a default texture by using the texture generator.
    A texture with more strands will increase the visibility.

    2) The strand count create more stands on the same curve,
    you'll see the variation by increasing some random factors like :
    Start offset, End Offset, Rnd seed, Rnd length

    3) The bend factor is an angle, so 90 should be visible,
    you have to increase the 'subdivision X' parameter for a better results.
    I recommand to turn on the wireframe for a better vizualisation.
     
    Doomchecker likes this.
  13. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    109
    Would you advise using the V2 Motion System LOD for long hair (since it was deprecated in V3)?

    Or would you rather use no LOD for long hair or another solution?

    Thanks!
     
  14. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    the V3 version is faster than the V2 with LOD.
    the V2 uses CPU and the V3 uses GPU.
    I'll add more optimisations in the next version ;)
    The new animation system will be also used for the next type of HairDesigner layer.
     
    Doomchecker and hopeful like this.
  15. Coyroski

    Coyroski

    Joined:
    May 19, 2020
    Posts:
    8
    Hello,

    I just bought your tool but however I can't get the Mask/Brush/Color toolbar to show up in the scene view no matter what layer type (short hair, long hair, fur, etc) I choose. I'm using Unity 2021.1.13f1.
     
  16. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    Did you activate the 'gizmos' button in the scene view?
     
  17. Coyroski

    Coyroski

    Joined:
    May 19, 2020
    Posts:
    8
    Thank you, that fixed it.

    Also, how do I activate Motion system v2/v3? I would like to add some wind effects into my model however in the Motion tab I don't see any options to change it.
     
  18. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    You have to set a windzone to the HairDesigner component (at the bottom of the editor)
    the wind parameter will be modified by the parameters in the motion tab.
     
  19. Coyroski

    Coyroski

    Joined:
    May 19, 2020
    Posts:
    8
    I'll give that a shot, thank you very much for the help!
     
  20. Coyroski

    Coyroski

    Joined:
    May 19, 2020
    Posts:
    8
    Hello again,

    Sorry for all the questions but I'm starting to get the hang of the tool and I'm really liking the results so far!

    Is it possible to use a Main Texture/Diffuse like in the Fur layer type but for Short hair/fur or Long hair layer type? So instead of manually specifying the stand color, it would get it from the texture instead?

    I had a look at the documentation and the Advanced fur layer type has results I'm after but setting the graphics API in the player settings to DX11, the button is still greyed out. (I'm guessing it's because I'm on HDRP?)
     

    Attached Files:

  21. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    No, sorry, the 'Long Hair' and 'Short Hair' layers don't use a texure color as input.
    And the Advanced Fur is only available for the built-in RP. :(

    I'm working on a new layer type, that will be a mix between the advanced fur and the long hair layer.
    That will be a full procedural rendering system using only GPU (simulation & rendering).
     
    Coyroski likes this.
  22. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    hey, would be cool for next update to have an optimization for m_needMeshRebuild
    like reduce GC and calculate across number of frames instead of one to reduce cpu usage (configurable maybe ? :)
     
  23. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    This should be used only in editor mode, not at runtime.
    Could you send me an email (contact@kalagaan.com) with your usecase?
     
    Last edited: Sep 8, 2021
  24. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    868
    Hey, I have a question regarding the created meshes (for short hair); it seems that it is being stored as part of the scene asset? Is there a way to export it as a regular mesh asset and load / reference from there? Scene files are getting pretty big, and the internal reference has some weird side effects.
     
  25. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    yes, there's different ways to do it

    1) you can lock the layers, then you'll be able to save the layers in a file.
    It will generate the mesh references for all the layers in a project folder.

    2) you can export the layer as a runtime layer, all the data (and the mesh) will be stored in a prefab.
     
    Last edited: Sep 8, 2021
  26. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    868
    Hey, thanks, I did go with 1); however, the size of the scene assets stays same size, seems liek the meshes are still part of it ?
     
  27. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    I did some tests and the scene size decrease when the reference is saved in the project.
    What is your version of Unity and HairDesigner?
     
  28. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    It alright, I can manage without it

    I'm using the URP version and seems to be a problem with changing hair colors?
    after calling GenerateLayers(hairDesigner);
    it creates the hair
    but the color doesn't change ?

    Code (CSharp):
    1.         HairDesignerShaderURP_Atlas shader = hairDesigner.GetLayer(0).GetShaderParams() as HairDesignerShaderURP_Atlas;
    2.         shader.m_tipColor = Color.red;
    3.         shader.m_rootColor = Color.red;
    4.         hairDesigner.GetLayer(0).m_shaderNeedUpdate = true;
    it seems correct but not working, what I'm missing ?
     
  29. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    868
    I use lastest LTS (2020.3.17), for Hair Designer I don't find a readme, but package manager says 1.10.1.
     
    Last edited: Sep 9, 2021
  30. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    I did a quick test and it works.
    Here the full script :

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Kalagaan.HairDesignerExtension;
    5.  
    6. public class TestAPI : MonoBehaviour
    7. {
    8.  
    9.     HairDesigner hairDesigner;
    10.  
    11.    
    12.     void Start()
    13.     {
    14.         hairDesigner = GetComponent<HairDesigner>();
    15.     }
    16.    
    17.     void Update()
    18.     {
    19.         HairDesignerShaderURP_Atlas shader = hairDesigner.GetLayer(0).GetShaderParams() as HairDesignerShaderURP_Atlas;
    20.         shader.m_tipColor = Color.red;
    21.         shader.m_rootColor = Color.red;
    22.         hairDesigner.GetLayer(0).m_shaderNeedUpdate = true;
    23.     }
    24. }
    25.  
    Could you send me your script (contact@kalagaan.com)
    Maybe there's something wrong in the full process.
     
  31. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    I did some test using the Haircut demo scene, and the size change if the layer are saved into the project.
    Could you send me a sample package with the problem? (contact@kalagaan.com)
    I could check it.

    You could also try to use a specific scene for generating the HairDesigner layers, then export the haircuts as a runtime layer, and load them using a script in your game scene.
     
  32. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    this bug only occurs after generating runtime layer (HairLayers.GenerateLayers(hairDesigner))
    it does change color if you wait for few secs after generating
     
  33. ciorbyn

    ciorbyn

    Joined:
    Oct 17, 2013
    Posts:
    138
    Intersting tool... Does it only work in the editor or is it possible to draw in play mode too?
     
  34. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    If you try to change the settings on start, the initialization of HairDesigner is not properly done.
    You have to call the modifications on Late Update :


    Code (CSharp):
    1.  
    2. public void LateUpdate()
    3.         {
    4.             HairDesignerGenerator g = m_target.GetLayer(1);
    5.             if (g != null)
    6.             {
    7.                 HairDesignerShaderURP_Atlas shader = g.GetShaderParams() as HairDesignerShaderURP_Atlas;
    8.                 shader.m_tipColor = Color.blue;
    9.                 shader.m_rootColor = Color.yellow;
    10.                 g.m_shaderNeedUpdate = true;
    11.             }
    12.         }
     
  35. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    The fur systems are based on textures, so you can edit them at runtime if you create the tools for modifing the textures.

    For the short hair and long hair layers (geometry haircards), the paint tools are based in editor,
    so you'll have to rewrite the edition tools for runtime, not so easy...
     
  36. heartdub_gls

    heartdub_gls

    Joined:
    Sep 9, 2021
    Posts:
    4
    Hi, I need help. After switching between Design and Material in the hair editing panel, there was a strange error in the adjustment of Specular in Material, and the adjustment of Smoothness was abnormal and invalid. The version I used is 2020.3.11 HDRP.
     

    Attached Files:

    Last edited: Sep 15, 2021
  37. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    The specular looks like it should be with these settings.
    You could decrease "Smoothness 1" for a wider range and decreasing intensity.
    you should also decrease the specular intensity using the alpha value of "Specular color 1"
     
  38. heartdub_gls

    heartdub_gls

    Joined:
    Sep 9, 2021
    Posts:
    4
    Thank you for your reply, but this is not the case. When I opened the demo for the first time, all parameters in Specular were displayed normally, but when I clicked "Design" and returned to "Material", the Specular adjustment was obviously abnormal. I recorded a video for you. You can have a look.
     

    Attached Files:

    • hair.7z
      File size:
      7.9 MB
      Views:
      328
  39. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    Thank you for the feedback,
    this is a bug, the mesh data are not build properly. :confused:
    The original mesh was done with a previous version, that's why there's a modification of the specular effect.
    It will be fixed in the next version.;)

    If you want a fix before the next release,
    please send me an email (contact@kalagaan.com) with your invoice number
     
  40. heartdub_gls

    heartdub_gls

    Joined:
    Sep 9, 2021
    Posts:
    4
    This plug-in was shared to me by my friend, so I don't know the invoice number. It doesn't matter, I'm looking forward to your next update. Thank you again for your patience in answering my question.;)
     
  41. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    It matters...
    You can't share paid assets bought on the assetstore, that's just called piracy.

    Most of the assetstore dev are working hard for creating stuff, sharing their work for free is just a way to make them stop.

    Asking for help without a licence and saying on the forum that it "doesn't matter" is really disrespectful.
    You have to buy your own version if you want to use it.
     
  42. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    WIP
    Now the strand system is compatible with shader graph (HDRP)



    Still a lot of work, but it's a big step :)
     
    Last edited: Sep 19, 2021
    XthemeCore and wetcircuit like this.
  43. heartdub_gls

    heartdub_gls

    Joined:
    Sep 9, 2021
    Posts:
    4
    I'm really sorry, I just want to confirm whether the plug-in can be used normally in the work. This is just a test to avoid unnecessary trouble. If the plug-in can be used perfectly in the work, I will buy it. I'm terribly sorry for my rudeness.:(
     
  44. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
  45. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    WOW! I have questions! :cool: … it looks like soooo many strands!

    Any limits on this new type of hair? render pipelines or anything?
     
  46. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    The limit is the GPU capability, but all is procedural, so it's easy to use LOD.
    There's also a balance between the number of physics strands and 'children'.
    The children are driven by the physics strands (force simulation + collisions)

    I'm adding more parameters to the strand system, and I'll try to add per strand settings, so it would be possible to change color or a curl parameter for some parts of the haircut.

    It works on built-in RP and HDRP.
    I'll do a a URP version, I have to test if the system is also compatible with shadergraph for URP.
    It doesn't require DX11 so it could work on any platform, but I didn't test it on mobile yet.
     
    Last edited: Sep 24, 2021
    Rotary-Heart, hopeful and wetcircuit like this.
  47. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    WIP strand collisions
    Basic test

     
  48. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    WIP : no gravity test
     
    hopeful and Rotary-Heart like this.
  49. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    :eek::cool::eek::cool::eek:

    Is curly hair possible?
     
    hopeful likes this.
  50. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    Here a simple version, I'll improve the shape ;)

     
    hopeful, XthemeCore and Rotary-Heart like this.