# Why is the vertex color interpolated differently in different cube faces?

I realise this might be a very simple and stupid question as I am just getting started with Blender.

I am trying to procedurally colour vertices to produce pseudo-colour maps.

I created this simple test with the default cube where I attempt to colour vertex 0 with red and the rest with black. I get the following result:

I understand that the colours are stored in the faces through the face loops, but I can't seem to understand why I would get a different interpolation behaviour in some faces (one is a triangular shape and the other two are rectangular shapes) and also why this interpolation is not linear. Is there a simple explanation for this? Are there alternative interpolations? Am I doing something wrong or missing something?

Here is the snippet of code I am using to produce this result (on 2.93.0):

import bpy
import bmesh

objectName = "Cube"
nodeId = 0
color = [1.0, 0.0, 0.0]

currentMesh = bpy.data.objects[objectName].data
currentBm = bmesh.new()
currentBm.from_mesh(currentMesh)
currentBm.faces.ensure_lookup_table()

if not currentBm.loops.layers.color:
currentBm.loops.layers.color.new('Col')
colorLayer = currentBm.loops.layers.color[0]

for face in currentBm.faces:
for loop in face.loops:
currentVert = loop.vert
index = currentVert.index
if index == nodeId:
loop[colorLayer] = (color[0], color[1], color[2], 1.0)
else:
loop[colorLayer] = (0.0, 0.0, 0.0, 1.0)

currentBm.to_mesh(currentMesh)
currentBm.free()


Thanks!

• A quad is really drawn as two tris, and how it looks depends on which of the two diagonals you split it along. This article is about a emulator, but it explains the issue pretty well. Jun 18, 2021 at 16:00
• Thanks @scurest. It makes sense. Jun 18, 2021 at 16:45
• @scurest this would make a fine answer on its own Jun 18, 2021 at 21:03