Thanks Is it possible to take a look at your implementation of the method?
Currently I see two ways to do it:
A) render scene with modified shaders
B) use original shaders, but render in two passes:
- render everything (to fill depthbuffer), clear color buffer to white
- render everything with ZTest:EQUAL, ZWrite:Off, Blending:(SrcFactor=0, DestFactor=object-ID-color)
The second approach will result in wrong color if more than one pixel passes Z-test, but this is supposedly a rare situation.