Vertex color and material color overlay

Hello there!

I want to change the color of some faces on a certain mesh by setting the “VertexBuffer.ColorKind” property. But when the mesh has its own material and the diffuseColor is not white, vertex color is affected by the diffuseColor. I cannot get what I want. How can I do?

What I want is:

What I get now:

Hello @Eric.J , how are you doing?

My understanding is that material’s diffuseColor will multiply the values you have in each vertex color.

Thank you for your reply @srzerbetto .
So what can I do if I want to keep both the diffuseColor and each vertex color?

I believe this will not be possible without writing a custom shader. With a custom shader you would be able to do some custom logic, such as using the alpha value of Vertex colors as a “mask” and having something like this:

vertexColor.r = (1 - vertexColor.a ) * vertexColor.r + (vertexColor.a * diffuseColor.r)
vertexColor.g = (1 - vertexColor.a ) * vertexColor.g + (vertexColor.a * diffuseColor.g)
vertexColor.b = (1 - vertexColor.a ) * vertexColor.b + (vertexColor.a * diffuseColor.b)
vertexColor.a = 1;

This way vertex that have alpha = 1 will be rendered using diffuse color and others will be rendered using vertex color.

Alright, let me give it a try. Thank you so much!