2

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:

Vertex 0 in red and the red to black interpolation. All hidden vertices are black as expected.

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!

Rui Costa
  • 91
  • 3

0 Answers0