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

Avoiding Ambient Occlusion on emmisive/lit materials

Discussion in 'General Graphics' started by andyz, Jan 13, 2020.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,243
    I am guessing this is covered in the standard pipelines but I am using a custom deferred (legacy) one right now!
    How do you normally mark pixels as emmisive to avoid them being shaded by effects like ambient occlusion?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,321
    This isn’t handled by any of the built in shaders. In fact using the non-legacy deferred rendering it’s impossible (without significant modifications to both the Standard shader, and the SSAO post processing, and even then it’s just an approximation). If you have emissive and AO, the emissive is modified by the SSAO.

    With the legacy deferred setup you could modify the SSAO to happen sooner, during the lighting pass, and have the final output to a temporary screen space texture. Then you’d have to have your final pass sample from that texture so it can apply it to the ambient lighting and not the emissive.

    The hack technique, the one that works with deferred and forward, is to have the shaders abuse the alpha channel or some free gbuffer channel to store what areas are emissive or not, and mask the SSAO based on that.

    The next option is to make all emission you don’t want to be affected by SSAO be separate transparent materials that have their own meshes rather than doing the emission on the opaque pass.
     
    andyz likes this.