To quickly create a color mask by materials, assigned to the scene objects, for post-processing
you can use the following script:
1 2 3 4 5 6 7 |
import bpy import random for material in bpy.data.materials: material.diffuse_color[0] = random.uniform(0, 1) material.diffuse_color[1] = random.uniform(0, 1) material.diffuse_color[2] = random.uniform(0, 1) |
This script assigns each material its own random viewport color.
After assigning colors, you can render the viewport by selecting in the 3D Viewport menu: View – Viewport Render Image (Viewport Render Animation), and save the resulting image for later use as a mask in compositing.