Using vertex colors in Blender 2.8

Ben Olayinka
benlearnsblender
Published in
4 min readMar 28, 2020

I’m creating a pickable scene in Blender, using two flat colors. It looks like this.

Each object in the scene has a light and dark material, and I wrote a script to change the material color when an object is highlighted. Since the materials are separate, the picking doesn’t look right.

only dark material is selected
only light material selected

To fix this, I want to combine the materials so that each object uses only one material, and use vertex colors on the faces to achieve the same light and dark effect. I couldn’t find any information about using a paint mask to color vertex groups or faces in Blender 2.8, so here’s how I did it.

  1. Delete the second material (or create a single material if you’re starting from scratch).

2. Hit ctrl-tab and go in to Vertex Paint mode. This will automatically create a Vertex Colors node called ‘col’ in the object properties.

3. In the material’s shader, hit shift-a and add a Vertex Colors node.

4. Attach the vertex colors node to the base color of the material (just drag a line between the nodes)

5. Go back in to edit mode (tab or ctrl-tab) and select the faces you want to color.

i selected all faces for the base color (just hit a to select all)

6. Go back to Vertex Paint mode and choose Paint Mask (the square looking button next to the edit mode dropdown, also called ‘Face selection mask for painting’). This is the magic sauce. It will allow you to paint only the faces you selected in edit mode.

Note 1: this step was the most difficult for me to find information about. The interface has changed in Blender 2.8, and this button moved and got a completely different icon.

Note 2: Choosing the faces paint mask will give you hard edges at the edges of your faces, while choosing the vertices paint mask (the next button over) will give you a gradient between vertices.

7. In the properties window, open the Active Tool browser and choose a color in the color picker. Hit shift-k or Paint — Set Vertex Colors to paint all the selected faces that color.

8. Tab or ctrl-tab to go back to edit mode. Select the faces you want to paint another color.

9. Tab or ctrl-tab to go back to Vertex Paint mode. Pick another color in the color picker. I’m only using two colors in my scene, so I set one as the background color, and then flip them using the switch button in the color picker.

switch easily between background and foreground colors and use shift-k to paint

10. Shift-k to paint the newly selected faces with the newly selected active color.

And voila!! If you export now, you should see that your entire object is made a of a single material, with vertex colors specified. Now my object picker works!

picking affects the color of the entire object! yay!

--

--

Ben Olayinka
benlearnsblender

Ben is an engineer, an optimist about love, a record collector, a poser writer, and a goofy DJ who plays disco everywhere.