Is it possible to create a colour gradient across an entire mesh if only a few vertices have colour?

I have been struggling to create a shader for my model of ~40,000 vertices. I have 144 vertices which I have assigned a colour to. (These 144 vertices represent real life data that I have obtained from sensors, so I can not increase the number of vertices initially coloured)

I would like to create a colour gradient between these vertices, so that the entire model is coloured, similar to a heat map.

I’ve tried using Lerp on the vertex matrix, but because the vertex numbers are seemingly random compared to their location, I’m not getting the interpolation between appropriate locations, rather neighbouring vertex numbers.

I have tried using something similar to this, but as I have so few vertices initially coloured, I just end up with a black model with colours spots:

My question: is it possible to do it in this way? If not, is there another way? I can’t seem to find one.

Interesting, I’ve been working on something scarily similar…

Anyway, I just iterate through all the vertices of the model (mine is about 9000 vertices), and interpolate using the distance from each of my colored points. I use a Gradient object and a float[] heatValues (one value for each vertex) that stores the current “heat” value, then evaluate the gradient for each vertex, and finally assign the vertex colors.

It is faster than expected, there’s no FPS drop even if I update every frame.

Does this make sense?