Assign color to a mesh rather than to the material

Hi
I wrote a simple example in the playground for this question.
https://playground.babylonjs.com/#S56Q7F
In this playground you can see the sea and an island of little tiles.
I’d like to colorized some of the tiles with dynamic colors.
The simplest way would be to create a material for each tint I need but this doesn’t work well with a large variety of colors.
I know there is a way to push an extra colors to each individual mesh.
I try to modify diffuseColor adding a uniform property but I had not success doing it.
I fail to find any beginner friendly documentation about this.

1 Like

You can use vertexColors: Babylon.js Playground (babylonjs.com)

Here’s your playground with the same technique from the one above: Question: How do I color these tiles | Babylon.js Playground (babylonjs.com)

2 Likes

You can also try using a different overlay color for each mesh. :slightly_smiling_face:
https://playground.babylonjs.com/#S56Q7F#2

1 Like

This is what I needed.
I can see it is a bit like what I do on UV.
The overlay option is very straight forward.
I had not seen those properties.
There is much to learn.
Thank you both

1 Like

The SPS might your friend as it was designed for this kind of goal :

you can set a different color and picture (“texture”) from a global image and still use only one mesh and one material

2 Likes