Babylon.js Playground (see the setVertexColors() method)
I have a ground mesh with a texture, and I am wanting to set the individual vertex colors on the mesh in order to draw a “path” with clean edges (so I want to be able to “fill in” certain facets (triangles) as opposed to sides (squares)).
I’ve run into two main problems, that being
How to properly set the vertex colors? In the playground, there are 3 images each 64x64 pixels. One is for the heightmap, one is for the texture, and one is for the “path”. I’m getting the pixel data from the “path” image from an offscreen canvas, but I’m not sure how to apply this to the vertex data of the mesh.
And also, in order to “map” the pixels to each vertex instead of each side (which is essentially mapping 1 pixel in the path image to 1 square on the ground mesh), I’m guessing it’d be necessary to double the size of the image, that way 1 pixel in the path image can map to 1 vertex on the ground mesh, thus being able to “fill in” triangles instead of squares.
When setting the vertices data on the ground mesh, how can I do this without affecting the texture? Again, I need the path to be “over” the texture, like so (texture is in wireframe mode to make it more clear):