Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Specular Occlusion?

Discussion in 'High Definition Render Pipeline' started by CihanGurbuz, Sep 4, 2020.

  1. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    Hello. I've only been using Unity for a few months. I used to use Unreal, and I stopped using it for a few reasons. But Unity didn't have the same quality in terms of graphics compared to Unreal. I thought it was because of dark surfaces not being reflected well.

    I could not find any information on the forums about this and developed this method.
    sas.jpg

    UnityCapture.gif




    Here's my question. What I have done seems right, but is it? Or is there an easier solution I haven't seen?

    Thanks in advance.
     
    Last edited: Apr 29, 2021
    newguy123, PutridEx, Neonage and 3 others like this.
  2. Passeridae

    Passeridae

    Joined:
    Jun 16, 2019
    Posts:
    388
    I'm not sure about your method (though seems right, judging by the first GIF). I usually bake bent normals for my geometry in Substance Designer and use them for this purpose.

    The last screenshot looks really good, not worse than Unreal, to my mind.
     
  3. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    I don't know how to make the situation better. Finally, I did a few tries. As such, the glare on the dark surfaces has decreased considerably. For more realistic scenes I hope unity does something. https://imgur.com/a/8D4Um4C


    Unity Default Lit
    default.jpeg

    Unity Specular Occlusion Edit
    edit.jpeg

    Unreal
    1920x1080 unreal.jpg

    Shader Edit
     
    Last edited: Apr 6, 2021
    jiraphatK, LumaPxxx and koirat like this.
  4. Passeridae

    Passeridae

    Joined:
    Jun 16, 2019
    Posts:
    388
    Unity has already done something for specular occlusion. It's called "Specular Occlusion Mode" and you can find it in the advanced tab of your shader:

    As I previously said, you're supposed to provide a bent normal map to your shader, plugging it into the respective input. You can also add an AO map which is supposed make the occlusion effect even stronger.

    Furthermore, you can enable SSR to ground your objects better.
     
  5. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    Unfortunately, these things do not make the scene better.(AO, SSR, Bent Normal) Also SSR, AO, Bloom off in unreal and unity. these things have a cost and i love bake light and maybe i won't use ao. I can only use bent normal for moving objects.

    What do you think should I do to make my scene look as good as unreal?
     
  6. Passeridae

    Passeridae

    Joined:
    Jun 16, 2019
    Posts:
    388
    Yep, they do, but in order to match your offline render reference, you have to enable at least SSR. Preferably the new one (PBR Accumulation). The reflection on the floor is the most obvious thing that both Unity and Unreal lack in comparison to Blender. Because of this your objects "float" above the surface. They are just a bit more shadowed in Unreal, but the general lack of connection to the surface is the same.

    Are you sure that you've correctly baked your bent normals? They work perfectly for me, adding all the specular occlusion I need. I've been struggling with the same problem for a while too, but bent normals + a bit of AO completely solved it for me, so it's very strange that they don't work in your case. I do bake lighting as well and I understand that once you've baked it you don't need any fake AO, but nevertheless, I've found it useful to add a bit of AO just for the sake of specular occlusion. And I'm not talking about the realtime ambient occlusion that you enable as an override in your HDRP volume. I use an AO map that comes with a material (which you put in the green channel in the Mask Map) and then I mix it in Shader Graph with an AO Map baked in Substance Designer for the whole object. Then I tune it to look realistic and aesthetically pleasing (usually this means low values) and in conjunction with Bent Normals it gives very good results.

    Why can't you use it with static objects as well?
     
    pachermann likes this.
  7. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    Because moving objects cannot be baked! :)


    You constantly ask me to use bent normal. bent normal only concerns the owner object. What will do the reflection blocking between the table and the floor? I can't create bent normal of the whole map!


    I did not see bent normal being used in Unity's last released scene! Also, reflection leak is present in this scene!



    unfortunately ao, ssr or something else doesn't solve this. I will try what you say. I don't think anything will change. Thanks for your interest.
     
  8. pierred_unity

    pierred_unity

    Unity Technologies

    Joined:
    May 25, 2018
    Posts:
    428
    Hey,

    Exposure-based AO is a technique I've already seen and used in the past, so what you've done in your shader works as intended. Is it correct? One might say nothing is truly correct in rasterization... So as long as you're happy with the results and it doesn't introduce artefacts or unwanted behaviours when you start modulating the exposure (especially when it goes negative).

    What's your reflection probe setup in your unity scene however? Did you place any local reflection probe in the room? If you didn't place any, the reflection of the sky will leak inside the room and greatly overpower any baked occlusion in the lightmaps. Judging by the amount of blue light/reflection leaking on the ceiling beams, it seems there is none or it requires some adjustments.


    Regarding the HDRP template, it only uses baked reflection probes (and no SSR for now), so you will indeed see some reflection leaking here and there, especially if you start placing the camera in really odd places that aren't meant to be accessible by the player.
     
  9. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    This word broke my heart. :)

    Unity Default Lit.
    (I also turned off "sky reflection" in hdrp default settings.)


    The question I'm looking for the answer is this.

    Same scene same materials same light same reflection probes Same post precess. but unity somehow looks bad compared to unreal. When I compared the two scenes, I came to the following conclusion. Unreal controls the reflection of dark surfaces very well. I found the above method for Unity and asked if this was true. I think I got the result I wanted. I just wanted to consult on the accuracy of this. Because I'm interested in level design. not a shader programmer. :)
     
    newguy123 and pierred_unity like this.
  10. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,753
    i don't think you can do anything else to match UE4 lightmap here. If i'm not mistaken UE4 volumetric lightmap also bake static bent normal for the whole scene for specular and directional occlusion which unity doesn't
     
    CihanGurbuz likes this.
  11. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    Yes, I've been thinking about that lately. It was the first time I saw a different lightmap in Unreal, I didn't understand why. I realized when I switched to Unity, this colorful lightmap has a meaning. it carries different information on each channel. :)



    I think I got the answer to my question more than enough. Thanks to all who answered and interested.
     
    keeponshading and Reanimate_L like this.
  12. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,753
  13. LeFx_Tom

    LeFx_Tom

    Joined:
    Jan 18, 2013
    Posts:
    78
    CihanGurbuz likes this.
  14. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,753
    oh right, bakery have new volumetric lightmap now
     
  15. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    yes, I knew about this add-on, but I didn't see that in the description.

    - Supports directional baking (bump/specular) with 4 modes:

    I can't pay $ 55 for this plugin right now. :) The solution I found is giving good results for now. Thank you for reminding me of this.
     
  16. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    this solution just generates a bent normal map of the object. What I need is to bake all the objects together. The solution I have already found gives good results for now.
    Thanks. :)

    1208x903 2.gif
     
    Last edited: Jan 13, 2021
  17. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    560
    Hi @CihanGurbuz - as this thread is quite long and complex - could you summarize the solution you landed on? Is it essentially the graph you posted at the top? If you could post the actual file to help others that would be amazing.
     
  18. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,753
    Which solution if i may ask? i'm also interested in scene specular occlusion
     
  19. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,966
    The idea is you feed a tweaked baked GI to the specular mask input.
     
    Reanimate_L and CihanGurbuz like this.
  20. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,753
    Ah, just as the shader graph screenshot he posted above then?
     
  21. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,966
    I believe so, yes.
     
  22. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    Of course.

    You should know first. You cannot use Unity's standard shaders. You have to create your own shader layout.

    You must first create a lit shader graph and a sub graph.
    Adsız2.png

    I did it like this.
    Adsız3.png

    Add this to the sub graph you created.
    Adsız4.png

    then you have to place this sub graph inside the main shader that it creates. I did it like this.
    Adsız.png
    then you need to create your materials on this shader. sample.
    Adsız5.png

    very simple method. I hope I could explain. :)
     
  23. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,753
    Speaking of i believe you can extract baked scene AO now, might give better result than using baked indirect lightmap
     
  24. AlexTuduran

    AlexTuduran

    Joined:
    Nov 26, 2016
    Posts:
    26
  25. ratonmalo

    ratonmalo

    Joined:
    May 8, 2020
    Posts:
    4
    Sadly this only works in HDRP and not URP right ?
     
  26. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    595
  27. CihanGurbuz

    CihanGurbuz

    Joined:
    Apr 30, 2020
    Posts:
    25
    @ratonmalo
    I've never tried it in URP. If there is specular occlusion and exposure option, you can use it.

    Hi @blueivy
    I think I tried orel's shader a few months ago and didn't get good results. I've always seen filamented's shader but never tried it. I tried that shader today. It looks really nice and is what I want, but I still haven't found a solution for HDRP. (Except Bakery) My solution is not working properly. (it just saves the day)
    Thanks.
     
    blueivy likes this.
  28. ratonmalo

    ratonmalo

    Joined:
    May 8, 2020
    Posts:
    4
    I don't see the specular occlusion in the fragmentation node in shader graph (URP) so I guess it's not possible.
     
  29. EricFFG

    EricFFG

    Joined:
    May 10, 2021
    Posts:
    99
    Is it somehow possible to grab the SSAO or shadow pass and diminish specular occlusion there?
     
  30. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,099
    Man, so this is what's been annoying the hell out of me for so long. I always wondered how unreal doesn't require reflection probes for proper lighting, but I have to go through this hell of a struggle in HDRP. The worse part is when it's a big level, it becomes unbelievably annoying.

    Then again, seeing how unity's GI is struggling with just having it work I'm not holding my breath for them to take this up :)

    thanks for the shadergraph.
     
    newguy123 and CihanGurbuz like this.
  31. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    994
    Mmm i'm pretty noob with HDRP but i can see in your images that there is in fact light leaking in the unreal version (the ceiling) and in fact i think the unity version looks better (nop, i'm no a unity fanboy xD). Lightmaps resolution can be a game changer, really, you need to understand those settings, i really recommend that you pay close attention to what @pierred_unity says.
    Also reflections are a very important thing in your blender reference, so you need to work on reflections too.
    Also, is the light at the same value on blender, unity and unreal? (light looks different) Unity has this options where you can match real camera's values and there is also some tools to tweak indirect GI, reflections and all that stuffs. Try also reflection probes ;)

    Unity can achieve amazing graphics. Take a look at this:


    That is just one person doing all that stuffs, so...
     
    Last edited: Sep 15, 2022
  32. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    I have two projects both running on 2022.2.0b3.
    One of them has correct specular occlusion, the other one not:

    upload_2022-9-22_8-41-4.png

    I compared all hdrp-settings and volume parameters which are identical.

    Does anyone have a clue what may prevent the second one to work correclty?

    EDIT:
    It was the dimmer being < 1 in the lights shadowmap settings.
    Setting it back to 1 solved it.
     
    Last edited: Sep 22, 2022
    newguy123 and Qleenie like this.
  33. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    609
    I also recognized that having the dimmer smaller 1 leads to weird effects with indirect specular; for me it was on a hair shader. This seems like a bug.