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

Question URP 10 - Ambient Occlusion in custom (unlit) shader

Discussion in 'Shader Graph' started by Qriva, Mar 21, 2021.

  1. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,296
    I have toon shader based on unlit shader graph. I want to use SSAO feature added in URP 10+.
    How to correctly implement this in shader graph?

    I found this upgrade guide where SSAO is mentioned, they said to add keyword and to use GetScreenSpaceAmbientOcclusion, so I made custom function like this:
    Code (CSharp):
    1. #ifdef SHADERGRAPH_PREVIEW
    2.   Direct = 1;
    3.   Indirect = 1;
    4. #else
    5.   Direct = GetScreenSpaceAmbientOcclusion(ScreenUV).directAmbientOcclusion;
    6.   Indirect = GetScreenSpaceAmbientOcclusion(ScreenUV).indirectAmbientOcclusion;
    7. #endif
    but it does not work. What did I do wrong?

    Additional question - What is the difference between direct and indirect AO and how to use them?
     
    Last edited: Mar 21, 2021