Help with gradients and distance points

I’m trying to create a gradient map based on the distances between two objects. I have the list of distances and their corresponding points (vertices), but when I apply them to the mesh, I get a noisy/grainy gradien. This happens even though the longer distances are physically located at the lateral parts of the sample. I have ensured that the list lengths match and all inputs are flattened. Any insights on why the vertex indices might be mismatching or how to fix this visualization?

DISTANCE_ARTICLE_Q.gh (2.2 MB)

Hello
you have to understand that you must provide a color for each vertex of the mesh. So for each point of the mesh you make a calculation.
Also I understand that

But you have 3 objects ?
So with 2 objects, a surface and a mesh here is a way


DISTANCE_ARTICLE_Q_LD.gh (1.5 MB)

Seconding what Laurent already inquired about (more than 2 meshes), did you intend to colorize both meshes based on their distance to the surface?

Pretty much the same as Laurent’s example, just brings in both meshes:
DISTANCE_ARTICLE_Q.gh (2.2 MB)