Search Unity

[WIP] TressFX Portation

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

  1. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    633
    It's sad that he's updated his blog saying he's quit working on the port because of Unity's rendering. He should've took a look at jove 2 which would have really made this pop :(
     
  2. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    Really sad, but good luck to kennux on his next endeavors ;]
     
  3. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    I haven't been working on this project for quite a long time, but yesterday i started working on it again.
    I could implement some new things like strand antialiasing, transparency, fragment sorting, dynamic directional lighting and some smaller things.

    Newest screenshots:






    Sometimes the lighting looks really strange, that's the next rendering-thing i will start working on.

    Up2date sourcecode is on my github repository :)
    I'll try to keep working on this but i cant promise anything.

    To the jove rendering:
    I already thought about it, may i'll try it in the future, but the main goal is to implement this into unity's rendering.
     
    2dchaos, Reanimate_L and blueivy like this.
  4. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    633
  5. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    Unfortunately, the compute shader is not compiling on unity 5 (I got the same problem as described here: http://forum.unity3d.com/threads/compute-shader-not-found.280951/). Bugreport is already sent, as soon as this gets fixed i'll start porting it to unity 5.

    Yes, i saw this slides and they look very impressive but for now TressFX 2.2 is the target version :p
     
    blueivy likes this.
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    Seems to work for me with U5, just fixed those compiler warnings and then can see:
    hairfx.jpg
     
  7. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    Does also the simulation work on unity 5?
    The simulation shader was the one which wouldn't compile.
     
  8. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    Attached the modified files: Simulation.compute, FragmentSorter.compute
     

    Attached Files:

  9. CW3MH6

    CW3MH6

    Joined:
    Jul 4, 2013
    Posts:
    14
    Thanks :)

    Works great!
     
  10. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    Thanks mgear, i merged your changes into my newest shaders and put them into a new unity5-dev branch available here:
    https://github.com/kennux/TressFXUnity/tree/unity5-dev

    I'll try to merge unity 4 changes into the unity 5 dev branch so both versions are always up 2 date.
    Last night i finally managed to get the sorting working correctly.
    Here are some new screenshots:


     
  11. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63
    Really happy to see progress in this, keep up the good work guys
     
  12. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    Can someone teach how to import custom meshes ?
     
  13. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    Also would it be some how possible to use procedural geometry for the hair inside unity..?
     
  14. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I think the tools for creating hair in an application like max and exporting guide hairs for use in tressfx are available on amd's site
     
  15. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    Can't find it =/
     
  16. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    If I remember correctly kennux already has a tool within his TressFX folders.
    It is called AsetoTFX. This folder already has a sub folder called "Tutorial" which might give a clue if the tool is suitable for you or not.
    Hope this helps.
     
  17. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    Oh, I see... I just have to know how to extract the hair data to a .tfx file so then I can convert it to an .tfxb file =/
     
  18. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    Ok, I got the hair_0txt file. But when I try to create a new Hair Data, it asks for a .tfxb file, which I don't have. How do I proceed ?
     
  19. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    Can't really help you there (don't have Max, can't generate .ase files) but if you look through the folders of kennux's code you'll see that there is a folder called "HairData" which holds a .bat and an .exe file. I believe they generate the tfxb file but I might be totally wrong since I've never tried it.
    Maybe it's better to wait and see what kennux or any other experienced forums user has to say about this.
     
  20. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    yeah, it won't help. It also asks for a .tfxb file... Kennux, help me !!! LOL
     
  21. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    @mgear:
    Procedural drawing is possible but you cant access the shadows maps from there as you are outside of the normal unity rendering pipeline.

    @HenriqueGomez:
    Importing custom meshes is currently not supported, i will write tools to convert other formats into TressFX and maybe editor tools.
    Unfortunately amd didn't release their modeling tool exporter.

    AseToTFX is not up2date, i will push a new version to github asap, but at the moment i'm a bit busy so it may take a week or two.

    The AssetConverter is currently unusable because the AseToTFX tool is not working correctly. As mentioned earlier, i'll need some time to rewrite everything ;)

    Updates to the overall progress:
    I greatly improved the unity editor integration and changed a bit here and there.
    Next big step will be decreasing the ammount of graphics ram and performance needed for rendering and the importing of new hair meshes.
     
    2dchaos, gurayg and blueivy like this.
  22. 2dchaos

    2dchaos

    Joined:
    Sep 11, 2013
    Posts:
    63

    No errors on the console, even messing with the alpha the hair is still transparent.
     
  23. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    This is a known problem, it seems to happen if there are very much fragments to sort.
    If the ammount of fragments is very high the per-pixel linked-list will run out of memory.
    At the moment there's no simple fix for this, you can try to increase the maximum hair layers paramter on the TressFXRender.cs script but you will need VERY much graphics ram (If you choose a number too high so your gpu has not enough vram unity and your graphics driver will crash).

    I'll try to lower memory usage for the future so this problem will get solved, but at the moment theres no fix :p
     
    nxrighthere and 2dchaos like this.
  24. TH-Interactive

    TH-Interactive

    Joined:
    May 26, 2013
    Posts:
    34
    Hey Kennux I love what you've done so far - amazing work!
    Just to let you know I'm also getting the transparency on the latest test project, just like 2dchaos posted above.
    System:
    i7
    8GB RAM
    AMD 270x 2GB RAM

    I've tried increasing the "TotalHairLayers" variable on the hair instance in the test scene - even to 128 and I see no difference.

    Have I gotten the right variable? Or what kind of number should I go to?

    Thanks for your efforts and time!
     
    2dchaos likes this.
  25. GuitarBro

    GuitarBro

    Joined:
    Oct 9, 2014
    Posts:
    180
    Hey, I don't usually post much on the forums here, but I had to sign in to let you know this is awesome. I'm really excited to see where this is going, it would be awesome if I could use it in a game. Keep up the good work! :D

    Also I thought I should mention that I'm not getting great performance when running in full screen in Unity 5 using the Unity 5 dev repository (though I can easily hit 60fps when running in a small editor window). You're probably aware, but I figured it wouldn't hurt to mention. If you're interested, here are my relevant specs:
    Windows 7
    AMD FX-8150
    GTX 660 Ti 2GB

    Good luck with the project!
     
  26. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    Hey, any updates on this?
     
  27. GuitarBro

    GuitarBro

    Joined:
    Oct 9, 2014
    Posts:
    180
    Unfortunately, it would seem there are none.
     
  28. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    I'm still working on it. I'm currently completely rewriting everything, including the hair shader :)
    Maybe take some time as i'm not working full-time :p

    I will post screenshots of new features asap on my blog, so stay tuned :)
     
    nxrighthere, mgear and KRGraphics like this.
  29. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Good stuff.. I may even use this for non game related characters rendered in Unity...
     
  30. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
  31. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    Thanks for your reply, I really want to see where this is going! Also about hairworks, I'll give it a try!
     
  32. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
  33. GuitarBro

    GuitarBro

    Joined:
    Oct 9, 2014
    Posts:
    180
  34. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    for me the demo scene works with those steps
     
  35. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    For me it doesn't work, it just loads the grass thing? In the console it said that 2 things haven't been completed. Maybe it's because I'm using 5.2 beta version...
     
  36. MohammadZak

    MohammadZak

    Joined:
    Aug 20, 2015
    Posts:
    14
    hi guys
    i saw this framwork and i say it has nice implementation
    but i working on my hair rendering solution called HairEngine!!
     
  37. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Hi Kennux,

    Excellent work thank you! It worked "right out of the box" for me, which was great to see (and I'm using Unity 5.1.1p1 currently).

    Now I'm trying to learn how to apply it to different models, but I'm not quite sure where to start -- or the authoring pipeline for that matter. Any chance you could give a quick "getting started" tutorial type thing in the future? For example, lets say I've imported my human biped model, now what scripts and objects need to be applied to what portions of the model in order for the hair to work? Do I need to model the hair-strands/guides in another 3d modeling tool such as 3ds max or Maya in order to get custom hair? Is the hair generated off of some sort of texture map or something?

    Why is there an ObjectConverter.exe and what does it do?

    Why is there a "MeshBuilder" helper script, and what does it do?

    I know you said you're still working on it, which is great, and I hope you continue to do so!
     
  38. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    First off: Do not try to use the current version of tressfx as it is now for production environments :p
    There's a massive update going on right now (will get pushed to github as soon as its done, but it will take some time, http://kennux.net/wordpress/?p=179 for more information).
    The new version of it will provide an even better integration into unity, a wizard to create hair gameobjects, .ase or .tfx import (1-click directly into unity) and much other epic things :).

    The ObjectConverter.exe is a tool that was in AMD's Example.
    The MeshBuilder script is a helper script that builds a mesh that will be used for procedural hair rendering.
    It is used to build multiple meshes from one big vertex / index array.
     
  39. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    Awesome! You are amazing.
     
  40. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Thanks Kennux. Looking forward to the update when it's ready. :)
     
  41. kite3h

    kite3h

    Joined:
    Aug 27, 2012
    Posts:
    197
    In TressFXRender.cs

    this.LinkedListHead = new RenderTexture (Screen.width, Screen.height, 0, RenderTextureFormat.ARGB32);

    convert to

    this.LinkedListHead = new RenderTexture (Screen.width, Screen.height, 0, RenderTextureFormat.RInt);
     
    2dchaos and bjonreyes like this.
  42. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Are you using an AMD GPU, @kennux? I am not knocking what you are doing but I don't see this thing working on my system...
     
  43. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    Seems like a unity update broke something (I'm not working on the code that is on github at the moment anymore, it will get updated).
    Anyway, stay tuned for the next release (more info on the current state was just posted on http://kennux.net yesterday) :)
     
    GuitarBro and Velo222 like this.
  44. GuitarBro

    GuitarBro

    Joined:
    Oct 9, 2014
    Posts:
    180
    Staying tuned!
     
  45. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    The new version got released. Check github and my blog for more infos ;)
     
  46. jdraper3

    jdraper3

    Joined:
    May 28, 2015
    Posts:
    117
    Thanks for continuing work on this, and congratulations on the new version!

    I downloaded the project from github and tested out the demo scene, but this is what I get--

    PS: Testing on AMD 5800k integrated GPU, latest Unity 5 release.

    tressfx.png
     
  47. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    It's working fine on Unity 5.2
     
  48. GuitarBro

    GuitarBro

    Joined:
    Oct 9, 2014
    Posts:
    180
    Awesome, I'll be checking this out soon.
     
  49. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    I've checked it using 5.3, it is working fine but I also noticed some small problems.

    If I turn of V-sync and use wind options, things get pretty nasty. Simulation runs much faster.

    Also tried it with Unity Cinematic Image Effects package
    https://www.assetstore.unity3d.com/en/#!/content/51515
    Depth of field seems a bit problematic.

    tress_fx.jpg

    Thanks Kennux!
    Have a happy new year.
     
  50. kennux

    kennux

    Joined:
    Aug 25, 2013
    Posts:
    43
    Thanks for all that feedback :)
    @jdraper3: Integrated gpus are known to cause trouble in much cases, got no idea why it fails on them, so sorry no fix for now, but thanks for the report :)

    @gurayg: You can limit the simulation speed, check the frame limit parameter on the TressFXSimulation component. At the moment almost no post processing works, maybe because i "hacked" the rendering pipeline. I think if you want to use post processing you need to modify the shader. But supporting post processing is definately on my todo!

    A video of the new renderer on a character in a game that is currently in development will follow soon :)
    And happy year to all of you aswell ;)