Per-vertex color. in a custom RealityKit mesh? (macOS)

I'm working on an application for viewing AMF models on macOS, using RealityKit. AMF supports several different ways to color models, including per-vertex color (where the color of a triangle is interpolated from vertex to vertex) as well as per-face color (where the color of the triangle is the same across the entire face).

I'm trying to figure out how to support those color models using a RealityKit mesh. Apple's documentation (https://developer.apple.com/documentation/realitykit/modifying-realitykit-rendering-using-custom-materials) talks about per-vertex colors, but I haven't found a way to create a mesh that includes per-vertex colors, other than use a texture map (which might be the correct solution).

Can someone give me some pointers?

I also find the documentation difficult to follow. A full example of the triangle that is shown in the documents would be quite helpful.

@raldrich Hi, did you ever figure this out? I am following this same path and I am surprised that MeshDescriptor does not appear to define a vertex color option. Maybe the answer is to define a custom buffer and then, at least on visionOS, hope that it's possible to define a shader graph that accesses the custom buffer.

Hi @hhjgjhghjghjghjg you might be able to get vertex colors to work with something like

let vertexColor: MeshBuffers.Semantic = MeshBuffers.custom("vertexColor", type: SIMD4<Float>.self)
let meshResource = MeshDescriptor()
meshResource[vertexColor] = ...

I've been unsuccessful so far. If anyone has gotten RealityKit to handle a vertexColor buffer to work, please provide some more details.

I seem to have come even shorter than you with displaying the vertex colors.

My setup is a simple USDC with vertex colors which show up fine in Blender but renders pink in both Xcode preview and in Reality Composer.

I've tried every consiveable constellation of the shader graph nodes VertexID, GeometryColor and GeometryProperty

Would love to hear from anybody that has gotten vertex colors to work in RCP, even just for math operations instead of shading.

Per-vertex color. in a custom RealityKit mesh? (macOS)
 
 
Q