0
$\begingroup$

New to Blender, and the documentation for bpy is throwing me for a few loops. I got a setup in the compositing layer working for my desired goal as shown:

Input

This renders an image and a color-coded mask for each of the three unique pass_index marked objects (below), and am trying to automate this through a bpy script as there are many variations I'll need to render.

Output

Each object can be given a pass index in bpy via e.g. bpy.data.objects['foo'].pass_index = bar, but I'm having trouble figuring out how to separate each layer(?) via pass index as the compositing nodes do. Simple camera manipulations and the like are straightforward (I have a script that can import the stl, setup camera/lighting as required, and produce images like the left one above), but I'm lacking the terminology to search the right question or understand the documentation- and recent changes between 2.7x and 2.8x make a number of older guides very difficult to understand...

Related would be the steps of adding a color and recombining to form a single image as shown in the compositing layer, but small steps first. Any help would be appreciated, thank you!

$\endgroup$
2
  • 1
    $\begingroup$ Using ID Masks for compositing is a very bad idea. They will cause serious problems with the edges if used for compositing compared to alternatives. Consider Cryptomatte instead. That's a way better solution in vast majority of cases. $\endgroup$ Jun 27, 2020 at 21:38
  • $\begingroup$ In the days when Cryptomatte was not around, what was the right way and purpose to use ID masks in blender? $\endgroup$ Oct 27, 2020 at 3:06

1 Answer 1

1
$\begingroup$

Specific answer for the task at hand (image segmentation) is given by the bpycv module. This isn't the same as a general compositor -> bpy solution, but posting here in case someone else also happens to (somehow) miss bpycv, yet find this post.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .