I'm rendering a mesh with vertex colors, but cannot get the colors to render. I'm using blender python 3.4.0

Here's what I tried:

# get object
ob = bpy.context.active_object
# set vertex paint toggle

# set to edit mode
bpy.ops.object.mode_set(mode = 'EDIT')

# make new material
mat = bpy.data.materials.new(name = "Col")

# make new node for vertexColors
vc = mat.node_tree.nodes.new("ShaderNodeVertexColor")
bsdf = mat.node_tree.nodes["Principled BSDF"]

# link vertexcolors node to bsdf, Base Color
mat.node_tree.links.new(bsdf.inputs["Base Color"] , vc.outputs['Color'])

# append material to mesh

# render

The object returned is grey. Am I forgetting something? What is the best way to debug this? I checked that vertex colors are present by saving the obj and colors to .ply and visualizing it shows colors.

  • $\begingroup$ Try mat.use_nodes = True after mat = bpy.data.materials.new(...) $\endgroup$
    – Gorgious
    Feb 16 at 16:19


You must log in to answer this question.