Search Unity

[WIP] TressFX Portation

Discussion in 'Works In Progress - Archive' started by kennux, Feb 28, 2014.

  1. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    Hello there,

    I want to show my TressFX portation in this thread.
    TressFX was developed by AMD and gets used to simulate realistic hair behavior.
    It uses DirectX 11 DirectCompute to do the whole simulation on the gpu.
    On this way they can simulate thousands of hair strands in realtime.

    Currently my implementation only supports the TressFX simulation. The hair rendering is done by passing all vertex positions to a vertex / geometry shader which will restart the strip at the hair ends.
    The original TressFX hair rendering shader will get ported / reimplemented soon, i hope :)

    The projects sourcecode is also available on github: https://github.com/kennux/TressFXUnity
    Feel free to improve my code and / or add some features to it :p

    Some Screenshots:





    There are some problems on low-end graphics cards, just to mention.
     
    Last edited: Aug 10, 2014
    nirvanajie, Baldinoboy and Arkade like this.
  2. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    That is looking very cool, good work! I'll have a look at the github soon enough it's very interesting seeing things like this
     
  3. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I'm surprised less people are taking interest in this, it looks pretty great to me and going by your github you're not far off. I'd like to demo it sometime, so good luck with it!
     
  4. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Posts:
    88
    Looks quite interesting, how does it work with other object like cloth? Is it more performance friendly than Unity cloth?
     
  5. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    It is only for hair simulation, other things are not possible.

    Currently i'm having some trouble porting the rendering shader, more information about the current progress is available on www.kennux.net.

    Anyway, thanks for your comments :)
     
  6. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Looks really cool so far : )
     
  7. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Wow this is interesting, anybody already check the repo?
    Great work kennux, this is pretty cool :)
     
  8. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Any chance this could work with Lux and UMA?

    Lux has a hair shader that is nearing completion.
     
  9. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    I've took a look at the Lux thread and the hair shader seems to not be what i need for TressFX.
    The main difference between the tressfx shader and normal hair rendering shaders is that tressfx's hairs are actually single hairs and not for example transparent quads or triangles with a hair texture.

    I'm currently having issues integrating the unity lighting and shadow system into my rendering (http://forum.unity3d.com/threads/235553-DrawProcedural-and-Lighting-Shadows).
    It doesn't seem to be possible to use shadow collectors/casters and multiple lighting passes with DrawProcedural() which is needed for rendering vertices from a computebuffer.
     
  10. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    I am going to be watching this thread with EXTREME interest. I've been looking for a hair solution for my game and TressFX is exactly what I need... in my special case, I am using PBR (Alloy) and I hope this will work with it.
     
  11. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    I figured the Lux shader wouldn't be directly compatible, but I'd point out that the author of Lux - Lars - is a bit of a shader genius. I don't know if he'd be interested in bringing anything related to TressFX into Lux or not, but he might be able to give you a tip or two to send you in the right direction.

    Just send him a PM and see.

    Probably the best hair shader on the asset store is this one. I'd tend to think it wouldn't be useful for you, because it probably isn't modeling individual hairs, but it does mention something about "tube shaders," whatever that is.
     
  12. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Speaking of, i've check your git but it give me an error in Unity when i press play....
    any idea what causing this?
     
  13. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    I've uploaded a new version to github which patches some syntax errors (i've been playing around with lighting).
    Anyway, the abuffer pass seems to be not working again so the hair will be full red.
    I will debug it, when i got time.

    I've wrote a message to lars from Lux.
    To Alloy: I don't own it and i won't integrate tressfx into it, but because my implementation is opensource anyone is able to integrate it into alloy.
     
  14. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Hello! I have been following your github with a good deal of interest, in the release last night i saw that the hair was moving really nicely but the rendering is borked, however i saw that youre apparently drawing the hair with triangle strips? Would this make it possible to treat strands more as 'wisps', as in decrease the amount of strands, but make them wider and apply uvs, thus making them viable for pretty much many of the excellent hair shaders available on Unity, including Lux and the Advanced Hair Shader that plays amenably wth skyshop. This way we have very realistic hair animation and none of the current rendering issues you're running into at least until it's working as intended again. None of the rendering controls in the repo version (width, tips, colouring) worked and the hair appeared entirely black, but I figured this was something you were working on

    Is this something you would consider?

    However you see it, well done on such an excellent project and i hope you get to the point you're looking at. I couldn't really work out how the strand shapes were placed/combed etc but then it's unreasonable to ask you to spend too much time on documentation, so i'll just keep following the git and see how you do
     
  15. twigs192

    twigs192

    Joined:
    Jan 4, 2013
    Posts:
    18
    Exactly what I've been looking for, been using shroud studio to replicate the hair from Alice Madness Returns and it's been such a pain in the ass. Sadly your demo isn't rendering on my 9800GT nvidia card, but I'll be keeping my eye on this. I'd love to see how this would simulate in my project once you figure out all the kinks. Best of luck


    btw,
    Here's what I've achieved with Shroud Studio (basic version)

    Demo: http://www.mediafire.com/download/8hw860c5ac6lnab/Hair_test.rar
     
    Last edited: Apr 26, 2014
  16. Gistix

    Gistix

    Joined:
    Jul 21, 2013
    Posts:
    29
    I sadly suppose it also needs DirectX 11, right?
     
  17. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    @lazygunn:
    I've had big issues with the rendering, and i didn't did anything the last about 2 months as i was very demotivated after searching calculation errors for hours and hours.
    Documentation will be added definately when i finished the rendering shader, but also AMD's TressFX Portation Guide (Included in the TressFX Sample located here: http://developer.amd.com/tools-and-...ent/graphics-development-sdks/amd-radeon-sdk/) is a good source of information.

    @twigs192:
    Wow! Great work. There are currently problems with many video cards, mostly with AMD cards. I will be working on this after the rendering is working.

    @gistix:
    Yes, it uses DX11.

    I hope to get some new commits pushed to github this weekend :)
     
  18. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I chucked a PM your way as it may help
     
  19. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    Development of this is going on, here are some screenshots which show the current progress:





    More infos on www.kennux.net
     
  20. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    it looks nice when its NOT moved because it in no way looks realistic when moved
     
  21. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Well done! Good to see it still being worked on, i thought it had been abandoned! I hope the articles helped, i might have a question or two in future as to how I might wish to use this for endeavours of mine (I'll keep this to PM most likely), but looking good for now and looking forwards to seeing how it goes in future
     
  22. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    In addition, i cant help but think the current scale of the imported hair and simulation is way too large - taking the max file to its typical import scale of 0.01 had it back down to a regular looking size in Unity units and the hair was rather enormous looking upwards! The scale should certainly affect the simulation, which looked very much like it was getting there, but perhaps some of the behaviour could be attributed to scale (at a guess). Upping the length and shape iterations cleared up the twitchiness certainly
     
  23. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    How do you authoring the Hair btw??
     
  24. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    On his site he said he got sent the hair strand model, but theyre created in 3ds max with the hair and fur modifier, iirc, AMD have the process on their site I think, but i also have two articles in the latest gpu pro book that go into it a bit
     
    Arkade likes this.
  25. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    @rea:
    Currently theres no "easy" way for importing hair models from 3ds, blender or other tools to this.
    I'm working on converters for other formats and maybe also a blender plugin.

    @lazygunn:
    Scaling is not supported at the moment, as well as setting an initial rotation (if the simulation is running you can rotate it, that works). I'm working on that :)
     
  26. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    ah isee.... so it's only Nvidia that make their hair SDK public
     
  27. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    @rea:
    I've put an .ase to .tfx / .txt converter into my git repository which can convert .ase hair splines to multiple tressfx files (Currently this tool is not very well tested and not reading the ase files "correctly". It was written in about an hour to test if it is possible to import ase files to tressfx, i'll improve that in the future).
    There's also an tutorial on how to use it on github and here: http://kennux.net/unity/TressFX/asetotfx_tut/

    @lazygunn:
    The scaling problem is now fixed, only scaling in play mode does not work. Scale it in edit mode and start it. The hair will now get correct scaled.

    If anyone finds bugs please leave an issue ticket on github :)
     
  28. 8Infinite8

    8Infinite8

    Joined:
    Jul 27, 2013
    Posts:
    112
    Fantastic results Kennux, very inspiring!! I hope to be able utilize this tool set with you soon.
     
  29. vfxjex

    vfxjex

    Joined:
    Jun 3, 2013
    Posts:
    93
    I got error in converting ase to tfx

    please help
     
  30. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    Really cool, how is the project going? ;]
     
  31. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Haha fantastic character! Do you have some WIP thread for project?
     
  32. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    There has been great work done on the dev branch, you should check it out, the results are fantastic, even without antialiasing:
    https://github.com/kennux/TressFXUnity/tree/dev
    (i've also found that if you change the hair tickness to 0.1f the FPS gets a huge boost)
     
  33. KheltonHeadley

    KheltonHeadley

    Joined:
    Oct 19, 2010
    Posts:
    1,685
    170 drawcalls though.
     
  34. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    Arkade, John-G and KRGraphics like this.
  35. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Any advantage / disadvantage to using this with Jove 2.0?
     
  36. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    170 drawcalls per 1 hair?
     
  37. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    I think the focus on performance will come last, if the project keeps going on
     
  38. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Holy S***... I love how real this looks. I hope these hair tools become usable for production
     
  39. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    Amazing right? From an artist point of view this is the most perfect hair I've seen in a game. It's impressive that there ain't no other good solutions for hair available for Unity, low poly hair is SO difficult to make right.
     
    KRGraphics likes this.
  40. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    It is... I have spent too much time doing it... I have a close way of doing it, but it is a PITA and i HATE HATE HATE cutout shaders.
     
  41. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    Cutout shaders suck, it aways looks odd from certain angles. It may work very well if you have the amazing artists of Naughty Dog and Square-Enix working for you, the money and experience shows, but there isn't a middle ground for indies hahah There was Shroud, but the project seens abandoned and from the videos I've seen, it was pretty complicated to implement.
    Hope @kennux and @8Infinite8 didn't abandoned the project, I bet people would pay money to have this in their game. ^^
     
  42. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    People would pay money, but IIRC the idea was to release it for free, like UMA and Lux.
     
  43. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    Yeah, but most of the free open source projects on the Asset Store I've seen are discontinued, see Lux for example. I wouldn't mind paying a fair price to help the developers continue doing a good work and having support.
     
  44. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Lux hasn't been discontinued, unless that's very recent news. The idea is that it will probably be replaced by Unity 5 PBR, but it is active.

    You get the latest Lux off of GitHub, not the asset store.
     
  45. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    I would pay money too for something like this... honestly I hate modeling hair, and my models are nearly CG quality and having polygon hair kinda ruins the look for me :(
     
    2dchaos likes this.
  46. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    Arkade likes this.
  47. bennytheball

    bennytheball

    Joined:
    Jul 9, 2014
    Posts:
    8
    I couldn't seem to get it to work. I'm bummed.
    I downloaded the latest build from https://github.com/kennux/TressFXUnity/tree/dev
    I tried loading the demo scene, and everything appeared to be there, but on run it just painted the screen a solid color and nothing more.

    I'm using an ATI 5850 GPU (ATI's TressFX11_v2.2 demo had worked fine on it).
    This hair simulator looks amazing, if only I could get it to work. Can anyone tell me if this a problem with the build, or me?
     
  48. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    What version of Unity are you using benny? Any messages on the log? Remember that dx11 must be enabled for it to work.
     
  49. bennytheball

    bennytheball

    Joined:
    Jul 9, 2014
    Posts:
    8
    Unity 4.5.4f1 - free version

    No messages, DX11 is enabled, oddly the stats display seems active and changes with mouse activity (click and drag).
    Here's a snapshot of the error in unity on run:
    http://s22.postimg.org/71oo1rne9/Tress_FXUnity_port_error.png

    Both the Scene and Game window become abruptly obscured by that solid color on run.
     
  50. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    I'm currently using Unity Pro without problems, I'm not sure if pro is needed for this asset to work, sorry. Maybe you can try PMing the developer.