Uploaded March 2025 | Updated November 2026, 1 day ago
In this shader tutorial, I show how to write the code required to bring screen space ambient occlusion into our custom lighting model in Unity. Once available we can use it in the traditional way to darken the ambient - but we can also use it in other, unique ways to get just the look we're looking for.
Here's the code for the Custom Function node:
#if defined(_SCREEN_SPACE_OCCLUSION) && !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(SHADERGRAPH_PREVIEW)
float ssao = saturate(SampleAmbientOcclusion(ScreenPos) + (1.0 - _AmbientOcclusionParam.x));
IndirectAO = ssao;
DirectAO = lerp(1.0, ssao, _AmbientOcclusionParam.w);
#else
DirectAO = 1.0;
IndirectAO = 1.0;
#endif
Take a look at the playlist for the whole series:
youtube.com/playlist?list=PL78XDi0TS4lGnGa7L2X4o3UV-XYZEKNwj
Here's last week's video on making our custom lighting model modular:
youtu.be/Ak40WLdV3ic
Shader Book Recommendations
bencloward.com/resources_books.shtml
------------------------------
Theme Music
Peace in the Circuitry - Glitch Hop
teknoaxe.com/Link_Code_3.php?q=1526
Background Music
Speo - The Little Things
youtube.com/watch?v=kvCYuyyLgC0
#UnrealEngine #shadergraph #Unity
In this shader tutorial, I show how to write the code required to bring screen space ambient occlusion into our custom lighting model in Unity. Once available we can use it in the traditional way to darken the ambient - but we can also use it in other, unique ways to get just the look we're looking for.
Here's the code for the Custom Function node:
#if defined(_SCREEN_SPACE_OCCLUSION) && !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(SHADERGRAPH_PREVIEW)
float ssao = saturate(SampleAmbientOcclusion(ScreenPos) + (1.0 - _AmbientOcclusionParam.x));
IndirectAO = ssao;
DirectAO = lerp(1.0, ssao, _AmbientOcclusionParam.w);
#else
DirectAO = 1.0;
IndirectAO = 1.0;
#endif
Take a look at the playlist for the whole series:
youtube.com/playlist?list=PL78XDi0TS4lGnGa7L2X4o3UV-XYZEKNwj
Here's last week's video on making our custom lighting model modular:
youtu.be/Ak40WLdV3ic
Shader Book Recommendations
bencloward.com/resources_books.shtml
------------------------------
Theme Music
Peace in the Circuitry - Glitch Hop
teknoaxe.com/Link_Code_3.php?q=1526
Background Music
Speo - The Little Things
youtube.com/watch?v=kvCYuyyLgC0
#UnrealEngine #shadergraph #Unity










