Access depth buffer (and scene color) from ISceneViewExtension::PostRenderBasePassMobile_RenderThread

Hi Stephane,

We did initially start with using a post-process pass, and that does of course give us access to the current frame’s stored depth as we would like. It’s also much easier to implement than all this custom shader stuff :sweat_smile: But, the post-process pass occurs after all base pass rendering is complete (opaque + translucent + fog), so our outlines render over the top of all translucent objects and are unaffected by fog, which can look bad in scenes with more dense fog. This is the reason I want to get the depth buffer during base pass rendering. Or, to be specific, just after all opaque rendering is completed.

In the test project, this requirement is also the reason I stuck some translucent spheres in the scene - to demonstrate that with this method, the outlines do draw underneath translucent objects and before fog, which is what we want.

The fog is less of a problem, we could always just re-apply fog to the outlines if we really want that (or fade them by distance, much easier and what we ended up doing with the post-process version). But drawing underneath translucent objects is only possible if we render the outlines before translucent rendering occurs.

The SceneViewExtension’s base pass callback happens right when we need, in both the single and multi pass forward rendering paths, but I suppose because the base pass is not yet ‘completed’ at that point in the single-pass rendering, the depth texture hasn’t been stored yet and is therefore inaccessible. I’ll note again that this all does work in the editor when simulating mobile, because the editor is being forced through the ‘multi pass’ forward code path, while on device we are always going through with a single pass. I assume this would also work if we were doing multi-pass forward on-device, but there is probably some performance reason we wouldn’t want to do that?