Skip to main content
100%

Blender: assign a unique vertex color for each material to the mesh (id map)

✓ Published0🌍 Public
MMcNull
Last edited Mar 20, 2022
Created on Mar 20, 2022

This example shows a Blender Python script that assigns a unique vertex color to every face based on the material assigned to that face, creating an ID map for meshes. It iterates through selected mesh objects, generates a color palette (either random or procedurally spaced via HSV), and writes these colors into a vertex color layer named `_IDMAP_`. The code uses Blender’s `bpy` API to access polygons, material slots, and vertex color data, directly manipulating `vertex_colors.data[i].color` per loop index.

AI-generated description

Similar vizzes