Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

NVIDIA HBAO+ Image Effect - Sample Project

Discussion in 'General Graphics' started by smb02dunnal, Feb 7, 2015.

  1. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
  2. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,663
    Great work you did there :) Tested it out and it works like a charm!
     
  3. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    what unity version 4 or 5?
     
  4. SAOTA

    SAOTA

    Joined:
    Feb 9, 2015
    Posts:
    220
    Could someone please compile a x64 version of the HBAO plugin? 32 bit works fine!!
     
  5. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    The sample project uses Unity 4.x
     
  6. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    ah i see, because i got error in 5
     
  7. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    437
    would be great to do it for U5 too =)
    tested on 4. work nice and clear
     
  8. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    I think there should be a x64 and x32 version port for Unity 5, that where we can see the real beauty..
     
  9. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
  10. braaad

    braaad

    Joined:
    Oct 4, 2012
    Posts:
    102
    Did an x64 build and tested in U5, works fine.
     
  11. TheHenk

    TheHenk

    Joined:
    Mar 24, 2011
    Posts:
    13
    Would you care sharing the build?
     
  12. braaad

    braaad

    Joined:
    Oct 4, 2012
    Posts:
    102
    When downloading anything from GameWorks you must agree to a licensing agreement through a registered account. I assume NVidia don't want people sharing files outside of that system.
     
  13. TheHenk

    TheHenk

    Joined:
    Mar 24, 2011
    Posts:
    13
    Ok, I guess I will have to build it myself..
     
  14. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Excuse me but how did you build it to 64 platform? Did you use msvc2010 or 2012?
    I have the source opened in msvc2010 and I can only see the Win32 option. When I try to change the platform to x64 manually I get this error message:
    Code (csharp):
    1.  
    2.  
    3. 1>build/Release\HBAO_Plugin.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
    4.  
     
  15. braaad

    braaad

    Joined:
    Oct 4, 2012
    Posts:
    102
    @Ravel you are getting that linker error because you are trying to build against the 32 bit hbao library. You need to change to the 64 bit version.
     
  16. paddy9614

    paddy9614

    Joined:
    Nov 25, 2014
    Posts:
    5
    very nice but does not working with AA!?
     
  17. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    strange, i manage to build the x64 version and in unity 5 the HBAO doesn't showing, only white scene

    EDIT : nvm i'm just being stupid, it works now
     
    Last edited: Feb 14, 2015
  18. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Infact this was a real hussle, because my vs10 had a bug, I had to uninstall it, and install it with some steps and patches to support x64 compiler. Now I got things working again :)
    a-team-t-shirt-hannibal-a-plan-comes-together.jpg

    Will check out the HBAO stuff now
     
  19. SAOTA

    SAOTA

    Joined:
    Feb 9, 2015
    Posts:
    220
    I'm not getting this to work anymore. It keeps throwing
    DllNotFoundException: xxxxx HBAO_Plugin.dll
    HBAOPlus.Start () (at Assets/HBAO/HBAOPlus.cs:71)

    This is after making sure the ref ddl is in the project folder and both ddl's are unlocked.

    The test scene works though. weird.
     
  20. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Unity5 or 4?
     
  21. SAOTA

    SAOTA

    Joined:
    Feb 9, 2015
    Posts:
    220
    Unity 4.6
     
  22. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    @SAOTA can you make a port for Unity 5 x64?
     
  23. SAOTA

    SAOTA

    Joined:
    Feb 9, 2015
    Posts:
    220
    just cant get this to work in unity 5. hopefully someone at nvidia builds a asset for x64 and x86.
     
    shkar-noori likes this.
  24. jziglar

    jziglar

    Joined:
    Sep 7, 2014
    Posts:
    4
    What compiler did you guys build this in?
    I'm getting the error:
    Failed to load 'Assets/Plugins/HBAO_Plugin.dll' with error 'The specified module could not be found.
    ', GetDllDirectory returned ''. If GetDllDirectory returned non empty path, check that you're using SetDirectoryDll correctly.

    In Unity 5.
     
  25. braaad

    braaad

    Joined:
    Oct 4, 2012
    Posts:
    102
    The x64 native dll? I used VS2013
     
  26. jziglar

    jziglar

    Joined:
    Sep 7, 2014
    Posts:
    4
    Hmm.
    The dll builds correctly.
    But when I load in Unity, it still outputs that error.
     
  27. braaad

    braaad

    Joined:
    Oct 4, 2012
    Posts:
    102
    So the built dll is correctly named HBAO_Plugin.dll ? also make sure that that the dll options are set to x64 (new in U5) by selecting the dll and there will be options in the inspector. For the x64 dll I only selected the x64 option.
     
  28. jziglar

    jziglar

    Joined:
    Sep 7, 2014
    Posts:
    4
    That's all set up correctly, I am thinking that the DLL is not correctly pulling in the dependencies. It seems to depend on the GFSDK_SSAO.win64.dll file. Is there a way to include the GFSDK_SSAO.win64.dll file as part of the HBAO_Plugin.dll file?
     
  29. braaad

    braaad

    Joined:
    Oct 4, 2012
    Posts:
    102
    Yeah, so in your linker input you need to specify the win64 lib instead of the win32.
     
    Reanimate_L likes this.
  30. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    This......this one is the problem, i don't have access to my HBAO project right now. And it compile as long as you link the win64 lib correctly
     
  31. jziglar

    jziglar

    Joined:
    Sep 7, 2014
    Posts:
    4
    Now I got it to compile within Unity, but it doesn't show anything. If I increase the bias to >= 1, it turns the screen black, but that's it.
     
  32. TrollHachem

    TrollHachem

    Joined:
    Dec 25, 2012
    Posts:
    65
    If your normal scene is rendered inverted (but AO fine) (happened to me when enabling GI) , go to HBAOPlus script and replace :
    Code (CSharp):
    1. Graphics.Blit(null, destination, renderAoMaterial);
    by
    Code (CSharp):
    1. Graphics.Blit(source, destination, renderAoMaterial);
    This'll invert AO and make normal colors appear as they should.

    You'll have to reinvert AO :
    Go to renderAO shader and replace
    Code (CSharp):
    1. const float ao = _AoResult.Sample(sampler_AoResult, i.uv);
    by
    Code (CSharp):
    1. const float ao = _AoResult.Sample(sampler_AoResult, fixed2(i.uv.x,1 - i.uv.y));
    And editor is stuck when exiting and have to shut it down with task manager. Am i the only one having this problem?
     
    Last edited: Mar 6, 2015
  33. gtpdzbiz

    gtpdzbiz

    Joined:
    Mar 21, 2011
    Posts:
    53
    Yes same issue here, the edito will stuck upon shutting down.
     
  34. TrollHachem

    TrollHachem

    Joined:
    Dec 25, 2012
    Posts:
    65
    Hello ,
    I fixed the issue ,
    Go the the plugin source code , And remove ALL debuglog calls.
    I don't know how but this fixed it for me.

    And ,
    I tried passing the normal data to HBAO+. (using data from G-Buffer)
    I got a really weird result,i think the problem is in the Unity's camera World To View matrix.
    I first thought it's because the normal texture was wrong , so i sent in the normals-depth from the camera depth texture mode , i got the same result.
    Can anyone find a solution to this?
    Thanks :)
     
  35. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    315
    Hey guys, using Unity 5.0.4f here. Once I enable the effect on Unity All the screen is getting black forming a circle growing up and after few second the whole screen is black.
    I've never compiled anything I just took the sample archive and get the files from the Unity example demo. What do I miss here? Thanks !
     
    lka69 likes this.
  36. ki_ha1984

    ki_ha1984

    Joined:
    Aug 24, 2014
    Posts:
    111
    Hi to everyone,
    Because i am new to unity and i am confused with all the above instructions, i would like to ask if is there any simple sample or guide on how to use HBAO+ in Unity 5?

    Thank you in advanced


    Ki_ha1984
     
  37. gratyanolteanu

    gratyanolteanu

    Joined:
    Nov 18, 2014
    Posts:
    24
    I have compiled the plugin for x64, no errors, but right now everything is white.Need to figure out why.
     
  38. TrollHachem

    TrollHachem

    Joined:
    Dec 25, 2012
    Posts:
    65
    Try in another scene.
     
  39. gratyanolteanu

    gratyanolteanu

    Joined:
    Nov 18, 2014
    Posts:
    24
    HI. Can I ask you something?
    After Compiling the dll for x64, what is the size of dll ? Mine dll is 91 KB its more smaller than original dll.
    For compilation I used blend for VS 2015.
    I opened the .sln file
    I selected _Plugin From "Solution explorer" and right clik and I choose propertyes
    In the property window I choose Configuration Manager
    --> Platform tab: New
    --> New Project Platform window : New platform x64 , Copy Settings from Win32 hit ok
    --> Activate Solution Configuration : Release
    --> Configuration tab : Release and hit close
    --> Platform : x64

    In linker --> Aditional Library Directory : Edit and modify from $(DXSDK_Dir)\Lib\x86 in $(DXSDK_Dir)\Lib\x64 hit ok
    in input -->Aditional dependencies: Edit and...
    here i have 2 entry:
    GFSDK_SSAO.win32.lib and opengl32.lib
    I changed GFSDK_SSAO.win32.lib in GFSDK_SSAO.win64.lib
    And I don't know if I need to delete opengl32.lib or to modify in opengl64.lib
    I delete the entry opengl32.lib
    Hit ok And compile.
    Some Warnings and Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped

    In unity 5 I recompiled the shaders and I have no error after I disabled the old plugin, restarted unity and activated the new one
    But everything is white.

    PS: Need to copy GFSDK_SSAO.win64.dll in test_project folder root
     
    Last edited: Mar 19, 2015
  40. gratyanolteanu

    gratyanolteanu

    Joined:
    Nov 18, 2014
    Posts:
    24
    In new scene when I attache the .cs to the camera I get this error:
    NullReferenceException: Object reference not set to an instance of an object
    HBAOPlus.OnRenderImage (UnityEngine.RenderTexture source, UnityEngine.RenderTexture destination) (at Assets/HBAO/HBAOPlus.cs:110)
     
  41. gratyanolteanu

    gratyanolteanu

    Joined:
    Nov 18, 2014
    Posts:
    24
    Some how Is working right now...

    I think is working because now the scene use the standard material. The Original material is completely white
     
    Last edited: Mar 19, 2015
  42. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Is anybody manage to build with HBAO+? i got weird depth artifact
     
  43. gratyanolteanu

    gratyanolteanu

    Joined:
    Nov 18, 2014
    Posts:
    24
    Last edited: Mar 24, 2015
    shkar-noori likes this.
  44. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Ah sorry, should make myself clearer, not about build the plugin for unity, it already work in editor. But build any executable with HBAO+
     
    lka69 likes this.
  45. TrollHachem

    TrollHachem

    Joined:
    Dec 25, 2012
    Posts:
    65
    Bundle the GFSDK dll with the executable
     
    Reanimate_L likes this.
  46. gratyanolteanu

    gratyanolteanu

    Joined:
    Nov 18, 2014
    Posts:
    24
    HBAO+ Provides a modern alternative to SSAO and require Shader Model 4.0. If you build the game for pc and you'r graffick card support SM 4+ it should worck.
    Windows build
    https://www.facebook.com/photo.php?fbid=738288849622082&set=pcb.738288892955411&type=1&theater
    https://www.facebook.com/photo.php?fbid=738288846288749&set=pcb.738288892955411&type=1&theater
    the HBAO you see far away reprezent the mesh edges. With Bias=0.2. and blur radius 2. units scale 1.
    You need to increase the bias if you want that edges to be fade....
     
  47. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Ahh....i've missed this one....thanks man
     
  48. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    950
    I did the same thing but it just crashed as soon as I ran the scene.
     
  49. gratyanolteanu

    gratyanolteanu

    Joined:
    Nov 18, 2014
    Posts:
    24
    Maybe you did something wrong, :(
     
  50. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    doesn't work I get lots of red errors