Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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,487
    The HDRP shader has a specific alpha panel, you can play with the parameters for creating finner strands.
    Root & Tip colors are a part of the settings, the 'alpha density' increase the visibility of the 'middle' of the strand.
     
    Last edited: Feb 4, 2020
  2. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    585
    I am unable to change the hair color. I do change it everywhere I could find some color, but it doesn't have any effect.
    However, I have noticed an error message (here is a video about it:
    )
    Here is a screenshot:
    hair1.png
    How would I go on about fixing this?
    And what is the difference between Colors in the Texture Generator and in the Material->Colors tab?
     
    Last edited: Feb 5, 2020
  3. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    The texture color is black, you have to set it to white if you want to modify it in the shader (Material tab).
    FinalColor = TextureColor*ShaderColor

    You have to unpack the prefab for modifications.
     
  4. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    Wow… those pics are fantastic. We definitely need a braid option, even if it's just in the material.

    Would anyone else be interested in a Discord where we could share these resources and show our own efforts?
    (is there one already?)
    I'd be interested whether it is tool-specific or general info… Sometimes tool-specific can be limiting.
     
  5. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
  6. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    Yes, the braid generator is an important feature, I'll try to speed up the dev.
     
    GCatz and wetcircuit like this.
  7. Hungry-Lion

    Hungry-Lion

    Joined:
    Sep 2, 2018
    Posts:
    21
    Hi, I want to ask about effieciency, trigon cost.

    How much for a character full of fur on average graphical quality?
     
    Last edited: Feb 13, 2020
  8. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    The polycount depends of technic (type of layer) you choose and the way you use it.
    It could be very different according to the original mesh.

    Short hair & long hair : you control the polycount with the subdivision settings and the number of hair cards you draw.

    Fur (shell) : The original mesh should be low poly for better performances, the number of shells can be defined by the LOD system.

    Advanced Fur (DX11) : The shader generates the strands in a geometry shader, you can control the density and the strand subdivisions. It requires a DX11 compatilbe GPU.

    The balance between the final design and the performances is defined by the user.
     
  9. zunshiro

    zunshiro

    Joined:
    Jan 29, 2019
    Posts:
    1
    Draw order not working correctly when use more than one object.



     
  10. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    736
    @kalagaan Hi, I updated to new version; somehow I am not able to switch layers anymore, due to probably some change of protection level.
    My code:

    Code (CSharp):
    1. public HairDesigner m_hair;
    2.  
    3. ...
    4.  
    5. m_hair.GetLayer(currentLayer).m_enable = true;
    Somehow, m_enable is now protected. There seems to be now an Enable() and Disable() method, but these are not working for me, so now I am not able to switch the layer anymore during runtime. Can you help ?
     
  11. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    The API has changed, you have to use :
    Code (CSharp):
    1. m_hd.GetLayer(currentLayer).SetActive(true)
     
  12. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    736
    Thank you very much! Already find out by trying;) But you are just too fast in responding;)
     
    kalagaan likes this.
  13. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    @kalagaan Remember when I promise you the recursive hair shader, the one that would have infinite strand based on a single polygon. Well here is the base:

    Code (CSharp):
    1. Hairtech flat only
    2.  
    3. [code]
    4. #define DARKEN_OVER_DISTANCE 1  // This makes it easier to see the different layers in a static image, not to hide a max distance.
    5. #define SHOW_2D_SHAPE        1  // This makes the 2d shape be shown in upper left corner
    6.  
    7. const float c_camearaDistance    = 6.0;
    8. const float c_cameraViewWidth    = 24.0;
    9.  
    10. //============================================================
    11. //============================================================
    12. bool BooleanFunction_Square (vec2 current)
    13. {
    14.     return (current.x < 0.25 || current.x > 0.75 || current.x < 0.25 || current.x > 0.75);
    15. }
    16.  
    17. //============================================================
    18. float NumberStepsFunction_Square (vec2 current, vec2 stepValue)
    19. {
    20.     // if it's already in the shape, no steps to take
    21.     if (BooleanFunction_Square(current))
    22.         return 0.0;
    23.    
    24.     float stepsX;
    25.     if (stepValue.x < 0.0)
    26.         stepsX = (current.x - 0.25) / -stepValue.x;
    27.     else
    28.         stepsX = (0.75 - current.x) / stepValue.x;
    29.  
    30.    
    31.     return ceil(stepsX);
    32. }
    33.  
    34.  
    35. //============================================================
    36. void mainImage( out vec4 fragColor, in vec2 fragCoord )
    37. {  
    38.     // set up the camera
    39.     vec3 cameraPos;
    40.     vec3 rayDir;
    41.  
    42.     {
    43.         vec2 percent = (fragCoord / iResolution.xy) - vec2(0.5,0.5);
    44.         vec3 offset = vec3(0.5, 0.5, iTime+0.01);
    45.  
    46.         float angleX = 0.0;
    47.         float angleY = 0.0;
    48.  
    49.         if (iMouse.z > 0.0) {
    50.             vec2 mouse = iMouse.xy / iResolution.xy;
    51.             angleX = 3.14 + 6.28 * mouse.x;
    52.             angleY = (mouse.y - 0.5) * 3.14;//(mouse.y * 3.90) - 0.4;
    53.         }
    54.  
    55.         vec3 cameraFwd    = (vec3(sin(angleX)*cos(angleY), sin(angleY), cos(angleX)*cos(angleY)));          
    56.         vec3 cameraRight = normalize(cross(vec3(0.0,1.0,0.0),cameraFwd));
    57.         vec3 cameraUp = normalize(cross(cameraFwd, cameraRight));
    58.  
    59.         cameraPos = vec3(0.0, 0.0, -1.0) + offset;
    60.         vec3 cameraTarget = vec3(0.0, 0.0, 0.0) + offset;
    61.  
    62.         float cameraViewHeight    = c_cameraViewWidth * iResolution.y / iResolution.x;
    63.         vec3 rayTarget = cameraPos +  cameraFwd * c_cameraDistance + cameraRight * c_cameraViewWidth * percent.x + cameraUp * cameraViewHeight * percent.y;
    64.         rayDir = normalize(rayTarget - cameraPos);
    65.     }
    66.  
    67.     // keep the camera in a unit cube
    68.     cameraPos = fract(cameraPos);  
    69.    
    70.     // If ray facing negative on z axis, just flip direction and invert where we are in the cube on the z axis.
    71.     // Now we only have to deal with positive z directions.
    72.     if (rayDir.z < 0.0) {
    73.         rayDir *= -1.0;
    74.         cameraPos.z = 1.0 - cameraPos.z;
    75.     }
    76.        
    77.     // calculate the 3d position of the next two plane intersections
    78.     float intersection1Distance = (1.0 - cameraPos.z) / rayDir.z;
    79.     float intersection2Distance = (2.0 - cameraPos.z) / rayDir.z;
    80.     vec3 intersection1 = fract(cameraPos + rayDir * intersection1Distance);
    81.     vec3 intersection2 = fract(cameraPos + rayDir * intersection2Distance);
    82.    
    83.     // Calculate how much the uv changes from intersection1 to intersection2.
    84.     // Convert it from [0,1] to [-0.5, 0.5].
    85.     // We need to know this to know if the uvs are going positive or negative and by how much, on each axis.
    86.     vec2 uvStep = intersection2.xy - intersection1.xy;
    87.     uvStep = fract(uvStep + 0.5) - 0.5;
    88.          
    89.     // calculate how many steps it takes to hit something on the X and Y axis and take whichever hits first.
    90.     float steps = 0.0;
    91.     steps = NumberStepsFunction_Square(intersection1.xy, uvStep);
    92.  
    93.     // calculate how far it is to the intersection we found
    94.     float dist = (1.0 - cameraPos.z) / rayDir.z + steps / rayDir.z;
    95.    
    96.     #if DARKEN_OVER_DISTANCE
    97.     float tint = clamp(1.0 - dist / 5.0, 0.0, 1.0);
    98.     #else
    99.     float tint = 1.0;
    100.     #endif
    101.    
    102.     // calculate the hit point
    103.     vec3 hitPoint = cameraPos + rayDir * dist;
    104.     vec2 uv = hitPoint.xy;
    105.    
    106.     // sample the texture
    107.     fragColor = vec4(texture(iChannel0, uv).rgb * tint, 1.0);  
    108. }
    109.  
    from
    https://www.shadertoy.com/view/MlK3zt[/code]

    It took me that long only because I tried to find a generalized version with curls too, those damn elusive CURLS still evade me!

    This basis could have been done day one if I wasn't stubborn, I let you translate it in proper shader format. But basically you can discard depth you don't need to get the thickness you want. Since you can position the camera in the lattice, you can emulate fur by slanting it. It has limitation as everything is just a big square, but it does give the parallax needed by tweaking the distance parameters. It should be a good replacement for shell techniques too. It can be used to complexify simple cards by adding fake parallax thickness, and let the card manage the complexity of shapes. Baking parameter and UV manipulation can help break the repetitive pattern of parallel. Casting rays with different stepping parameter, in a single pixel position, to mix up and break further the pattern.

    Things to look for as research:
    - "free" translucence absorption by computing the "infinite overdraw", basically there should be a way to compute how many strand overlap mathematically up to a certain distance after first it (ie the number of step before it exit the surface (as each step is a depth jump), then reenter the next, since it's regular you can just find how much it repeat in the thickness you design before discarding).
    - if we can do other shape (circle) and have very low distance between plane, then find a way to change the width of the shape progressively with depth (widening), we effectively emulate an infinite shell method, but without the geometric cost.
    - Using the width of the strand to have cylinder like normal, ie distance from center of the strand as a cos().

    I'm also trying to find a generalize way to raytracing in wrapping space for any primitive volume, not just flat band, and without the modulo trick (create artefact for complex shapes). Triangle would make better grass (and would allow to compensate side stretching by sloping in the inverse of the stretch). Cylinder would do better for hair silhouette.

    I'm still looking for the curl though, two step, one intersecting cylinder, then trace on the surface of a cylinder.
     
  14. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    Thank you for the reference. :)

    I'm not sure how this could be used. Maybe I missed something, but the function is limited to simple shapes and you can't do a cutout without sampling the fur height texture for each 'layer'. :confused:
    Maybe I'm wrong but I think that regular way to calculate a parallax would work better for fur.

    I'm currently working on a Raymarching system for ShaderGraph, I'll try to find a way to create a sdf fur without killing the GPU. :p
     
  15. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    Yeah it has some limit, it's a tool to help add some pizzaz, originally it was looking for it for low spec, so you had simple density not limited by polygon, a lot can be bake into constant too.

    Since it's analytical all you need is to crank up the number for free. Like use small space tiling, small delta between planes, and you the big thing is using the uv direction like a flow map to get the most of the effecy and break the simplicity of the shape.

    On bigger hardware it's probably more of a lod system, there is no more vertices to upload.

    What do you mean exactly there?
     
  16. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    The the way to check the 'depth' is based on the shape, so using a fur density for the height won't work in that case.
     
  17. VirtusH

    VirtusH

    Joined:
    Aug 18, 2015
    Posts:
    91
    Hi Kalagaan! We were considering purchasing this hair and fur asset, but we have technical requirements. I was hoping you could let me know how your asset might work for us before we buy it.

    We need animals in our game to 'grow', we currently do so by fading between textures and scaling the model and bones. Further I see you support fur on skinned renderers, but we need know how mesh scaling, bone scaling and blend shapes all together would work with your fur system. In addition to fading between base color textures dynamically, we need to be able to control visual parameters like gloss/spec/metallic to achieve a wet look. Finally, we would want the animals themselves to use our own custom shader, and run the fur on top to produce the final result.

    We're also thinking about switching to HDRP. I've read there's some support for that, but what could we expect exactly?

    Is this all together doable with your asset?
     
    Last edited: Mar 10, 2020
  18. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    Hi,
    There's 3 ways for creating fur in hairDesigner.
    - Short hair (geometry painted on the initial model)
    - Fur shells generated at real time
    - DX11 geometry shader

    All these technics are compatible with bone modifications and blendshapes.
    HairDesigner generate its own meshes, the original character is not modified.

    The main script of hairDesigner controls the shader properties with a specific script for each shader, you can easily modify many parameters : fur length, textures, colors, smoothness, AO, emission...
    You can easily override the shader controller to include your own shader in the system if you want to add some specific shader options.

    Short hair & shells are compatible with HDRP, but the DX11 layer is not yet supported.
    The HDRP versions are made with shadergraph, so you can easily modify the shaders if you need to.
     
    Last edited: Mar 11, 2020
  19. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    585
    I just wanted to post my current results with hair and fur designer.

    One important note: Directional light should have setting "Shadow Map" enabled!

    2.png
     
    Last edited: Mar 12, 2020
  20. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    281
    there really should be a way to share hairs
     
  21. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    The problem is that the final hair mesh is generated with the original mesh data, it includes the skinning and blendshapes.
    I'll try to find a way to retarget the haircuts, maybe it could be easier with a generic head mesh.
    But I don't think that it would work with complex mesh.
     
  22. Ukounu

    Ukounu

    Joined:
    Nov 2, 2019
    Posts:
    206
    Are you people even aware what "spam bot" is? It crawls through threads in online forums, takes a few keywords used in conversation ("hairstyle", "hair", "textures"), and then uses a neural network to generate a pseudo-relevant reply, while inserting a spam link to advertised website.
    The bot made a similar post in another thread, so I clicked on its profile to find more posts. And it looks like these bots have about the same IQ already as an average Unity developer, since you guys kept talking to it without noticing anything. Humanity is doomed. Reported. :confused:
     
    Last edited: Mar 25, 2020
  23. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    LOL do you even own this plugin?

    Why are you so wounded?
     
  24. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    I don't know if it's a bot, the link was interesting, so don't care...:p
     
    EmagineVR and wetcircuit like this.
  25. Ukounu

    Ukounu

    Joined:
    Nov 2, 2019
    Posts:
    206
    I think the fact that we, humans, have reached the point where we can't discern a human from a spam bot any longer is kind of worrisome and maybe even "wounding" my human intelligence. But I don't want to derail this thread any longer, so I'll take my leave.
     
  26. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    736
    Human intelligence consists to an important part of social intelligence, which some of us seems lacking a bit ....
     
  27. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    736
    @kalagaan I have a question regarding shadows; on long hair, shadows are flickering a lot (using HDRP, one light source with Spot Light).
    If I push the shadow threshold up to 1, it gets better, but then I'll have way too much shadows. Is there a way to improve the shadow quality? I've set shadow resolution to 2048 already, all other shadows look good, only the hair shadows are flickering.

    Edit: If I increase shadow resolution, flickering gets indeed better, to some extend. between 2048 and 4096 seems a huge difference, but even with 8192 the flickering does not completely vanish
     
    Last edited: Mar 26, 2020
  28. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    The HairDesigner HDRP shader is made with ShaderGraph, the control of the shadows is still limited in HDRP.
    I hope that unity will improve the shadows for transparent objects in the next versions of the HDRP package.
     
  29. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    736
    Thanks for answer; with high resolution I guess it looks okay.

    One very different question: I was thinking about painting eyebrows with hair designer. Is there a way to synchronize the position of painted hair (short hair) with blendshapes? I am using blendshapes to control e.g. eyebrows, but the painted hair does not follow the move.
     
  30. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    You have to lock the short hair layer in the design tab, then all the blendshapes will be generated to the final mesh ;)
     
  31. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    736
    Ah, yes, thanks. Forgot about that. Now it works, and looks good! Only issue is / was that the locking took 15 minutes. Is this maybe because I have 1000+ blendshapes?
     
  32. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    1000 blendshapes, that's huge!
    That's why I don't convert all the blendshapes when the layer is unlocked. :p
    If your mesh as a lot of vertices, the final conversion is slow...
     
  33. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    736
    Do you think there are any bigger then usual runtime effects, if I add hair designer to a rich mesh (30000 vertices) with many blend shapes (1000+), or does runtime performance only depend on the extra hair mesh?
     
  34. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    I don't know exactly how Unity deals with blendshapes, but I think that if you don't change the blendshapes weigth each frame, the performances should not be affected.
     
  35. Fbits

    Fbits

    Joined:
    Sep 19, 2019
    Posts:
    2
    Hey,

    Is there a useful tutorial out there? I'm currently struggling to create real-looking hair.

    Thanks!
     
  36. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    The texture generator is an important step in the workflow.
    Try to set the 'hair count' parameters to a low value (20 or 30)
    You'll have better results with a few 'hair count' on the texture and more geometry.
    You have to balance between texture and geometry density for a nice coverage.

    If you need help, please send me some screenshots of your character and settings (contact@kalagaan.com).
     
  37. Fbits

    Fbits

    Joined:
    Sep 19, 2019
    Posts:
    2
    Thanks for your reply! I just got one issue now: floating hair which I can't delete with the paint delete feature.
    See this screenshot:
    upload_2020-4-7_12-38-6.png

    Any idea how to remove this particular strand of hair?
    Thanks again.
    Cheers Fabian
     
  38. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    That's weird that you have such a floating strand :confused:
    What is your version of HairDesigner?
    Maybe there's a floating triangle in your mesh, HairDesigner use a mesh collider based on the original model.

    You can delete it if you align the camera with the axis of the strand and the mesh.
    The tool need to detect a collision. ;)
     
  39. GambitMonkey

    GambitMonkey

    Joined:
    Apr 5, 2016
    Posts:
    65
    Kalagaan I have looked on the forums here and on your site but I cant find an answer about URP. I see HDRP, but does your product support URP yet? Thank you!
     
  40. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    Sorry, it doesn't support URP yet.
     
  41. GambitMonkey

    GambitMonkey

    Joined:
    Apr 5, 2016
    Posts:
    65
    OK. Thank you for the quick reply. Sounds like it is on your road map though. Well hopefully anyways.
     
  42. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    Yes, it's on my roadmap ;) but I don't know when it will be available.
     
  43. Chris_Payne_QS

    Chris_Payne_QS

    Joined:
    Jul 16, 2016
    Posts:
    83
    Well then I wish you would say so clearly on the store page.
     
  44. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    On the store page I explain that it's compatible with HDRP, maybe I should add that it's not yet compatible with URP.
    I don't know why the assetstore doesn't show the Render pipeline compatibility... This information is mandatory when a package is uploaded on the assetstore...
     
  45. Fluffy-Tails

    Fluffy-Tails

    Joined:
    Jun 28, 2009
    Posts:
    120
    I just completely reinstalled HairDesigner after an issue I discovered.
    Why am I getting this after applying Hair Designer? Screen Shot 04-16-20 at 03.52 AM.PNG
     
  46. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    That's weird :confused:
    What is your version of Unity?

    If you have upgraded to Unity 2019.3, you have to enable the Gizmos button in the scene view.
    I'll enable it by script in the next version.
     
    Last edited: Apr 16, 2020
  47. ArkanisShadowrune

    ArkanisShadowrune

    Joined:
    Aug 23, 2018
    Posts:
    4
    Hello Kalagaan,

    I started a new project in hdrp standard template, with directx 11 per default.
    When i try to paint hair, the result is pink
    upload_2020-4-16_22-53-49.png

    I tried to upgrade the materials to hdrp, but still it doesnt work:

    upload_2020-4-16_22-54-28.png

    Same result happened with directx 12

    I have these error messages

    upload_2020-4-16_22-56-17.png

    Can you please indicate how we can solve this issue ? Also I generated the textures with hdrp option ticked

    Thank you in advance
     
  48. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    You have to install the HDRP Addon
    'Assets/HairDesigner/Addon'
    In the next version I'll add a Warning message if the package is not installed ;)

    There's a bug with the Texture Generator for HDRP (unity 2019.3), it will be fixed in the next version.
    If you want a fix before the release, please send me an email (contact@kalagaan.com) with your invoice number.
     
    Last edited: Apr 16, 2020
  49. Fluffy-Tails

    Fluffy-Tails

    Joined:
    Jun 28, 2009
    Posts:
    120
    I am using Unity 2019.3.9f1.
    The Gizmo was enabled regardless, I turned it off and back on and it didn't solve the problem.

    Any suggestions?
     
  50. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,487
    Thank you for the feedback,
    This is a bug with the basic version of HairDesigner and Unity 2019.3.9.
    It looks like a modification of the Unity API in this version, I'm working on a fix! ;)
    Send me an email (contact@kalagaan.com) with your invoice number and I'll send you a fix asap.