Search Unity

HairWorks Port For Unity

Discussion in 'General Discussion' started by theprotonfactor, Nov 8, 2015.

  1. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    I've managed to reproduce the issue on Windows 7, but it works fine for me on 8 and 10. I'll push some new dlls that will hopefully be compatible with older versions of windows as soon as possible.
     
    r3ndesigner likes this.
  2. AcIdSaMa

    AcIdSaMa

    Joined:
    Dec 5, 2012
    Posts:
    19
    About got this to work with my project only problem I'm having now is the color the hair is needing to be black when using lighting it makes the hair white without using the lighting script the hair is not visable at all. If I try and change the root and tip colors themselves to black it makes the hair disappear.

    Would like some help with this please :)
     
  3. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    I can't reproduce that behavior on my end unfortunately, but I've made some substantial changes to how rendering is dealt with in the code so please try the latest version and let my know if you're still having this issue.
     
  4. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    @r3ndesigner I've added new DLL's with the latest update. It should now hopefully support Windows Vista and up, if you're still getting that message then please make sure that your Visual C++ Redistributable Packages are up to date as they are required to properly execute the plugin. If the problem persists after that then please let me know.

    On a broader note to everyone, I've just dropped an update that now requires you to have a HairWorksManager script in the scene. You can just create an Empty GameObject and add the script as a component. Check the example project if you need a guide. The reason for this change is that I'm refactoring the code to separate rendering logic from the Hair Instance script. This is part of laying a foundation for proper deferred support and proper shadowing support.
     
  5. r3ndesigner

    r3ndesigner

    Joined:
    Mar 21, 2013
    Posts:
    143
    Same error, i downloaded the last C++ (vc_redist.x64) restarted the pc and didnt worked, anyway thanks bro =}
     
  6. AcIdSaMa

    AcIdSaMa

    Joined:
    Dec 5, 2012
    Posts:
    19
    Well it works but doesn't work when in test play I can see the hair on the character looking in scene view it isn't there at all. Then if I build the project and run the exe it's not even there. Just wondering if there is something I'm missing cause I'm trying to see if the simple project has what I need but can't figure it out.
     
  7. cerrec

    cerrec

    Joined:
    Jan 19, 2017
    Posts:
    41
    I, too, have been trying to get this to work in Windows 7 without success. I downloaded your github files from June 28, and placed NvHairWorksDx11.win64.dll in the plugins folder. I no longer get an error message saying it failed to load the Hairworks (121) dll, but I also don’t get any hair. The animations play fine in your sample scenes, but again, no hair. One thing I’ve noticed is the check box for Hair Works manager (script) refuses to stay checked when I enter Game mode. And it stays unchecked when I return to Scene mode. Could this have something to do with it? It seems that the Manager isn’t being activated.
     
    r3ndesigner likes this.
  8. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    I doubt the Manager is the issue. Although, it's really strange behavior that it disables itself, because none of the code should be doing that, you can check for yourself.

    Me and my team are looking at some solutions to the windows 7 issue, but the plugin build target was set to Windows 8.1+ and changing that target is quite a bit more painful than I'd thought.

    Right, so the bug with it being visible in play mode but not in scene view is a Unity bug that was fixed around 5.6.2. Don't know why the player isn't working for you. If you PM me the output log of the exe I can take a look for you.
     
  9. cerrec

    cerrec

    Joined:
    Jan 19, 2017
    Posts:
    41
    I tried it using Unity 2017.1 f3 and had the same result. The Manager unticks itself. Here's a screenshot of the Console when I enter Game mode. Perhaps this will give you some insight into what's going on.

    Console Screenshot.jpg

    OK, I think I see the problem. There's no HairWorksIntegration.dll in the Plugins/x86_64 folder. But where is the new version of it? I don't see it anywhere in your package.
     
    Last edited: Jul 12, 2017
  10. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    There should be a folder called packages outside of the example project, import the unitypackage in the packages folder into the example project and it should add in the missing dll's. Also, try to use the latest version on github if possible because it features some minor fixes to the manager.
     
  11. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    On a broader note, the project has been upgraded to Unity 2017.1 and works on the new Mono runtime with dot net 4.6 enabled :)

    I'm also going to record a video on how to set up HairWorks in Unity which I'll post on youtube and link to both here and on github. Hopefully that will clear some misconceptions up.
     
    MTDues likes this.
  12. cerrec

    cerrec

    Joined:
    Jan 19, 2017
    Posts:
    41
    I tried that and got the old familiar error of "Failed to load Hairworks (version 121) dll". And this is after downloading your latest package for 2017.1. What on earth am I doing wrong?
     
  13. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    In that case I don't think you're doing anything wrong. It must still be a windows 7 issue, because we have it running on multiple machines at my studio. The only other thing I can think of is that you need to have the visual studio 2015 run-time installed as well as the latest visual c++ redistributable package. In theory if you have those then you really shouldn't see any issues. But...

    If that doesn't fly then we could probably fix the issue by actually rolling back the compiler toolset used to generate the dll to something equivalent to visual studio 2012 or so, but we really, really would prefer not to do that :) If push comes to shove I will do that, but it's a last resort to say the least.
     
  14. cerrec

    cerrec

    Joined:
    Jan 19, 2017
    Posts:
    41
    Could you please post links for the above items. I want to make sure I'm getting the correct ones. If it works for you, it should work for me, right?
     
  15. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    In theory, yes. However, we hardly ever test against Windows 7, so it's quite possible that there are issues we are yet unaware of.

    Anyway, the runtime and all other required components are contained within the installer here
     
  16. cerrec

    cerrec

    Joined:
    Jan 19, 2017
    Posts:
    41
    Thanks for the link, but alas, it doesn't work. I wish I knew what was different between my machine and yours. If you could make that special version, I would be deeply grateful.
     
  17. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    Done. :) I've rolled back the compiler toolset, so fingers crossed this time. Get it from Github again, open the example project and import the package under the packages folder, then add the DLL's from the HairWorks sdk and restart Unity. If that doesn't do it then I don't know what to tell you.
     
  18. cerrec

    cerrec

    Joined:
    Jan 19, 2017
    Posts:
    41
    Dang it, it still doesn't work. In desperation, I ran ProcessMonitor to see what was going on. Unity is definetly seeing and opening NvHairWorksDx11.win64.dll correctly. But for some reason, your script is throwing up the error. Anyway, thanks for the attempts. You're a good guy!
     
  19. cerrec

    cerrec

    Joined:
    Jan 19, 2017
    Posts:
    41
    I just had a thought - could you provide a list, or perhaps a screenshot, of all the Windows 7 updates you have installed on your machine? It's in Control Panels / Programs and Features / View Installed Updates ( in the upper left hand corner). Maybe, just maybe, this might be the key.
     
  20. AcIdSaMa

    AcIdSaMa

    Joined:
    Dec 5, 2012
    Posts:
    19
    Sent you a PM with my Output log file would be nice to get this working looks great in the editor.
     
  21. AcIdSaMa

    AcIdSaMa

    Joined:
    Dec 5, 2012
    Posts:
    19
    So I managed to get this working in my project but found that if I have two instances of the hair running. One for player 1 and then player 2 it will cause my game to crash with the following

    Code (csharp):
    1.  
    2. nvwgf2umx.dll caused an Access Violation (0xc0000005)
    3.   in module nvwgf2umx.dll at 0033:c8193fbf.
    4.  
    Not sure what the cause of this is.
     
  22. emilche123

    emilche123

    Joined:
    Oct 27, 2014
    Posts:
    3
    Hi! I do not know if you are still active with this asset but! I have a problem in the new unity version when I import this asset. It says "hwi.cs(227,52) error cs00443: Value or constant expected" I have tried playing around with the script but have not been able to get it to work. Do you have any suggestions?
    Thanks mate!
     
  23. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    I'm pretty sure I fixed that a long time ago... I think you're either using an older version of my fork or the original.
     
    MTDues likes this.
  24. MTDues

    MTDues

    Joined:
    Mar 27, 2014
    Posts:
    27
    Thx for ur efforts unit saluts you :D
     
  25. MTDues

    MTDues

    Joined:
    Mar 27, 2014
    Posts:
    27
    Im having a proplem at the visual studio when i follow proton insturctions PLEASE HELP!

    Why i get error build and this error

    " failed to open source file: 'Nv/HairWorks/Shader/NvHairShaderCommon.h' C:\Users\Dell-PC\Desktop\Neo NVIDIAHairWorksIntegration-master\NVIDIAHairWorksIntegration-master\Plugin\Shaders\DefaultHairShader.hlsl 1 10 HairWorksIntegration "

    https://imgur.com/a/LFjIh


    Win8 / 64 and done everything on github, any help
     
    Last edited: Nov 8, 2017
  26. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    The hlsl file uses a different compiler than the rest of the project and you have to set up the path to its library separately. Right click on the hlsl file in visual studio and go to its properties, from there you should be able to specify its include folder. Also there's a shader that's already built included in the unity package under the Packages folder. You can just import the unity package if you don't plan on modifying the shader.
     
  27. MTDues

    MTDues

    Joined:
    Mar 27, 2014
    Posts:
    27
    upload_2017-11-9_3-22-34.png
    I did edited the defult hlsl like u said and now it shows another error

    note: i changed the project platform to a x64 would that be okay , idk what caused another error
    am i the only one having this proplem xD

    "
    Error 5 error MSB3073: The command "xcopy /Yq C:\Users\Dell-PC\Desktop\Neo NVIDIAHairWorksIntegration-master\NVIDIAHairWorksIntegration-master\Plugin\_out\HairWorksIntegration_x64_Debug\*.cso C:\Users\Dell-PC\Desktop\Neo NVIDIAHairWorksIntegration-master\NVIDIAHairWorksIntegration-master\Plugin\..\HairWorksIntegration\Assets\StreamingAssets\UTJ\HairWorksIntegration\
    xcopy /Yq C:\Users\Dell-PC\Desktop\Neo NVIDIAHairWorksIntegration-master\NVIDIAHairWorksIntegration-master\Plugin\_out\HairWorksIntegration_x64_Debug\HairWorksIntegration.dll C:\Users\Dell-PC\Desktop\Neo NVIDIAHairWorksIntegration-master\NVIDIAHairWorksIntegration-master\Plugin\..\HairWorksIntegration\Assets\UTJ\Plugins\x86_64\
    C:\Users\Dell-PC\Desktop\Neo NVIDIAHairWorksIntegration-master\NVIDIAHairWorksIntegration-master\Plugin\Externals\PatchLibrary\PatchLibraryProxy64.exe /target:Unity.exe /patch:C:\Users\Dell-PC\Desktop\Neo NVIDIAHairWorksIntegration-master\NVIDIAHairWorksIntegration-master\Plugin\_out\HairWorksIntegration_x64_Debug\HairWorksIntegration.dll
    :VCEnd" exited with code 9009. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets 132 5 HairWorksIntegration"
     
  28. MTDues

    MTDues

    Joined:
    Mar 27, 2014
    Posts:
    27
    i made all x64 for my 64 pc thats all i changed thats not mentioned in ur guide

    hlsl file
    upload_2017-11-9_3-26-30.png

    the whole project
    upload_2017-11-9_3-26-39.png
     
  29. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    I think that error is a result of it failing to interpret the command to copy the shader and dll's over to the unity project when its done builing, but I'm not sure... I've only used VS 2015 to compile it, not sure if older versions support the copy command...
     
  30. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    Send me a private message if you need more help
     
  31. MTDues

    MTDues

    Joined:
    Mar 27, 2014
    Posts:
    27
    the unity priject from ur link at github
    when i open it and import the package u uploaded to the unity project shows me this error

    which doesnt make the hair show up in scene and in runtime

    anyhelp ?, ive downlaod the SDK from nvidia site and all :(
     

    Attached Files:

  32. MTDues

    MTDues

    Joined:
    Mar 27, 2014
    Posts:
    27
    note: im win 8 , 64
     
  33. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    Just wanted to say awesome work. :)

    I read through the entire thread, and I see you struggled a lot with getting shadows to work.

    I might suggest you look at this project: https://github.com/kennux/TressFXUnity
    While I realize it's a completely different hair system, and unfinished, one thing they did manage to do was get shadows working quite well. Perhaps it can give you some ideas.

    Also I was curious what happened to the blender plugin? The links seem to go to a missing repository.

    Thanks.
     
  34. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    With the TressFx plugin they actually have access to all of the hair mesh data and they render it directly inside of Unity. So as a result shadows are no problem.

    In this plugin, however, everything including rendering is done in the plugin c++ side, not really my choice that's just how the sdk works. I think even the hair mesh is generated on the gpu. In other words because the mesh doesn't exist in Unity it can't render shadows for it without some hacks. In order to do the same thing the TressFx plugin does we'd have to do a readback to the cpu and then pass the data from the c++ plugin to the c# Unity environment and then generate meshes again. So unfortunately it's not really possible for performance reasons.

    As for the Blender plugin, that's kinda a long story. To boil it down there was a misunderstanding where some people thought I was using the Hairworks sdk in Blender to export the hair files which is not permitted due to incompatible licensing of blender and the sdk. I tried to explain that I coded everything myself and reverse engineered the file much the same way Blender does with Fbx files, but I ended up taking it down just to be safe, although it should be fine. Good news is I'm going to bring it back better than ever. Essentially I'm making a standalone tool that will import blend files, list out the hair particle systems in the scene and allow you to pick and choose what to export with some options. That should be rock solid in terms of licensing because Blender is never directly used and it should also have better performance because it's being written in pure c++. I can't make any estimates on when it will be done though... It's one of many half-baked projects I have lying around at the moment.
     
    twobob and ceebeee like this.
  35. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    yeah I don't quite get the argument with blender they threw at you. You're not distributing your addon with blender, so whatever license your plugin is under is immaterial. It could be closed source commercial and that's fine. It doesn't change blender's license in the least. At any rate, glad to hear it will be back at some point.
     
  36. Velo222

    Velo222

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

    That's amazing you're still working on the Hairworks integration.

    Anyways, I decided to try to do a fresh install of your hairworks plugin, and tried following the GitHub instructions step by step. I "think" I have all of the .dll's in the right folders (but maybe not). I don't get any errors or anything. But when I add the "Hair Works Manager" script to my scene, I get the "Failed to load Hairworks (version 121) dll. You need to get HairWorks SDK from NVIDIA website. Read document for more detail." error warning popup.

    I have the "NvHairWorksDx11.win64.dll" in the Assets->UTJ->Plugins->x86_64 folder (file path). I am using Windows 10 and have a 64 bit machine.

    Any idea why the Hair Works Manager script won't recognize the .dll? Forgot to mention, I'm using Unity version 2018.2.8f1. Is that too recent a version of Unity for the plugin to even work at all?

    Also, I added the Hair Instance script to my skinned mesh renderer on my character and tried to load a .apx hair asset, but the "Hair_asset" field remains blank. I'm assuming that's because the Hair Works Manager script cannot find the .dll?

    Anyways, great work, and thanks for all that you do :)

    * Just noticed the other posts with this issue. How can I update my visual c++ redistributable packages by themselves? If I upgrade Visual Studio to 2017 (I currently have 2015), do you think that might help as well? Or should I stick with 2015?
     
    Last edited: Oct 30, 2018
  37. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Update: I seem to have resolved the Hair Works Manager script not being able to find the Hairworks .dll file. Instead of placing the "NvHairWorksDx11.win64.dll" in the Assets->UTJ->Plugins->x86_64 folder, instead I placed this .dll in the Assets->HairWorksIntegration->Plugins->x86_64 folder.

    This caused the manager script to recognize the .dll finally.

    After doing this, and loading the .apx hair asset, I had some white hair "follicles" information show up on the screen, but they were inside my animals mesh, and not scaled properly.....and they didn't show up at all on the Game screen (just in the Scene screen).

    What's interesting is if check "Visualize Guide Hairs" or Visualize certain things on the Hair Instance script, it will actually show all of the hair guides/follicles properly. But no hair is drawn for some reason.

    Here is a picture of my current situation:

    HairworksIntegrationProb1.png

    The "Scale Factor" on the Hair Instance script seems to not do anything at all. And I don't see any rendered hair at all, but the visualizers seem to work.
     
  38. Devconone

    Devconone

    Joined:
    Oct 2, 2017
    Posts:
    4
    Hi Protonfactor,
    Thanks for developing this tech, it looks amazing and a decent hair solution for Unity is very badly needed!

    I've just been trying to get it working, but to no avail however.
    I followed the step by step to get it setup in an empty project using the supplied shader (no coding or anything strange from me) I've had no compiller errors, but the display in Unity seems broken in several ways - probably easiest to show with a GIF. This is what the test hairstyle looks like in NVIDIA's hair viewer:

    ...and this is what it looks like in Unity:

    Has anyone experienced anything like this? Is there something simple that I'm doing wrong somewhere? Any help in getting it working would be greatly appreciated!

    Many thanks
     
  39. unity_KSUwZulc0fOUtw

    unity_KSUwZulc0fOUtw

    Joined:
    Aug 15, 2018
    Posts:
    1
    Although it has been a long time, I have had the same problem. Did you solve it?
     
  40. puzzic

    puzzic

    Joined:
    Aug 23, 2015
    Posts:
    7
    This is AWESOME!!! Thank you.
    But, I have had the same problem. Any idea?
    Unity 2018.2.3f1