This is complicated if you want to do it from the mesh shader. You can use maxzBuffer to read the prepass depth but this will not contain the transparent objects and will be half resolution. Moreover, your node gpu C code would need to tag the GPUMaterial with one of these:
If you want to do a fullscreen pass after perpass and shading you will have to setup a render pass yourself in C. This would be a much cleaner option but then you cannot have per shader parameter tweaks.
I got it somewhat working, although I cheated a bit (I disabled the half resolution on the maxzbuffer).
Hopefully if I interpolate manually the half res buffer in the shader I can get good enough results.
By the way, just to be sure. Assuming a full resolution buffer and no floating point errors, in the following code reconstructed and viewPosition should be equal, right?
Having a fullscreen pass would be too limiting for artists IMO, and would no longer be compatible with cycles.
I’ll upload a patch to phabricator soon anyway, so we can see there what’s needed to get this into master. For now I was just focused in getting it into a working state.