BABYLON.Mesh (custom mesh) is only colouring 1 in 4 facets

I have a model which (for now) assigns the same colour to each position on each facet. This will soon be variable though, once I can fix this issue, so this custom vertex colouring needs to remain.

The trouble is only 1 in every 4 facets gets coloured. I’m not sure what’s causing this, any ideas?

https://playground.babylonjs.com/#J7JSQX

I have been trying to figure this out and I think it might actually be a problem with the way 3 out of 4 of the faces are responding to light. When I apply two lights at different locations I can actually see that a very small amount of the green is being applied to the vertices that I thought weren’t being coloured. But nowhere near as much as one of the vertices on each group of 4. New Playground below. I’m not sure where to go from now.

https://playground.babylonjs.com/#J7JSQX#1

When I turn backface culling on I can see that some faces are disappearing, meaning that you are not creating the faces correctly (in the correct winding order) and thus I believe the normals are also wrong

Thanks @Deltakosh. I reread the mesh and normals docs and I think I understand now. I changed the order the vertices are pushed into the array so that these are specified in a clockwise order when viewed from above. This worked perfectly with a blank normals array (letting Babylon calculate the normals). I believe that if any of the facets I want coloured had faced down (in a negative direction) then I would have needed to specify the normal directions.

2 Likes