Search Unity

Is dynamic hair hardware intensive?

Discussion in 'General Discussion' started by Haxzploid, Apr 18, 2019.

  1. Haxzploid

    Haxzploid

    Joined:
    Dec 28, 2018
    Posts:
    36
    Hi

    I would like to know if dynamic hair in unity is hardware intensive - As in; does it take up a lot of resources?

    Imagine a semi-low poly game, with somewhat cartoony hair like below - physics based with a lot of movement. Does this drain resources or is it quite doable in 2019?


     
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    Seeing as the game you're using as an example came out in 2005, yeah, that's fine.
     
  3. Haxzploid

    Haxzploid

    Joined:
    Dec 28, 2018
    Posts:
    36
    Well, i believe those are pre-rendered animations, right? Aren't they just a pre-rendered layer, smacked on top of gameplay?
     
  4. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    Whats a pre-rendered layer? And how do you smack something on top of gameplay?

    In answer to your question though, yes its possible.

    You could use the new animation rigging package to create a damping effect for the hair so that it moves as expected which may or may not be a more performant way of doing this. I think the new package uses c# animation jobs so it should be multithreaded

    A compute shader + shader would be the other way to go about this

    There are probably other ways too but those two spring to mind.


    No offence but the way you are describing things tells me you are new to unity and probably game development as a whole, which also means you probably shouldnt be trying to do hair physics as the first thing.
     
  5. Haxzploid

    Haxzploid

    Joined:
    Dec 28, 2018
    Posts:
    36
    You are right about me being very new to both.

    I am the type of person that need to work on a single project, to learn. I just wanted to get an idea of how FPS heavy the vision was, before going that route - And you are right, i shouldn't start off with the advanced parts.

    What i meant by "pre-rendered layer" was not an attempt to sound clever. It was my way of describing a 2d animation being played, simulating 3d characters on the screen. That's what it looks like to me. Long time since i played B&W2 so correct me if i'm wrong. :)

    Thanks for the answer, that it's indeed possible.
     
  6. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    Hey I think thats a good approach to learning, just wanted to make sure you know its going to be pretty intensive.

    I (and most of the community here) love seeing people try to learn difficult or new things instead of asking for the work to be done for them, so I think what you are doing is great :) And I can link you some tutorials to get you started that could help on this matter:

    Note these are all different ways of doing same thing so try them all! Some easy some hard!

    Joint based hair physics:
    https://laboratoriesx86.wordpress.com/2014/07/27/joint-based-hair-cloth-physics-for-unity/

    This one is for cloth but can be applied to anything including hair:
    https://www.polygon-treehouse.com/blog/2017/8/4/howtoponcho

    And if you wanted to go the compute shader route, this is a great intro to compute shaders:
    http://kylehalladay.com/blog/tutorial/2014/06/27/Compute-Shaders-Are-Nifty.html

    After that for the compute shader route you would basically use a compute shader to compute the bend of each hair mesh, and literally transform the model based on the spring physics sim. This way is hardest and requires a lot of math and physics research.

    Good luck :)

    P.S personally I would try the cloth method first as it is easiest and looks really good for what it is! If you wanted literally individual strands of hair, joint based could be okay but wont be that performant, but would be what I would try first.

    Then if no other solution is fast enough FPS wise, compute shader based deformation is the way to go
     
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
  8. Haxzploid

    Haxzploid

    Joined:
    Dec 28, 2018
    Posts:
    36
    Thank you for the hints.
     
  9. Haxzploid

    Haxzploid

    Joined:
    Dec 28, 2018
    Posts:
    36
    You are right - I was mainly thinking about those "story tellers/guides" popping up. I completely forgot about the "avatars" having hair as well, perhaps my GPU was not up to date at that time. Well i guess that also answers my questions, so thanks.
     
  10. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,243
    With a poly count that low?
     
  11. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    I think that those characters just used a technique called "hair cards". Basically, groups of hairs are painted onto a transparent quad or line of quads, and these quads are placed around the head and face so that it looks like the hair has volume. Those quads can be animated just like any other part of a model, including being made semi-dynamic.

    If you zoom in on this model (not by me!) you can see the technique in action.
     
    Ryiah and BrandyStarbrite like this.
  12. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    @angrypenguin
    Yeah. I think they used that same technique you described, for Donkey Kong's fur, in Donkey Kong Tropical Freeze.
     
  13. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    no the hair card method is different from the shell based method, which dk tropical freeze (and start fox adventure) used.
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Shells are more for fur though.
     
  15. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    It's an artistic and technical choice, you can pretty mush do both with it, but while fur is either card or shell, human hair is generally done with card due to the sophistication of hairstyle (since we are intimately familiar with them) and the amount of control card offer you.