At the moment it seems like it isn’t possible to make a generic NodeMaterial() that:
- Uses vertex colors
- And also works for meshes that don’t include vertex colors
This is because the vertex color input returns zero vector when attribute isn’t defined, so any material that uses the vertex color input will inevitably render black when applied to a mesh or mesh primitive that doesn’t inlcude vertex colors.
I think a best solution would be to make InputBlock of color type return a vec4(1.0) when the vertex color attribute isn’t present. This way color input node would behave in expected way for meshes that don’t include color data.
For now I was able to come up with a workaround by creating a custom EnsureVertexColor node, but even that required overwriting NodeMaterial _prepareDefinesForAttributes
method so that it also exposes a #define for vertex color. However, this is so convoluted workaround that hopefully an official way to use vertex color input on generic meshes will be added.