Search Unity

Ambient Occlussion shows through Unlit shader

Discussion in 'Shaders' started by BIGTIMEMASTER, Sep 14, 2019.

  1. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    Why does this happen?

    I see a fix that you can add a shadow caster pass to solve this, but why does that solve it? Can this be explained simply?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    SSAO uses the camera depth texture to calculate the occlusion.

    The camera depth texture is generated by rendering all opaque objects in the scene using their shadow caster pass.

    Since the unlit shader doesn’t have a shadow caster pass, it isn’t rendered into the camera depth texture, so the SSAO is for the objects behind the unlit object.

    Adding a shadow caster pass to an unlit shader will make the AO apply to the shape of the unlit object. If you don’t want it to be applied at all move the unlit object to the transparent queue range (2500+).
     
  3. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    perfect explanation. Thanks @bgolus