Avoiding Ambient Occlusion on emmisive/lit materials

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?

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.

1 Like