Accessing a Material Vertex Paint Color Value

Hi

I want to somehow access the vertex paint color value under the player 0 or 1 was painted to determine whether the player is for example standing over painted grass so you could have the proper walking sound playing.

Anyone know if this is possible in Blueprint?

Getting the material and physics materials etc. is easy enough with linetrace and i’ve tried messing around with getting the Collision UV Index but cannot seem to get or see any difference when i’m linetracing over the painted part.

Thanks!

After alot of research and testing i’ve come to the conclusion that it is not possible through blueprint, only C++.

You can either go through the Vertex buffer:
FColorVertexBuffer* colVertBuffer = &meshCompTemp->GetStaticMesh()->RenderData->LODResources[lodData].VertexBuffers.ColorVertexBuffer;

TArray colorDataFromBufferTemp;

colVertBuffer->GetVertexColors(colorDataFromBufferTemp);

Or through PaintedVertices under the LodData:
meshCompTemp->LODData[lodData].PaintedVertices[i].Color

However, both of these are not viable in packaged builds since the data gets serialized, things like position of the vertices are available if you check the Allow CPU Access and use the vertex buffer but this is because the positions and normals of the vertices are always the same, the color are different from the default ones and with Allow CPU Access you can only access the default values in the static mesh, not the ones painted out on an instance of that mesh.

1 Like

Thanks for doing the research! I had exactly the same use-case, and indeed it seems that packaged builds do not populate LODData arrays. (weirdly enough first method was not working for me in the editor either, but maybe I did something wrong).

I guess for now I will resort to reading the paint data in Editor, saving it to a file and loading this in packaged builds ;/

For it to work in editor you must have CPU Access on the Meshes.
Yea that’s what i did as well, i have plugin that does all of this comfortably on the way and i expect it to hit the epic store in march/april:
https://www.alexanderfloden.com/vertex-data-detection-plugin

That sounds great! I will keep an eye on your plugin!

Watched your video and it doesn’t explain where you get the info for macOS. This changes for each version ( :sob:) so here is a link with a description in detail.

It’s TEXT so you can print it off, copy it, etc.

1 Like