- Home /
Getting the colour of any point on a plane?
I want to find the colour of a point on a MeshFilter. I know I could get an array of vertex colours from meshFilter.mesh.colours[]
but these are just an array of colours of each individual vertices. Sometimes the colour of a point between 2 vertices are interpolated and so it wouldn't be accurate to just get the colour of one particular vertex.
How can I find the colour of any given point on a plane with a MeshFilter component?
Answer by Statement · Mar 08, 2013 at 02:00 PM
but these are just an array of colours of each individual vertices. Sometimes the colour of a point between 2 vertices are interpolated and so it wouldn't be accurate to just get the colour of one particular vertex.
Right, so what you can do is to interpolate the color yourself based of the three color values of the triangle. I don't know how you pick the point in your mesh, but if you for example use a raycast and get a ray cast hit, you could use the barycentric coordinate to interpolate it pretty easily. See the example in the docs for RaycastHit.barycentricCoordinate that does this for a normal for example.