Custom mesh vertex color in shader

I am creating a custom mesh, setting the colors on the VertexData.
vertexData.colors = [r, g, b, a …]

In the shader I want to access the vertex color as part of the shader.
How can I get the per vertex color in the shader to use as part of the coloring?
Any assistance would be greatly appreciated.

Also what is a good shader reference to lookup functions and features?

If vertex colors are defined correctly the will be added as an attribute called color. see color.vertex.fx to see how it works:

Babylon.js/color.vertex.fx at master · BabylonJS/Babylon.js (

Thank you for the reply and the example.
One thing I don’t understand is the #include code.
Specially where it is importing it from.

Do you know of any easy to consume information to help me better understand that?

Not sure what information you are looking for? I always find the best place is the code itself, but we do have a very extensive documentation page, where you might find what you are looking for.

To answer your direct question, the “include” comes from here - Babylon.js/materialHelper.ts at master · BabylonJS/Babylon.js (

If colors are present, the define is added to the materials

If your question is about the include keyword itself, it works similarly to C/C++ include, which is a way to add code into a file: C/C++ #include directive with Examples - GeeksforGeeks