I’ve noticed that SSAO does not apply on top of emissive materials, which is realistic, but I need to change that for getting the look I want to get in my game.
I’ve searched in the engine to see where I could change that behavior:
In *GetDynamicLighting *in DeferredLightingCommon.usf the SSAO is applied to the lighting. The output of a material is calculated in *FPixelShaderInOut_MainPS *in BasePassPixelShader.usf, and if I understand it correctly the lighting is calculated first, and then based on that the material pixel shader runs. Then its just doing Color += Emissive to add the emissive color to the color of that pixel.
So no matter what the result of the lighting was, it adds the emissive value to the color of that pixel. If SSAO made the pixel black before, the value is offset by the emissive color and its no longer black. As far as I understand it, in FPixelShaderInOut_MainPS() I can no longer access the screen space data, so I can’t just multiply the emissive by the SSAO there, which would fix my problem. I basically just need to do *Emissive = ScreenSpaceData.AmbientOcclusion somewhere to get what I want, but I don’t know where that would be possible.
I don’t want to change anything else, so regular shadows should still not affect the emissive material, only SSAO should be added on top of that.
Any ideas how this could be done?