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

URP Post-Processing: Ambient Occlusion availability?

Discussion in 'Universal Render Pipeline' started by ivank, Sep 6, 2019.

  1. ivank

    ivank

    Joined:
    Nov 16, 2013
    Posts:
    105
    Hello, its great that URP is now equipped with its own set of post/processing effects. However the AmbientOcclusion effect is still currently missing and is not even mentioned in in-progress documentation on Github.

    Can we get any info about the Ambient Occlusion effect status - it means will it make it into 2019.3?

    Thanks
     
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,237
    Ambient Occlusion isn't available because URP doesn't render a geometry normals texture, which is the pillar of any ambient occlusion effect:



    I don't know if they're adding the option (can't see anything related on GitHub). But URP is apparently also getting Deferred rendering in the future, where normals are always available, making AO work out of the box. So I suppose they're either going to implemented it at some point, or wait until Deferred rendering is in place.
     
  3. gustavolsson

    gustavolsson

    Joined:
    Jan 14, 2011
    Posts:
    339
    An idea: calculate an approximate normal from the depth texture (that is available) and use that? If you are comfortable with creating your own post-process effect that is.

    Useful article on the subject (especially "Cetral differences for Terrains"): http://www.iquilezles.org/www/articles/normalsSDF/normalsSDF.htm
     
  4. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    rekindledphoenix likes this.
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    yes, it supports MultiScaleVO
    which relies on the depth buffer only as far as i remember.

    it was not really stable (image wise) but under certain conditions better than nothing.
    doing an extra normal pass or using multiple rendering targets when rendering forward lighting sounds a bit bandwidth heavy to me, so i guess we have to live with a rather simple ssao solution.
     
    Ruslank100, OfficialHermie and noio like this.
  6. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    @larsbertram1 The hack I posted above simply re-enabled Unity's own PPv2 AO under LWRP. But as 2019.3 has ditched PPv2 I suppose it won't work anymore. Are there currently any working URP 2019.3+ solutions that you know of? Any of your assets?
     
    noio likes this.
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    i don't know.
    i just wanted to clearify that normals are not mandatory if you use some special SSAO techniques.
    they are super good to have but maybe just too expensive – at least in case of URP and forward.
     
    Ruslank100 and Matt-Cranktrain like this.
  8. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    MadeFromPolygons likes this.
  9. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Unity really needs to sort out this custom post processing asap. URP seems like incomplete and feels like it has gone backward now.
     
  10. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    185
    I can't believe what a mess it is!, I mean SSAO is a trivial old school method and there is no proper implementation with URP. So, what is the best way to get normals? if URP is so flexible how come you can't even do SIMPLE SSAO???
     
  11. create3dgames

    create3dgames

    Joined:
    Aug 20, 2012
    Posts:
    275
  12. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Source files linked through pastebin.
     
    MadeFromPolygons likes this.
  13. create3dgames

    create3dgames

    Joined:
    Aug 20, 2012
    Posts:
    275
    o_Oo_Oo_Oo_O
     
  14. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
  15. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
  16. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Maybe it's been a month because it's ready and just waiting for another branch to be merged into master first. Could be close. You never know. Deferred lighting in URP is apparently ready to be merged, according to a recent commit.
     
  17. DiveshNaidoo

    DiveshNaidoo

    Joined:
    Apr 1, 2018
    Posts:
    23
    Ruslank100 and Matt-Cranktrain like this.
  18. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    If I may, I don't think SSAO is a good fit for URP. If we get deferred, it'll maybe be fine since a big chunk of the performance cost will be paid regardless, but other than that, it's generally an effect that makes things look actively worse and is most definitely not worth the huge performance cost.

    Especially with low settings, the only thing it does is make corners look like the have mold. IMO if your game needs SSAO to look good, you are probably doing something wrong. With all that said, I would be interested to find out why people keep asking so much for it.
     
  19. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    I very much like the look of AO, so I disagree with you.
     
    PutridEx, AlexMasse, JoeW97 and 11 others like this.
  20. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    This is pretty much the primary reason for switching from URP to HDRP. All shadergraphs still work once master node is swapped out, I am able to get same graphics as before but with actual ability to perform this effect and many others. I also find that in general, HDRP is actually easier for me to use than URP which seems to have far more issues version to version. I also no longer feel like I have downgraded my graphics by using SRP, which I definately felt with URP

    HOWEVER using the custom normals texture by @alexanderameye works for URP! So you can build a AO on top of that.

    @alexanderameye please make more tutorials, your edge detection tutorial was great but really waiting for that follow up tutorial that does it as an image effect! Please keep them up you could easily become a major player on the tutorial scene if you fill your site with a little more content!
     
  21. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Yeah maybe I'll do that, but just feels really weird doing a low-poly game in HDRP... I feel like they did the change to SRPs like a year too early.
     
    Ruslank100 and chadfranklin47 like this.
  22. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    Not at all, your just getting a larger set of features. Can make any game you want in it, low poly included. However you can always try generating custom normal texture and then writing an AO effect on top of that, that will work just fine too and above a user has linked to a tutorial on the normal texture part.
     
  23. Mickle_S

    Mickle_S

    Joined:
    May 9, 2015
    Posts:
    2
    I wrote a basic ScriptableRenderFeature based on the SSAO implementation from the SRP github. Just add it to your RendererData and plug in the shader and noise texture and it should work. It's not a great implementation: it has to blit twice because blitting can't have the same source and destination.

    Screen Shot 2019-11-21 at 1.34.02 PM.png

    ScriptableRenderFeatures are a really neat way of extending the pipeline for things like this, but the documentation isn't great and you kind of have to do a lot of digging through the code to understand how to use them.

    Happy to answer questions
     

    Attached Files:

  24. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    @Soul_Without Looks cool!

    Just add it to your RendererData and plug in the shader and noise texture and it should work

    How do I go about adding it to my RenderData, completely new to me.

    @GameDevCouple_I Why did you choose HDRP over the old "default"? Was more leaning towards just going back to that, since I assumed HDRP would add a lot of bloat I dont need to the project.
     
  25. Mickle_S

    Mickle_S

    Joined:
    May 9, 2015
    Posts:
    2
    When you first created your Universal Render Pipeline Asset (the one you select in project settings) it should have created another asset for the renderer. In the inspector window for that asset click the plus in the Renderer Features section and you should see the new feature
     
    mrCharli3 likes this.
  26. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Screenshot_5.jpg View attachment 517100
    @Soul_Without
    Edit: I downloaded 2019.3 but unfortunately it does not pick up your script, see attachment.
     
    Last edited: Nov 21, 2019
  27. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    According to the public roadmap AO is only still being considered. Confusing.
     
    futurlab_xbox and cxode like this.
  28. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    And reflection probe box projection in a year or so, which is kind of bizarre, since it's roughly ten lines of shader code and it runs even on 5 year old mobile phones, so I don't know why they need a year.
     
    Ruslank100 and cxode like this.
  29. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    400
  30. AlejUb

    AlejUb

    Joined:
    Mar 11, 2019
    Posts:
    25
    There are some solutions out there that don't use the normals buffer.
    The first Crysis SSAO was only based on depth textures and a very low sampling ratio.
    I remember a Toy Story 3 SSAO (http://advances.realtimerendering.c... 2010 Advanced RealTime Rendering Course).pdf) managed to get also low count sampling for SSAO
    There's also Neural Network AO that uses a block of depth pixels for a lookup texture for the AO result.

    If URP is also aiming for mobile, I would rather have also these options instead of only a high quality-ish one that requires compute shaders, normals, depth, etc.

    Also the issue with rolling 'our own' AO solutions is that Unity's Post procesing (PPv2 or URP-builtin) does A LOT of stuff at their final Uber shader, where they start mixing and combining previously prepared results (bloom results, dof results, motion blur results, etc).
    It would be nice if we could write to those 'target textures' to be later used in the final Uber shader that way we could roll our own solutions too (provided a set of rules of how those resulting textures need to be set for compatibility with the Uber shader).
     
    Ruslank100 likes this.
  31. AlejUb

    AlejUb

    Joined:
    Mar 11, 2019
    Posts:
    25
    Wow! Thanks a lot for this contribution.
    Would it be possible to add a 'downsample' option, to make it run on a lower res target?

    Had a question, if you happen to be acquainted with these RenderPassFeatures, have you found a way to be able to feed a render target result from one blit to the next? Suppose I add a downsampling pass and leave that result on a temporary render target (that's not released), to then use it on a next blit pass feature to, say, gaussian blur it... so on and so forth.
     
  32. pachermann

    pachermann

    Joined:
    Dec 18, 2013
    Posts:
    133
    Thank you for sharing this!!!
     
  33. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    The wait is over! HBAO is now URP friendly. Working beautifully. What a difference a good AO can make.
     
    Repirobito, noio, bmouret and 3 others like this.
  34. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Edit nvm im stupid.
     
    Last edited: Mar 3, 2020
  35. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    For the record, @jimmikaelkael has said that HBAO will see performance gains once Unity adds view normals. But working fine for me.
     
  36. soorya696

    soorya696

    Joined:
    Dec 13, 2018
    Posts:
    71
    is it possible to enable post-processing via script?
     
  37. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    You can enable/disable the PP volume, for example. But you should ask in a different thread because this one is more specifically about ambient occlusion in URP.
     
    soorya696 likes this.
  38. Regone

    Regone

    Joined:
    Aug 1, 2014
    Posts:
    35
    Is there a free alternative? :\
     
  39. pachermann

    pachermann

    Joined:
    Dec 18, 2013
    Posts:
    133
    intergrated lightmapper can do AO baked into Lightmap
     
  40. Regone

    Regone

    Joined:
    Aug 1, 2014
    Posts:
    35
    For some reason it doesn't bake for me in URP, are there any steps to do it?
     
  41. pachermann

    pachermann

    Joined:
    Dec 18, 2013
    Posts:
    133
    if you for example use a directional light and set it to Bake and the strength (brightnes) is very low it still bakes you AO into Static objects.
     
    Last edited: Apr 8, 2020
    AlejUb likes this.
  42. ykswobel

    ykswobel

    Joined:
    Apr 5, 2018
    Posts:
    57
    no news about AO post processing in URP?
     
  43. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    There is if you check the github. It will be out quite soon.
     
  44. Komikom

    Komikom

    Joined:
    May 20, 2015
    Posts:
    38
    Link?
     
  45. Matt-Cranktrain

    Matt-Cranktrain

    Joined:
    Sep 10, 2013
    Posts:
    129
    Komikom likes this.
  46. pachermann

    pachermann

    Joined:
    Dec 18, 2013
    Posts:
    133
    i just used the super affordable HBAO from assets store it's amazing it's fast i love it!!!
    using URP 7.2.1
     
    Last edited: Apr 24, 2020
    noio, transat and Matt-Cranktrain like this.
  47. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    It will be faster still when it can tap into depth normals, the dev told me.
     
    pachermann likes this.
  48. jjiangweilan

    jjiangweilan

    Joined:
    Mar 31, 2018
    Posts:
    19
  49. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
  50. jjiangweilan

    jjiangweilan

    Joined:
    Mar 31, 2018
    Posts:
    19
    Oh ok, I see. I was looking at the global illumination part.