How to find pixels which are getting occluded in the next frame? I have 3D model of a scene with several objects that are transformed from one keyframe to another one (translation, rotation, scaling). This scene will be rendered as animation with write_still=True so the final results are images per each frame. I am interested in finding pixels that are visible in one frame but are occluded in the next frame. A simple example could be something like this:

First frame ----------- > Second frame




In this example, the colorful plane is fully visible in the first frame but is getting behind the gray square in the second frame, so not only the bottom left corner of it is occluded now, but part of the background near the gray square is also occluded by the colorful square. In the next image, the occluded areas are highlighted white. I would like to have a binary mask that shows which pixels from the first frame will be occluded in the next frame. The final goal is to do this by Python interface, but any suggestion to solve this is very appreciated.



Please note that objects are 3D, they might rotate or scale too. Lighting will change and the camera motion is also involved. A more complete example is as follows:

First frame



Second frame



Occlusion map
Please see the panel ... object relations pass index. This information can be examined in the compositor.  This is generated in the object index render pass for Cycles. You must enable that pass.



There is also Cryptomatte.