I am using the blender to create a visual parking scene model, by using the python script the model could produces a RGB picture of the parking scene as well as the depth image, both are showing below.

enter image description here

enter image description here

I am just wondering would it possible to also create a segmentation image which separates each object class with a color, for example all the car object are in red, all the ground are in blue, all the building are in grey, like the examples

enter image description hereenter image description here


Give each object a unique 'pass index'. You can use the compositor, the Object Info node, and some math nodes to convert it to a colour.

This happens when you divide the object index by the maximum index you're using (to get it to a 0-1 value), and apply it to a diffuse material:

As diffuse material

By using a Colour Ramp you can take that 0-1 value and map it to discrete colours:

With colour ramp as diffuse material

By swapping out the Diffuse shader with an Emission shader, you just get the straight colour values:

With colour ramp as emission shader

This is the final material:

Cycles material node setup

This is the blend file I used:

See the manual for more info.

  • $\begingroup$ is there any tutorial for this ? $\endgroup$ – user824624 Jun 8 '17 at 1:39
  • $\begingroup$ I've added example images, the node setup, and an example blend file for you. $\endgroup$ – dr. Sybren Jun 10 '17 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.