Assigning a color to each object in scene

I want to create a picture-in-picture view that shows objects in the scene in their unique colors, i.e., scene is rendered such that each object has its outline and filled with some flat color (no texture or reflection or shadow etc). I can create the picture-in-picture view using Scene2DComponent and I’m thinking I can create some post processing material that is rendered on it. The post processing will basically replace each object with some random flat color. For this I need to be able to identify which pixel corresponds to which object in post processing and then select color for that object. Is this possible? Any detail on how to accomplish this would be great!

Below is the example of rendering I want to do:

you could use the custom depth with the new stencil index feature.