Search Unity

Horizon Based Ambient Occlusion - HBAO image effect

Discussion in 'Assets and Asset Store' started by jimmikaelkael, Feb 21, 2016.

  1. Richmar1

    Richmar1

    Joined:
    Mar 15, 2015
    Posts:
    7
    That's great to hear! Until then, rz_0lento's suggested changes worked. HBAO is now rendering!
     
  2. Richmar1

    Richmar1

    Joined:
    Mar 15, 2015
    Posts:
    7
    Just to clarify how to make HBAO work in urp 12:

    1.) Comment out line 34 from Assets\Horizon Based Ambient Occlusion\SRP\URP\Editor\HBAOEditor.cs that contains
    hasAdvancedMode
    override.

    2.) On line 375 from Assets\Horizon Based Ambient Occlusion\SRP\URP\Runtime\HBAORendererFeature.cs
    Replace this:
    Code (CSharp):
    1. source = new RenderTargetIdentifier("_CameraColorTexture"); // <----Original
    With this:
    Code (CSharp):
    1. source = renderingData.cameraData.renderer.cameraColorTarget;
    3. At this point, HBAO will render, but it won't render correctly. In the HBAO override for the Post Process Volume, make sure to change the Per-Pixel Normals option to one of the Construct variants.

    Thank you again rz_0lento for pointing me in the right direction!
     
  3. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,148
    As extra note, those Per-Pixel Normals from Camera didn't really work proper on URP 10 either, have to use reconstruct versions. In addition if now using URP 12 deferred they have extra option on URP Renderer Data asset called "Accurate G-buffer normals" which now totally break HBAO if it is still getting normals from camera :) Reconstruct -variants work fine still.
     
  4. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,148
    Would be nice if this option was in URP too now that it has deferred mode (URP 12+).
     
    jimmikaelkael likes this.
  5. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    654
    This method was strongly tied to how standard render pipeline worked.

    For SRP I'm expecting Unity to allow access to a global ambient occlusion texture so that we can write ourselves in it instead of the builtin AO (this should be done at early stage, before opaque, so we need the correct injection points in the pipelines). Then like it is actually done in HDRP the materials can access the occlusion term.
    The benefits are that it is a lit AO and it can also be disabled per material.

    EDIT: please also take a look at this thread https://forum.unity.com/threads/mis...nt-in-hd-render-pipeline.979803/#post-7376441
    HDRP does not currently have before opaque injection point, nor before atmospheric scattering
     
    Last edited: Aug 20, 2021
    rz_0lento likes this.
  6. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    654
    This is now available on URP10+ in HBAO v3.4. There's a new field at the top of general settings which allow for LitAO mode.
     
    rz_0lento likes this.
  7. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,634
    Nice work! SSAO is now dead to me :D
     
  8. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    669
    Hell can you please talk more on what is the LITAO and should I use it over the normal HBAO you have? Does it look better, does it cost the same, what other benefits?
     
  9. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    654
    With this mode the AO is applied to lighting at material level. It is more physically correct and won't cost more perfs. Another benefit is that you can exlude AO in your custom shaders.

    To support AO in your custom shaders, this is done the exact same way as for Unity's SSAO, please refer to this page:
    https://docs.unity3d.com/Packages/c...iversal@10.2/manual/upgrade-guide-10-0-x.html

    EDIT: it seems there's a missing bit of information in the doc about the required passes in your custom shaders; The Depth pass is required in any case and the DepthNormal pass is required only if you intend to use per pixel normals "Camera".
     
    SilverStorm likes this.
  10. OMGOMGXAXA

    OMGOMGXAXA

    Joined:
    Apr 2, 2016
    Posts:
    7
    I have the same error in HDRP (unity 2021.2.0b8) :
    Assets\Horizon Based Ambient Occlusion\SRP\URP\Editor\HBAOEditor.cs
    that contains "hasAdvancedMode override" not working.

    How to fix this in HDRP pipeline? :)
     
  11. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    363
    In Unity 2021.2.0b10 I think at certain camera angles the results is backwards with camera normals?

    upload_2021-9-7_21-13-38.png

    upload_2021-9-7_21-13-51.png

    Compared to reconstruct
    upload_2021-9-7_21-15-49.png

    looks fine at this angle
    upload_2021-9-7_21-14-29.png
    upload_2021-9-7_21-14-42.png

    Compared to reconstruct it looks the same

    No idea whats happening :O

    This is in forward mode
     
  12. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    363
  13. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    654
    Camera view normals on URP were added not so long ago. I added the option for the future but it is not reliable actually (I have let reconstruct mode as the default option). It's what unity outputs... And generally I do not support betas: I can not even launch the version you mentionned without it crashing instantly on my system.

    I'm really sorry for the inconvenience.
     
  14. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    363
    Ah fair enough, hopefully it comes out of beta soon XD

    The new features in URP 12 are simply too good to pass up for me so I figured I'd just jump on it.

    Reconstruction works fine for now so I'll just do that. I hope you get 2021.2 to work soon!
     
  15. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    250
    I'm having issues with URP in 2020.3.3f1. I created a new project, installed URP 10.5.1, installed the current version of HBAO, created a new URP pipeline asset, added HBAO to the Renderer features, and enabled the depth texture but it doesn't work in the demo scene. Did I miss anything?

    If I remove the pipeline asset from the graphics setting (basically going back to built in), it works but as soon as I assign the pipeline asset to the SRP field, it stops. The scene renders fine, it's just like the asset is not doing anything. I do have Post Processing checked on the scene camera.
     
  16. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,148
    @reggie_sgs Make sure you apply the HBAO to the right URP data asset (the one in use atm).
     
  17. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    250
    Yes, it's a new project and there's only one so that's not it.
     
  18. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    654
    I tried on these specific versions and had no issue.

    - you did not mention you unpacked HBAO's embedded URP package, so I hope you're not adding Unity's builtin SSAO renderer feature
    - please consider that the demo scenes for URP and Standard pipeline are not the same, you seem to be looking into the same demo scene when you switch the pipeline: it doesn't work like that
    - try removing renderer feature, removing HBAO package and reinstall
     
  19. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,148
    Just to make sure, can you add SSAO renderer feature to the same URP data asset you've put HBAO and see if the SSAO applies? If you can't see that one either, it's probably still the wrong asset. Also if it's the right asset, make sure HBAO is actually enabled by upping the intensity above 0 (or whatever naming convention it uses for this).
     
  20. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    250
    Thanks, I didn't realize the SRP package added a different demo scene, I just missed that. After switching to the correct demo scene, I was able to get it to work. Thanks!
     
  21. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    657
    Hi, I am using HDRP13 with HBAO and all works very good (Good job!). But is there a way to render AO before Fog? The old method doesn't seem to be working (I can't find the lines anymore).

    Also, I hear that they added injection points for custom postprocess.
    https://docs.unity3d.com/Packages/c...13.0/manual/Custom-Pass-Injection-Points.html

    Is this relevant for HBAO and if so, how do I use it to render HBAO before fog? Thanks!
     
  22. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    657
    Hey another thing, in HDRP13, (I am not sure if it also happens in HDRP12) but with DLSS on, optimal settings turned off for DLSS, and Dynamic res set down to below 1, the screen renders wrong.

    https://forum.unity.com/threads/dls...l-settings-is-unchecked.1179922/#post-7559440

    Check this thread out that I posted, I initially thought it was HDRP, but it looks like it is HBAO +HDRP13.
    Would really appreciate it if you can provide a workaround, or update to the code.

    Thanks!
     
  23. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    654
    Hi, sadly I can not run recent unity editor versions on my computer, it crashes instantly. And honestly, I generally never support betas because it is too much broken.

    Yeah, the document you are showing are the available injection points. I know them all and if you look closely there's no custom post process injection point available just before fog, I'm so sorry for the inconvenience.

    Thank you very much for the feedback! Now I know that HBAO doesn't actually get proper render size for DLSS, but, as stated above I have no ETA for a fix.
     
  24. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    657
    NP mate, honestly you have one of the best support for your product so I am not worried about this getting fixed in the future. Just wanted to relay the message so that you are aware.

    Also, it breaks in HDRP12 with DLSS, so, so far all available versions of DLSS + HBAO is broken at the moment.
    I am guessing this is related to the newly introduced upscaled TAA but I haven't looked into the code so your guess is as good as mine :)

    Cheers!
     
  25. mrekuc

    mrekuc

    Joined:
    Apr 17, 2009
    Posts:
    109
    I understand it is probably not ideal for mobile but I do have a question regaurding this package. I have the same application running on a few Android devices and a few iOS devices. I get about 18fps on Android but getting 60 fps on iOS with it. Just curious what the difference is or does SSAO on Android just suck compared to iOS?
     
  26. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    654
    I'm not used to mobile but let me guess.
    Behind the platforms you mentionned there is hardware and SSAO computation heavily rely on GPU. Old graphics benchmarks https://www.anandtech.com/show/10685/the-iphone-7-and-iphone-7-plus-review/4
     
unityunity