How can I add measured values to specific vertices on a mesh, then interpolate between them to get calculated values for all the vertices?

I would like to create a colour map across the surface of an entire 3D model. I have two parts to the problem as I think once I have the values assign I should be able to assign the colours:

  1. I have some measured values that I want to assign to specific locations on the mesh.

  2. I then want to interpolate between these measured values to get calculated values for all the vertices.

I can’t seem to find a way to assign the measured values to the specific vertices. Probably a stupid question, but how do I know the locations of the vertices I want to assign the measured values to? (The model is not a regular shape) My instinct would be to make a matrix with the values of each vertex, but I’m not sure how to do this and how would I know which matrix value corresponds to a given vertex?

I am using C# to write this as a mobile application.

You need to create a mapping of the positions of the measured values to the positions of the vertices in the mesh. You can either do this with user input (e.g. the user clicks on parts of the mesh), or you come up with a clever algorithm (without knowing more about your project, I cannot be more specific).

For example, if you are taking temperature readings from a real-world human body at certain locations, and your mesh in the application is a human body, you can use raycasting to get the vertices they clicked on. Then you map your temperature (or whatever measurement) value to a color, and assign that color to the vertex or the texture. Then based on distance from those vertices, you interpolate on a gradient.

Assigning the color to the vertex has the disadvantage that you will need a shader that uses vertex colors (the default shader ignores them) and that the resolution of the colour map will depend on the resolution of your mesh. However, it is more intuitive how it works, and is easier to program.

Assigning colour to the texture, you need to be able to map the distance to texture space (full 3D to 2D in range [0-1]), but the mapping is not limited by the resolution of the mesh.